请选择 进入手机版 | 继续访问电脑版
  • 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NameIdentifier类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.opensaml.saml1.core.NameIdentifier的典型用法代码示例。如果您正苦于以下问题:Java NameIdentifier类的具体用法?Java NameIdentifier怎么用?Java NameIdentifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NameIdentifier类属于org.opensaml.saml1.core包,在下文中一共展示了NameIdentifier类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildArtifact

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/** {@inheritDoc} */
public SAML1ArtifactType0001 buildArtifact(
        SAMLMessageContext<RequestAbstractType, Response, NameIdentifier> requestContext, Assertion assertion) {
    try {
        MessageDigest sha1Digester = MessageDigest.getInstance("SHA-1");
        byte[] source = sha1Digester.digest(requestContext.getLocalEntityId().getBytes());

        SecureRandom handleGenerator = SecureRandom.getInstance("SHA1PRNG");
        byte[] assertionHandle = new byte[20];
        handleGenerator.nextBytes(assertionHandle);

        return new SAML1ArtifactType0001(source, assertionHandle);
    } catch (NoSuchAlgorithmException e) {
        log.error("JVM does not support required cryptography algorithms.", e);
        throw new InternalError("JVM does not support required cryptography algorithms: SHA-1 and/or SHA1PRNG.");
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:SAML1ArtifactType0001Builder.java


示例2: buildArtifact

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/** {@inheritDoc} */
public SAML1ArtifactType0002 buildArtifact(
        SAMLMessageContext<RequestAbstractType, Response, NameIdentifier> requestContext, Assertion assertion) {
    try {
        String sourceLocation = getSourceLocation(requestContext);
        if (sourceLocation == null) {
            return null;
        }

        SecureRandom handleGenerator = SecureRandom.getInstance("SHA1PRNG");
        byte[] assertionHandle = new byte[20];
        handleGenerator.nextBytes(assertionHandle);
        return new SAML1ArtifactType0002(assertionHandle, sourceLocation);
    } catch (NoSuchAlgorithmException e) {
        log.error("JVM does not support required cryptography algorithms: SHA1PRNG.", e);
        throw new InternalError("JVM does not support required cryptography algorithms: SHA1PRNG.");
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:SAML1ArtifactType0002Builder.java


示例3: getSourceLocation

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/**
 * Gets the source location used to for the artifacts created by this encoder.
 * 
 * @param requestContext current request context
 * 
 * @return source location used to for the artifacts created by this encoder
 */
protected String getSourceLocation(SAMLMessageContext<RequestAbstractType, Response, NameIdentifier> requestContext) {
    BasicEndpointSelector selector = new BasicEndpointSelector();
    selector.setEndpointType(ArtifactResolutionService.DEFAULT_ELEMENT_NAME);
    selector.getSupportedIssuerBindings().add(SAMLConstants.SAML1_SOAP11_BINDING_URI);
    selector.setMetadataProvider(requestContext.getMetadataProvider());
    selector.setEntityMetadata(requestContext.getLocalEntityMetadata());
    selector.setEntityRoleMetadata(requestContext.getLocalEntityRoleMetadata());

    Endpoint acsEndpoint = selector.selectEndpoint();

    if (acsEndpoint == null) {
        log.error("Unable to select source location for artifact.  No artifact resolution service defined for issuer.");
        return null;
    }

    return acsEndpoint.getLocation();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:SAML1ArtifactType0002Builder.java


示例4: newSubject

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
private Subject newSubject(final String identifier) {
    final SubjectConfirmation confirmation = newSamlObject(SubjectConfirmation.class);
    final ConfirmationMethod method = newSamlObject(ConfirmationMethod.class);
    method.setConfirmationMethod(CONFIRMATION_METHOD);
    confirmation.getConfirmationMethods().add(method);
    final NameIdentifier nameIdentifier = newSamlObject(NameIdentifier.class);
    nameIdentifier.setNameIdentifier(identifier);
    final Subject subject = newSamlObject(Subject.class);
    subject.setNameIdentifier(nameIdentifier);
    subject.setSubjectConfirmation(confirmation);
    return subject;
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:13,代码来源:Saml10SuccessResponseView.java


示例5: marshallAttributes

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException {
    NameIdentifier nameIdentifier = (NameIdentifier) samlElement;

    if (nameIdentifier.getNameQualifier() != null) {
        domElement
                .setAttributeNS(null, NameIdentifier.NAMEQUALIFIER_ATTRIB_NAME, nameIdentifier.getNameQualifier());
    }

    if (nameIdentifier.getFormat() != null) {
        domElement.setAttributeNS(null, NameIdentifier.FORMAT_ATTRIB_NAME, nameIdentifier.getFormat());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:NameIdentifierMarshaller.java


示例6: marshallElementContent

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallElementContent(XMLObject samlObject, Element domElement) throws MarshallingException {
    NameIdentifier nameIdentifier = (NameIdentifier) samlObject;

    if (nameIdentifier.getNameIdentifier() != null) {
        XMLHelper.appendTextContent(domElement, nameIdentifier.getNameIdentifier());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:NameIdentifierMarshaller.java


示例7: processChildElement

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
        throws UnmarshallingException {

    Subject subject = (Subject) parentSAMLObject;

    if (childSAMLObject instanceof NameIdentifier) {
        subject.setNameIdentifier((NameIdentifier) childSAMLObject);
    } else if (childSAMLObject instanceof SubjectConfirmation) {
        subject.setSubjectConfirmation((SubjectConfirmation) childSAMLObject);
    } else {
        super.processChildElement(parentSAMLObject, childSAMLObject);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:SubjectUnmarshaller.java


示例8: processAttribute

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
    NameIdentifier nameIdentifier = (NameIdentifier) samlObject;

    if (NameIdentifier.FORMAT_ATTRIB_NAME.equals(attribute.getLocalName())) {
        nameIdentifier.setFormat(attribute.getValue());
    } else if (NameIdentifier.NAMEQUALIFIER_ATTRIB_NAME.equals(attribute.getLocalName())) {
        nameIdentifier.setNameQualifier(attribute.getValue());
    } else {
        super.processAttribute(samlObject, attribute);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:NameIdentifierUnmarshaller.java


示例9: buildAuthenticationRequest

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/**
 * Generate an authentication request with passive support.
 *
 * @return AuthnRequest Object
 * @throws Exception
 */
public AuthnRequest buildAuthenticationRequest(String subjectName, String nameIdPolicyFormat, boolean isPassive)
        throws Exception {

    if (log.isDebugEnabled()) {
        log.debug("Building Authentication Request");
    }
    Util.doBootstrap();
    AuthnRequest authnRequest = (AuthnRequest) Util
            .buildXMLObject(AuthnRequest.DEFAULT_ELEMENT_NAME);
    authnRequest.setID(Util.createID());
    authnRequest.setVersion(SAMLVersion.VERSION_20);
    authnRequest.setIssueInstant(new DateTime());
    authnRequest.setIssuer(buildIssuer());
    authnRequest.setNameIDPolicy(buildNameIDPolicy(nameIdPolicyFormat));
    authnRequest.setIsPassive(isPassive);
    authnRequest.setDestination(Util.getIdentityProviderSSOServiceURL());
    String acs = Util.getAssertionConsumerServiceURL();
    if (acs != null && acs.trim().length() > 0) {
        authnRequest.setAssertionConsumerServiceURL(acs);
    } else {
        authnRequest.setAssertionConsumerServiceURL(CarbonUIUtil.getAdminConsoleURL("").replace("carbon/", "acs"));
    }

    if (subjectName != null) {
        Subject subject = new SubjectBuilder().buildObject();
        NameID nameId = new NameIDBuilder().buildObject();
        nameId.setValue(subjectName);
        nameId.setFormat(NameIdentifier.EMAIL);
        subject.setNameID(nameId);
        authnRequest.setSubject(subject);

    }

    Util.setSignature(authnRequest, XMLSignature.ALGO_ID_SIGNATURE_RSA, new SignKeyDataHolder());

    return authnRequest;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:44,代码来源:AuthenticationRequestBuilder.java


示例10: marshallAttributes

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException {
    NameIdentifier nameIdentifier = (NameIdentifier) samlElement;

    if (nameIdentifier.getNameQualifier() != null) {
        domElement.setAttributeNS(null, NameIdentifier.NAMEQUALIFIER_ATTRIB_NAME, nameIdentifier.getNameQualifier());
    }

    if (nameIdentifier.getFormat() != null) {
        domElement.setAttributeNS(null, NameIdentifier.FORMAT_ATTRIB_NAME, nameIdentifier.getFormat());
    }
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:13,代码来源:NameIdentifierMarshaller.java


示例11: marshallElementContent

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallElementContent(XMLObject samlObject, Element domElement) throws MarshallingException {
    NameIdentifier nameIdentifier = (NameIdentifier) samlObject;

    if (nameIdentifier.getNameIdentifier() != null) {
        XMLHelper.appendTextContent(domElement,nameIdentifier.getNameIdentifier());
    }
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:9,代码来源:NameIdentifierMarshaller.java


示例12: populateRequiredData

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/** {@inheritDoc} */
protected void populateRequiredData() {
    super.populateRequiredData();

    Subject subject = (Subject) target;
    
    QName qname = new QName(SAMLConstants.SAML1_NS, NameIdentifier.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1_PREFIX);
    subject.setNameIdentifier((NameIdentifier)buildXMLObject(qname));
    qname = new QName(SAMLConstants.SAML1_NS, SubjectConfirmation.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1_PREFIX);
    subject.setSubjectConfirmation((SubjectConfirmation)buildXMLObject(qname));
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:12,代码来源:SubjectSchemaTest.java


示例13: NameIdentifierTest

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/**
 * Constructor
 */
public NameIdentifierTest() {
    super();
    singleElementFile = "/data/org/opensaml/saml1/impl/singleNameIdentifier.xml";
    singleElementOptionalAttributesFile  = "/data/org/opensaml/saml1/impl/singleNameIdentifierAttributes.xml";
    expectedFormat = "format";
    expectedNameIdentifier = "IdentifierText";
    expectedNameQualifier = "Qualifier";
    qname = new QName(SAMLConstants.SAML1_NS, NameIdentifier.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1_PREFIX);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:13,代码来源:NameIdentifierTest.java


示例14: testSingleElementUnmarshall

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/** {@inheritDoc} */

    public void testSingleElementUnmarshall() {
        NameIdentifier nameIdentifier = (NameIdentifier) unmarshallElement(singleElementFile);
        
        assertNull("Name Identifer contents present", nameIdentifier.getNameIdentifier());
        assertNull("NameQualifier present", nameIdentifier.getNameQualifier());
        assertNull("Format present", nameIdentifier.getFormat());
    }
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:10,代码来源:NameIdentifierTest.java


示例15: testSingleElementOptionalAttributesUnmarshall

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/** {@inheritDoc} */

    public void testSingleElementOptionalAttributesUnmarshall() {
        NameIdentifier nameIdentifier = (NameIdentifier) unmarshallElement(singleElementOptionalAttributesFile);
        
        assertEquals("Name Identifier contents", expectedNameIdentifier, nameIdentifier.getNameIdentifier());
        assertEquals("NameQualfier attribute", expectedNameQualifier, nameIdentifier.getNameQualifier());
        assertEquals("Format attribute", expectedFormat, nameIdentifier.getFormat());
    }
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:10,代码来源:NameIdentifierTest.java


示例16: testSingleElementOptionalAttributesMarshall

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/** {@inheritDoc} */

    public void testSingleElementOptionalAttributesMarshall() {
        NameIdentifier nameIdentifier = (NameIdentifier) buildXMLObject(qname);
        
        nameIdentifier.setFormat(expectedFormat);
        nameIdentifier.setNameIdentifier(expectedNameIdentifier);
        nameIdentifier.setNameQualifier(expectedNameQualifier);
        
        assertEquals(expectedOptionalAttributesDOM, nameIdentifier);
    }
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:12,代码来源:NameIdentifierTest.java


示例17: testChildElementsMarshall

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/** {@inheritDoc} */

    public void testChildElementsMarshall() {
        Subject subject = (Subject) buildXMLObject(qname);

        QName oqname = new QName(SAMLConstants.SAML1_NS, NameIdentifier.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1_PREFIX);
        subject.setNameIdentifier((NameIdentifier) buildXMLObject(oqname));
        oqname = new QName(SAMLConstants.SAML1_NS, SubjectConfirmation.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1_PREFIX);
        subject.setSubjectConfirmation((SubjectConfirmation) buildXMLObject(oqname));

        assertEquals(expectedChildElementsDOM, subject);
    }
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:13,代码来源:SubjectTest.java


示例18: doEncode

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/** {@inheritDoc} */
protected void doEncode(MessageContext messageContext) throws MessageEncodingException {
    if (!(messageContext instanceof SAMLMessageContext)) {
        log.error("Invalid message context type, this encoder only support SAMLMessageContext");
        throw new MessageEncodingException(
                "Invalid message context type, this encoder only support SAMLMessageContext");
    }

    if (!(messageContext.getOutboundMessageTransport() instanceof HTTPOutTransport)) {
        log.error("Invalid outbound message transport type, this encoder only support HTTPOutTransport");
        throw new MessageEncodingException(
                "Invalid outbound message transport type, this encoder only support HTTPOutTransport");
    }

    SAMLMessageContext<SAMLObject, Response, NameIdentifier> artifactContext = (SAMLMessageContext) messageContext;
    HTTPOutTransport outTransport = (HTTPOutTransport) artifactContext.getOutboundMessageTransport();

    URLBuilder urlBuilder = getEndpointURL(artifactContext);

    List<Pair<String, String>> params = urlBuilder.getQueryParams();

    params.add(new Pair<String, String>("TARGET", artifactContext.getRelayState()));

    SAML1ArtifactBuilder artifactBuilder;
    if (artifactContext.getOutboundMessageArtifactType() != null) {
        artifactBuilder = Configuration.getSAML1ArtifactBuilderFactory().getArtifactBuilder(
                artifactContext.getOutboundMessageArtifactType());
    } else {
        artifactBuilder = Configuration.getSAML1ArtifactBuilderFactory().getArtifactBuilder(defaultArtifactType);
        artifactContext.setOutboundMessageArtifactType(defaultArtifactType);
    }

    AbstractSAML1Artifact artifact;
    String artifactString;
    for (Assertion assertion : artifactContext.getOutboundSAMLMessage().getAssertions()) {
        artifact = artifactBuilder.buildArtifact(artifactContext, assertion);
        if(artifact == null){
            log.error("Unable to build artifact for message to relying party");
            throw new MessageEncodingException("Unable to builder artifact for message to relying party");
        }

        try {
            artifactMap.put(artifact.base64Encode(), messageContext.getInboundMessageIssuer(), messageContext
                    .getOutboundMessageIssuer(), assertion);
        } catch (MarshallingException e) {
            log.error("Unable to marshall assertion to be represented as an artifact", e);
            throw new MessageEncodingException("Unable to marshall assertion to be represented as an artifact", e);
        }
        artifactString = artifact.base64Encode();
        params.add(new Pair<String, String>("SAMLart", artifactString));
    }

    String redirectUrl = urlBuilder.buildURL();

    log.debug("Sending redirect to URL {} to relying party {}", redirectUrl, artifactContext
            .getInboundMessageIssuer());
    outTransport.sendRedirect(urlBuilder.buildURL());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:59,代码来源:HTTPArtifactEncoder.java


示例19: getNameIdentifier

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/** {@inheritDoc} */
public NameIdentifier getNameIdentifier() {
    return nameIdentifier;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:SubjectImpl.java


示例20: setNameIdentifier

import org.opensaml.saml1.core.NameIdentifier; //导入依赖的package包/类
/** {@inheritDoc} */
public void setNameIdentifier(NameIdentifier nameIdentifier) throws IllegalArgumentException {
    this.nameIdentifier = prepareForAssignment(this.nameIdentifier, nameIdentifier);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:SubjectImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PreferencesFacade类代码示例发布时间:2022-05-23
下一篇:
Java MavenPublication类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap