本文整理匯總了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;
}
};
}