本文整理汇总了Java中org.opensaml.saml2.common.impl.ExtensionsBuilder类的典型用法代码示例。如果您正苦于以下问题:Java ExtensionsBuilder类的具体用法?Java ExtensionsBuilder怎么用?Java ExtensionsBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExtensionsBuilder类属于org.opensaml.saml2.common.impl包,在下文中一共展示了ExtensionsBuilder类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSAMLExtensions
import org.opensaml.saml2.common.impl.ExtensionsBuilder; //导入依赖的package包/类
protected Extensions getSAMLExtensions(HttpServletRequest request) {
try {
String samlRequest = request.getParameter(SSOConstants.HTTP_POST_PARAM_SAML2_AUTH_REQ);
if (samlRequest == null) {
samlRequest = (String) request.getAttribute(SSOConstants.HTTP_POST_PARAM_SAML2_AUTH_REQ);
}
if (samlRequest != null) {
XMLObject xmlObject;
if (SSOConstants.HTTP_POST.equals(request.getMethod())) {
xmlObject = unmarshall(SSOUtils.decodeForPost(samlRequest));
} else {
xmlObject = unmarshall(SSOUtils.decode(samlRequest));
}
if (xmlObject instanceof AuthnRequest) {
AuthnRequest authnRequest = (AuthnRequest) xmlObject;
Extensions oldExtensions = authnRequest.getExtensions();
if (oldExtensions != null) {
ExtensionsBuilder extBuilder = new ExtensionsBuilder();
Extensions extensions = extBuilder.buildObject(SAMLConstants.SAML20P_NS,
Extensions.LOCAL_NAME, SAMLConstants.SAML20P_PREFIX);
extensions.setDOM(oldExtensions.getDOM());
return extensions;
}
}
}
} catch (Exception e) { // TODO IDENTITY-2421
//ignore
log.debug("Error while loading SAML Extensions", e);
}
return null;
}
示例2: webSSOprofile
import org.opensaml.saml2.common.impl.ExtensionsBuilder; //导入依赖的package包/类
@Bean
public WebSSOProfile webSSOprofile() {
return new WebSSOProfileImpl() {
@Override
protected AuthnRequest getAuthnRequest(SAMLMessageContext context, WebSSOProfileOptions options, AssertionConsumerService assertionConsumer, SingleSignOnService bindingService) throws SAMLException, MetadataProviderException {
AuthnRequest authnRequest = super.getAuthnRequest(context, options, assertionConsumer, bindingService);
authnRequest.setExtensions(buildExtensions());
return authnRequest;
}
/**
* Language extension to AuthnRequest:
*
* <samlp:Extensions>
<vetuma xmlns="urn:vetuma:SAML:2.0:extensions">
<LG>[fi|sv]</LG>
</vetuma>
</samlp:Extensions>
*/
private Extensions buildExtensions() {
Extensions extensions = new ExtensionsBuilder()
.buildObject("urn:oasis:names:tc:SAML:2.0:protocol", "Extensions", "saml2p");
XSAny vetuma = new XSAnyBuilder().buildObject(new QName("urn:vetuma:SAML:2.0:extensions", "vetuma"));
XSAny language = new XSAnyBuilder().buildObject(new QName("urn:vetuma:SAML:2.0:extensions", "LG"));
String idpLanguageFromTarget = TargetStoringFilter.getRequestParamTarget(((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest())
.map(t -> t.startsWith(Urls.FRONT_SV) ? "sv" : "fi")
.orElse("fi");
language.setTextContent(idpLanguageFromTarget);
extensions.getUnknownXMLObjects().add(vetuma);
vetuma.getUnknownXMLObjects().add(language);
return extensions;
}
};
}