本文整理汇总了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.");
}
}
示例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.");
}
}
示例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();
}
示例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;
}
示例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());
}
}
示例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());
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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());
}
}
示例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());
}
}
示例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));
}
示例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);
}
示例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());
}
示例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());
}