[java-idp-testbed] branch master updated: IDP-1217 Add RequestedAttributes call to the test SP in the testbed

Rod Widdowson rdw at steadingsoftware.com
Fri Jun 15 12:07:19 EDT 2018


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch master
in repository java-idp-testbed.

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-testbed.git;a=commit;h=ccc33ff3e31ae945aead4e2a080c4461b7ad8818

The following commit(s) were added to refs/heads/master by this push:
       new  ccc33ff   IDP-1217  Add RequestedAttributes call to the test SP in the testbed
ccc33ff is described below

commit ccc33ff3e31ae945aead4e2a080c4461b7ad8818
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Fri Jun 15 17:06:40 2018 +0100

    IDP-1217  Add RequestedAttributes call to the test SP in the testbed
    
    https://issues.shibboleth.net/jira/browse/IDP-1217
---
 src/main/java/sp/SAML2Controller.java | 30 +++++++++++++++++++++++++++++-
 src/main/webapp/index.html            |  2 ++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/src/main/java/sp/SAML2Controller.java b/src/main/java/sp/SAML2Controller.java
index 9ae534e..c97f8a4 100644
--- a/src/main/java/sp/SAML2Controller.java
+++ b/src/main/java/sp/SAML2Controller.java
@@ -40,6 +40,7 @@ import org.opensaml.saml.common.messaging.SAMLMessageSecuritySupport;
 import org.opensaml.saml.common.messaging.context.SAMLEndpointContext;
 import org.opensaml.saml.common.messaging.context.SAMLPeerEntityContext;
 import org.opensaml.saml.common.xml.SAMLConstants;
+import org.opensaml.saml.ext.reqattr.RequestedAttributes;
 import org.opensaml.saml.ext.saml2aslo.Asynchronous;
 import org.opensaml.saml.saml2.binding.encoding.impl.HTTPPostEncoder;
 import org.opensaml.saml.saml2.binding.encoding.impl.HTTPRedirectDeflateEncoder;
@@ -60,6 +61,7 @@ import org.opensaml.saml.saml2.core.Status;
 import org.opensaml.saml.saml2.core.StatusCode;
 import org.opensaml.saml.saml2.core.Subject;
 import org.opensaml.saml.saml2.metadata.Endpoint;
+import org.opensaml.saml.saml2.metadata.RequestedAttribute;
 import org.opensaml.saml.saml2.metadata.SingleLogoutService;
 import org.opensaml.saml.saml2.metadata.SingleSignOnService;
 import org.opensaml.saml.saml2.profile.SAML2ActionTestingSupport;
@@ -137,6 +139,17 @@ public class SAML2Controller extends BaseSAMLController {
         encodeOutboundMessageContextRedirect(messageContext, servletResponse);
     }
     
+    @RequestMapping(value="/InitSSO/ReqAttr", method=RequestMethod.GET)
+    public void initSSORequestReqAttr(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws Exception {
+        final AuthnRequest authnRequest = buildAuthnRequest(servletRequest);
+        authnRequest.setExtensions(buildRequestedAttributesExtensions());
+        authnRequest.setDestination(getDestinationRedirect(servletRequest, "SSO"));
+        final Endpoint endpoint = buildIdpSsoEndpoint(SAMLConstants.SAML2_REDIRECT_BINDING_URI, authnRequest.getDestination());
+        final String idpEntityID = getIdpEntityId(servletRequest);
+        final MessageContext<SAMLObject> messageContext = buildOutboundMessageContext(authnRequest, endpoint, idpEntityID);
+        encodeOutboundMessageContextRedirect(messageContext, servletResponse);
+    }
+
     @RequestMapping(value = "/InitSSO/POST/Passive", method = RequestMethod.GET) public void initSSORequestPostPassive(
             HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws Exception {
         final AuthnRequest authnRequest = buildAuthnRequest(servletRequest);
@@ -403,10 +416,25 @@ public class SAML2Controller extends BaseSAMLController {
 	            authnRequest.setScoping(scoping);
 		    }
 		}
-		
 		return authnRequest;
 	}
 
+    private Extensions buildRequestedAttributesExtensions()
+    {
+        final RequestedAttribute attribute = (RequestedAttribute) builderFactory.getBuilder(
+                RequestedAttribute.DEFAULT_ELEMENT_NAME).buildObject(RequestedAttribute.DEFAULT_ELEMENT_NAME);
+        attribute.setFriendlyName("mail");
+        attribute.setName("urn:oid:0.9.2342.19200300.100.1.3");
+        attribute.setNameFormat("urn:oasis:names:tc:SAML:2.0:attrname-format:uri");
+        final RequestedAttributes attributes = (RequestedAttributes) builderFactory.getBuilder(
+                RequestedAttributes.DEFAULT_ELEMENT_NAME).buildObject(RequestedAttributes.DEFAULT_ELEMENT_NAME);
+        attributes.getRequestedAttributes().add(attribute);
+        final Extensions extensions = (Extensions) builderFactory.getBuilder(
+                Extensions.DEFAULT_ELEMENT_NAME).buildObject(Extensions.DEFAULT_ELEMENT_NAME);
+        extensions.getUnknownXMLObjects().add(attributes);
+       return extensions;
+    }
+
     private LogoutRequest buildLogoutRequest(HttpServletRequest servletRequest) {
         final LogoutRequest logoutRequest = (LogoutRequest) builderFactory.getBuilder(
                 LogoutRequest.DEFAULT_ELEMENT_NAME).buildObject(LogoutRequest.DEFAULT_ELEMENT_NAME);
diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html
index 324a562..202aaed 100644
--- a/src/main/webapp/index.html
+++ b/src/main/webapp/index.html
@@ -12,6 +12,8 @@
 <li><a href="sp/SAML2/InitSSO/Redirect">Init SAML 2 SSO, Redirect Binding</a></li>
 <li><a href="sp/SAML2/InitSSO/Passive">Init SAML 2 SSO, Redirect Binding, Passive Request</a></li>
 <li><a href="sp/SAML2/InitSSO/ForceAuthn">Init SAML 2 SSO, Redirect Binding, ForceAuthn Request</a></li>
+<li><a href="sp/SAML2/InitSSO/ReqAttr">Init SAML 2 SSO, Redirect Binding, Requested Attributes</a></li>
+
 <li><a href="sp/SAML2/InitSSO/POST">Init SAML 2 SSO, POST Binding</a></li>
 <li><a href="sp/SAML2/InitSSO/POST/Passive">Init SAML 2 SSO, POST Binding, Passive Request</a></li>
 <li><a href="sp/SAML2/InitSSO/POST/ForceAuthn">Init SAML 2 SSO, POST Binding, ForceAuthn Request</a></li>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list