Author: jonananas
Date: 2011-04-13 14:38:45 -0400 (Wed, 13 Apr 2011)
New Revision: 885
Modified:
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/SamlMessageFactory.java
Log:
PLFED-172 Picketlink-seam: AuthnRequest should contain NameIDPolicy
createAuthnRequest now uses SAML2Request, with the effect that NameIDPolicy element is
present
Modified:
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/SamlMessageFactory.java
===================================================================
---
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/SamlMessageFactory.java 2011-04-13
05:08:53 UTC (rev 884)
+++
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/SamlMessageFactory.java 2011-04-13
18:38:45 UTC (rev 885)
@@ -28,6 +28,7 @@
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
+import org.picketlink.identity.federation.api.saml.v2.request.SAML2Request;
import org.picketlink.identity.federation.core.exceptions.ConfigurationException;
import org.picketlink.identity.federation.core.saml.v2.common.IDGenerator;
import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLConstants;
@@ -53,8 +54,8 @@
private ServiceProvider serviceProvider;
public StatusResponseType createStatusResponse(RequestAbstractType request, String
statusCode, String statusMessage)
- {
- StatusResponseType response = new StatusResponseType();
+ {
+ StatusResponseType response = new StatusResponseType();
response.setID(generateId());
response.setIssueInstant(generateIssueInstant());
@@ -67,7 +68,7 @@
response.setInResponseTo(request.getID());
StatusCodeType statusCodeJaxb = new StatusCodeType();
- statusCodeJaxb.setValue( URI.create(statusCode) );
+ statusCodeJaxb.setValue(URI.create(statusCode));
StatusType statusType = new StatusType();
statusType.setStatusCode(statusCodeJaxb);
@@ -83,24 +84,23 @@
public AuthnRequestType createAuthnRequest()
{
- AuthnRequestType authnRequest = new AuthnRequestType( generateId(),
JBossSAMLConstants.VERSION_2_0.get() , generateIssueInstant() );
-
- NameIDType issuer = new NameIDType();
- issuer.setValue(serviceProvider.getSamlConfiguration().getEntityId());
- authnRequest.setIssuer(issuer);
-
-
- // Fill in the optional fields that indicate where and how the response should be
delivered.
- authnRequest.setAssertionConsumerServiceURL(URI.create( serviceProvider
- .getServiceURL(ExternalAuthenticationService.SAML_ASSERTION_CONSUMER_SERVICE
)));
- authnRequest.setProtocolBinding( URI.create(
"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" ));
-
- return authnRequest;
+ SAML2Request saml2request = new SAML2Request();
+ try
+ {
+ return saml2request.createAuthnRequestType(generateId(),
+
serviceProvider.getServiceURL(ExternalAuthenticationService.SAML_ASSERTION_CONSUMER_SERVICE),
null,
+ serviceProvider.getSamlConfiguration().getEntityId());
+ }
+ catch (ConfigurationException e)
+ {
+ throw new RuntimeException(e);
+ }
}
- public LogoutRequestType createLogoutRequest(SeamSamlPrincipal principal) throws
ConfigurationException
- {
- LogoutRequestType logoutRequest = new LogoutRequestType( generateId(),
JBossSAMLConstants.VERSION_2_0.get(), generateIssueInstant());
+ public LogoutRequestType createLogoutRequest(SeamSamlPrincipal principal)
+ {
+ LogoutRequestType logoutRequest = new LogoutRequestType(generateId(),
JBossSAMLConstants.VERSION_2_0.get(),
+ generateIssueInstant());
NameIDType issuer = new NameIDType();
issuer.setValue(serviceProvider.getSamlConfiguration().getEntityId());
@@ -109,9 +109,9 @@
NameIDType nameID = new NameIDType();
nameID.setValue(principal.getNameId().getValue());
logoutRequest.setNameID(nameID);
-
- logoutRequest.addSessionIndex( principal.getSessionIndex() );
+ logoutRequest.addSessionIndex(principal.getSessionIndex());
+
return logoutRequest;
}
Show replies by date