[java-shib-idp2 COMMIT] in /branches/REL_2: doc/RELEASE-NOTES.txt src/main/java/edu/internet2/middleware/shibboleth/i...

noreply at shibboleth.net noreply at shibboleth.net
Mon Oct 10 14:29:42 BST 2011


Author: lajoie
Date: Mon Oct 10 14:29:42 2011
New Revision: 3072

URL: http://svn.shibboleth.net/view/java-shib-idp2?rev=3072&view=rev
Log:
Expose AuthnRequest XMLObject - SIDP-523

Modified:
    branches/REL_2/doc/RELEASE-NOTES.txt
    branches/REL_2/src/main/java/edu/internet2/middleware/shibboleth/idp/authn/Saml2LoginContext.java

Modified: branches/REL_2/doc/RELEASE-NOTES.txt
URL: http://svn.shibboleth.net/view/java-shib-idp2/branches/REL_2/doc/RELEASE-NOTES.txt?rev=3072&r1=3071&r2=3072&view=diff
==============================================================================
--- branches/REL_2/doc/RELEASE-NOTES.txt (original)
+++ branches/REL_2/doc/RELEASE-NOTES.txt Mon Oct 10 14:29:42 2011
@@ -5,6 +5,7 @@
 [SIDP-514] - Alt text for IdP Logos is not esapiEncoder.encodeForHTMLAttribute
 [SIDP-520] - Ipad/iOS devices will auto capitalize text entered into the IdP login screen, which can cause errors. Adding an HTML element will prevent that
 [SIDP-522] - supplied examples shouldn't promote federation URIs as relying parties
+[SIDP-523] - Add access to inbound AuthnRequest
 
 Changes in Release 2.3.3
 =============================================

Modified: branches/REL_2/src/main/java/edu/internet2/middleware/shibboleth/idp/authn/Saml2LoginContext.java
URL: http://svn.shibboleth.net/view/java-shib-idp2/branches/REL_2/src/main/java/edu/internet2/middleware/shibboleth/idp/authn/Saml2LoginContext.java?rev=3072&r1=3071&r2=3072&view=diff
==============================================================================
--- branches/REL_2/src/main/java/edu/internet2/middleware/shibboleth/idp/authn/Saml2LoginContext.java (original)
+++ branches/REL_2/src/main/java/edu/internet2/middleware/shibboleth/idp/authn/Saml2LoginContext.java Mon Oct 10 14:29:42 2011
@@ -21,6 +21,7 @@
 import java.io.StringWriter;
 import java.util.List;
 
+import org.apache.tools.ant.filters.StringInputStream;
 import org.opensaml.Configuration;
 import org.opensaml.saml2.core.AuthnContext;
 import org.opensaml.saml2.core.AuthnContextClassRef;
@@ -30,12 +31,16 @@
 import org.opensaml.saml2.core.RequestedAuthnContext;
 import org.opensaml.xml.io.Marshaller;
 import org.opensaml.xml.io.MarshallingException;
+import org.opensaml.xml.io.Unmarshaller;
 import org.opensaml.xml.io.UnmarshallingException;
+import org.opensaml.xml.parse.ParserPool;
+import org.opensaml.xml.parse.XMLParserException;
 import org.opensaml.xml.util.DatatypeHelper;
 import org.opensaml.xml.util.LazyList;
 import org.opensaml.xml.util.XMLHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 /**
@@ -51,10 +56,13 @@
     /** Relay state from authentication request. */
     private String relayState;
 
+    /** The authentication request. */
+    private transient AuthnRequest authnRequest;
+
     /** Serialized authentication request. */
     private String serialAuthnRequest;
-    
-    /** Unsolicited SSO indicator.  */
+
+    /** Unsolicited SSO indicator. */
     private boolean unsolicited;
 
     /**
@@ -68,36 +76,61 @@
      */
     public Saml2LoginContext(String relyingParty, String state, AuthnRequest request) throws MarshallingException {
         super();
-        
+
         if (relyingParty == null || request == null) {
             throw new IllegalArgumentException("SAML 2 authentication request and relying party ID may not be null");
         }
+        
         setRelyingParty(relyingParty);
         relayState = state;
+        authnRequest = request;
         serialAuthnRequest = serializeRequest(request);
-        
+
         setForceAuthRequired(request.isForceAuthn());
         setPassiveAuthRequired(request.isPassive());
         getRequestedAuthenticationMethods().addAll(extractRequestedAuthenticationMethods(request));
     }
 
     /**
+     * Gets the authentication request object.
+     * 
+     * @return the authentication request object
+     * 
+     * @throws UnmarshallingException thrown if there is a problem unmarshalling the serialized form of the request
+     */
+    public synchronized AuthnRequest getAuthenticiationRequestXmlObject() throws UnmarshallingException {
+        if (authnRequest == null) {
+            try {
+                ParserPool parser = Configuration.getParserPool();
+                Document requestDoc = parser.parse(new StringInputStream(serialAuthnRequest));
+                Unmarshaller requestUnmarshaller =
+                        Configuration.getUnmarshallerFactory().getUnmarshaller(AuthnRequest.TYPE_NAME);
+                authnRequest = (AuthnRequest) requestUnmarshaller.unmarshall(requestDoc.getDocumentElement());
+            } catch (XMLParserException e) {
+                throw new UnmarshallingException("Unable to unmarshall serialized authentication request", e);
+            }
+        }
+
+        return authnRequest;
+    }
+
+    /**
      * Gets the serialized authentication request that started the login process.
      * 
      * @return authentication request that started the login process
      * 

[... 72 lines stripped ...]


More information about the commits mailing list