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


Java NameIdentifier类代码示例

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


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


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