use of org.opensaml.saml.saml2.core.Extensions in project cas by apereo.
the class MetadataUIUtils method locateMetadataUserInterfaceForEntityId.
/**
* Locate mdui for entity id simple metadata ui info.
*
* @param entityDescriptor the entity descriptor
* @param entityId the entity id
* @param registeredService the registered service
* @return the simple metadata ui info
*/
public static SamlMetadataUIInfo locateMetadataUserInterfaceForEntityId(final EntityDescriptor entityDescriptor, final String entityId, final RegisteredService registeredService) {
final SamlMetadataUIInfo mdui = new SamlMetadataUIInfo(registeredService);
if (entityDescriptor == null) {
LOGGER.debug("Entity descriptor not found for [{}]", entityId);
return mdui;
}
final SPSSODescriptor spssoDescriptor = getSPSsoDescriptor(entityDescriptor);
if (spssoDescriptor == null) {
LOGGER.debug("SP SSO descriptor not found for [{}]", entityId);
return mdui;
}
final Extensions extensions = spssoDescriptor.getExtensions();
if (extensions == null) {
LOGGER.debug("No extensions in the SP SSO descriptor are found for [{}]", UIInfo.DEFAULT_ELEMENT_NAME.getNamespaceURI());
return mdui;
}
final List<XMLObject> spExtensions = extensions.getUnknownXMLObjects(UIInfo.DEFAULT_ELEMENT_NAME);
if (spExtensions.isEmpty()) {
LOGGER.debug("No extensions in the SP SSO descriptor are located for [{}]", UIInfo.DEFAULT_ELEMENT_NAME.getNamespaceURI());
return mdui;
}
spExtensions.stream().filter(UIInfo.class::isInstance).forEach(obj -> {
final UIInfo uiInfo = (UIInfo) obj;
LOGGER.debug("Found MDUI info for [{}]", entityId);
mdui.setUIInfo(uiInfo);
});
return mdui;
}
use of org.opensaml.saml.saml2.core.Extensions in project pac4j by pac4j.
the class SAML2MetadataGenerator method generateMetadataExtensions.
protected final Extensions generateMetadataExtensions() {
final SAMLObjectBuilder<Extensions> builderExt = (SAMLObjectBuilder<Extensions>) this.builderFactory.getBuilder(Extensions.DEFAULT_ELEMENT_NAME);
final Extensions extensions = builderExt.buildObject();
extensions.getNamespaceManager().registerAttributeName(DigestMethod.TYPE_NAME);
final SAMLObjectBuilder<DigestMethod> builder = (SAMLObjectBuilder<DigestMethod>) this.builderFactory.getBuilder(DigestMethod.DEFAULT_ELEMENT_NAME);
DigestMethod method = builder.buildObject();
method.setAlgorithm("http://www.w3.org/2001/04/xmlenc#sha512");
extensions.getUnknownXMLObjects().add(method);
method = builder.buildObject();
method.setAlgorithm("http://www.w3.org/2001/04/xmldsig-more#sha384");
extensions.getUnknownXMLObjects().add(method);
method = builder.buildObject();
method.setAlgorithm("http://www.w3.org/2001/04/xmlenc#sha256");
extensions.getUnknownXMLObjects().add(method);
method = builder.buildObject();
method.setAlgorithm("http://www.w3.org/2001/04/xmldsig-more#sha224");
extensions.getUnknownXMLObjects().add(method);
method = builder.buildObject();
method.setAlgorithm("http://www.w3.org/2000/09/xmldsig#sha1");
extensions.getUnknownXMLObjects().add(method);
method = builder.buildObject();
method.setAlgorithm("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512");
extensions.getUnknownXMLObjects().add(method);
method = builder.buildObject();
method.setAlgorithm("http://www.w3.org/2001/04/xmldsig-more#rsa-sha384");
extensions.getUnknownXMLObjects().add(method);
method = builder.buildObject();
method.setAlgorithm("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
extensions.getUnknownXMLObjects().add(method);
method = builder.buildObject();
method.setAlgorithm("http://www.w3.org/2000/09/xmldsig#rsa-sha1");
extensions.getUnknownXMLObjects().add(method);
method = builder.buildObject();
method.setAlgorithm("http://www.w3.org/2000/09/xmldsig#dsa-sha1");
extensions.getUnknownXMLObjects().add(method);
return extensions;
}
use of org.opensaml.saml.saml2.core.Extensions 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;
}
use of org.opensaml.saml.saml2.core.Extensions in project spring-security by spring-projects.
the class OpenSamlMetadataAssertingPartyDetailsConverter method signingMethods.
private List<SigningMethod> signingMethods(IDPSSODescriptor idpssoDescriptor) {
Extensions extensions = idpssoDescriptor.getExtensions();
List<SigningMethod> result = signingMethods(extensions);
if (!result.isEmpty()) {
return result;
}
EntityDescriptor descriptor = (EntityDescriptor) idpssoDescriptor.getParent();
extensions = descriptor.getExtensions();
return signingMethods(extensions);
}
use of org.opensaml.saml.saml2.core.Extensions in project cas by apereo.
the class SamlIdPSingleLogoutRedirectionStrategy method supports.
@Override
public boolean supports(final RequestContext context) {
val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(context);
val registeredService = WebUtils.getRegisteredService(request);
if (registeredService instanceof SamlRegisteredService) {
val logout = configurationContext.getCasProperties().getAuthn().getSamlIdp().getLogout();
val samlRegisteredService = (SamlRegisteredService) registeredService;
val sloRequest = WebUtils.getSingleLogoutRequest(request);
val async = new AtomicBoolean(false);
if (StringUtils.isNotBlank(sloRequest)) {
async.set(getLogoutRequest(request).map(RequestAbstractType::getExtensions).stream().filter(Objects::nonNull).anyMatch(extensions -> !extensions.getUnknownXMLObjects(Asynchronous.DEFAULT_ELEMENT_NAME).isEmpty()));
}
return logout.isSendLogoutResponse() && samlRegisteredService != null && samlRegisteredService.isLogoutResponseEnabled() && sloRequest != null && !async.get();
}
return false;
}
Aggregations