当前位置: 首页>>代码示例>>Java>>正文


Java ExtensionsBuilder类代码示例

本文整理汇总了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;
    }
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:35,代码来源:DefaultSAML2SSOManager.java

示例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;
        }
    };
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:38,代码来源:WebSecurityConfig.java


注:本文中的org.opensaml.saml2.common.impl.ExtensionsBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。