Skip to content

Commit ca62a64

Browse files
committed
Support configuration of protocol binding for authentication requests
1 parent 971ae34 commit ca62a64

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/authentication/OpenSamlAuthenticationRequestFactory.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.security.saml2.provider.service.authentication;
1818

19+
import org.opensaml.saml.common.xml.SAMLConstants;
1920
import org.springframework.util.Assert;
2021

2122
import org.joda.time.DateTime;
@@ -32,6 +33,7 @@
3233
public class OpenSamlAuthenticationRequestFactory implements Saml2AuthenticationRequestFactory {
3334
private Clock clock = Clock.systemUTC();
3435
private final OpenSamlImplementation saml = OpenSamlImplementation.getInstance();
36+
private String protocolBinding = SAMLConstants.SAML2_POST_BINDING_URI;
3537

3638
/**
3739
* {@inheritDoc}
@@ -43,7 +45,7 @@ public String createAuthenticationRequest(Saml2AuthenticationRequest request) {
4345
auth.setIssueInstant(new DateTime(this.clock.millis()));
4446
auth.setForceAuthn(Boolean.FALSE);
4547
auth.setIsPassive(Boolean.FALSE);
46-
auth.setProtocolBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect");
48+
auth.setProtocolBinding(protocolBinding);
4749
Issuer issuer = this.saml.buildSAMLObject(Issuer.class);
4850
issuer.setValue(request.getIssuer());
4951
auth.setIssuer(issuer);
@@ -67,4 +69,13 @@ public void setClock(Clock clock) {
6769
Assert.notNull(clock, "clock cannot be null");
6870
this.clock = clock;
6971
}
72+
73+
/**
74+
* Sets the {@code protocolBinding} to use when generating authentication requests
75+
*
76+
* @param protocolBinding
77+
*/
78+
public void setProtocolBinding(String protocolBinding) {
79+
this.protocolBinding = protocolBinding;
80+
}
7081
}

0 commit comments

Comments
 (0)