Search in sources :

Example 1 with RequestInitiator

use of org.opensaml.saml.ext.saml2mdreqinit.RequestInitiator in project pac4j by pac4j.

the class SAML2MetadataGenerator method buildSPSSODescriptor.

protected final SPSSODescriptor buildSPSSODescriptor() {
    final SAMLObjectBuilder<SPSSODescriptor> builder = (SAMLObjectBuilder<SPSSODescriptor>) this.builderFactory.getBuilder(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
    final SPSSODescriptor spDescriptor = builder.buildObject();
    spDescriptor.setAuthnRequestsSigned(this.authnRequestSigned);
    spDescriptor.setWantAssertionsSigned(this.wantAssertionSigned);
    spDescriptor.addSupportedProtocol(SAMLConstants.SAML20P_NS);
    spDescriptor.addSupportedProtocol(SAMLConstants.SAML10P_NS);
    spDescriptor.addSupportedProtocol(SAMLConstants.SAML11P_NS);
    final SAMLObjectBuilder<Extensions> builderExt = (SAMLObjectBuilder<Extensions>) this.builderFactory.getBuilder(Extensions.DEFAULT_ELEMENT_NAME);
    final Extensions extensions = builderExt.buildObject();
    extensions.getNamespaceManager().registerAttributeName(RequestInitiator.DEFAULT_ELEMENT_NAME);
    final SAMLObjectBuilder<RequestInitiator> builderReq = (SAMLObjectBuilder<RequestInitiator>) this.builderFactory.getBuilder(RequestInitiator.DEFAULT_ELEMENT_NAME);
    final RequestInitiator requestInitiator = builderReq.buildObject();
    requestInitiator.setLocation(this.requestInitiatorLocation);
    requestInitiator.setBinding(RequestInitiator.DEFAULT_ELEMENT_NAME.getNamespaceURI());
    extensions.getUnknownXMLObjects().add(requestInitiator);
    spDescriptor.setExtensions(extensions);
    spDescriptor.getNameIDFormats().addAll(buildNameIDFormat());
    int index = 0;
    // Fix the POST binding for the response instead of using the binding of the request
    spDescriptor.getAssertionConsumerServices().add(getAssertionConsumerService(SAMLConstants.SAML2_POST_BINDING_URI, index++, this.defaultACSIndex == index));
    if (credentialProvider != null) {
        spDescriptor.getKeyDescriptors().add(getKeyDescriptor(UsageType.SIGNING, this.credentialProvider.getKeyInfo()));
        spDescriptor.getKeyDescriptors().add(getKeyDescriptor(UsageType.ENCRYPTION, this.credentialProvider.getKeyInfo()));
    }
    return spDescriptor;
}
Also used : SPSSODescriptor(org.opensaml.saml.saml2.metadata.SPSSODescriptor) SAMLObjectBuilder(org.opensaml.saml.common.SAMLObjectBuilder) RequestInitiator(org.opensaml.saml.ext.saml2mdreqinit.RequestInitiator) Extensions(org.opensaml.saml.saml2.metadata.Extensions)

Aggregations

SAMLObjectBuilder (org.opensaml.saml.common.SAMLObjectBuilder)1 RequestInitiator (org.opensaml.saml.ext.saml2mdreqinit.RequestInitiator)1 Extensions (org.opensaml.saml.saml2.metadata.Extensions)1 SPSSODescriptor (org.opensaml.saml.saml2.metadata.SPSSODescriptor)1