本文整理汇总了Java中org.opensaml.saml2.core.AuthnStatement.setSessionIndex方法的典型用法代码示例。如果您正苦于以下问题:Java AuthnStatement.setSessionIndex方法的具体用法?Java AuthnStatement.setSessionIndex怎么用?Java AuthnStatement.setSessionIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensaml.saml2.core.AuthnStatement
的用法示例。
在下文中一共展示了AuthnStatement.setSessionIndex方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildAssertion
import org.opensaml.saml2.core.AuthnStatement; //导入方法依赖的package包/类
public static Assertion buildAssertion(String recipient, String audience) {
Assertion assertion = SAMLUtil.buildXMLObject(Assertion.class);
assertion.setID(Utils.generateUUID());
assertion.setSubject(SAMLUtil.createSubject("joetest", recipient, new DateTime().plusHours(1)));
assertion.setIssueInstant(new DateTime());
assertion.setIssuer(SAMLUtil.createIssuer("idp1.test.oio.dk"));
assertion.setConditions(SAMLUtil.createAudienceCondition(audience));
assertion.getConditions().setNotOnOrAfter(new DateTime().plus(10000));
AuthnContext context = SAMLUtil.createAuthnContext("urn:oasis:names:tc:SAML:2.0:ac:classes:Password");
AuthnStatement authnStatement = SAMLUtil.buildXMLObject(AuthnStatement.class);
authnStatement.setAuthnContext(context);
authnStatement.setAuthnInstant(new DateTime());
authnStatement.setSessionIndex(Utils.generateUUID());
assertion.getAuthnStatements().add(authnStatement);
AttributeStatement as = SAMLUtil.buildXMLObject(AttributeStatement.class);
as.getAttributes().add(AttributeUtil.createAssuranceLevel(2));
assertion.getAttributeStatements().add(as);
return assertion;
}
示例2: processAttribute
import org.opensaml.saml2.core.AuthnStatement; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
AuthnStatement authnStatement = (AuthnStatement) samlObject;
if (attribute.getLocalName().equals(AuthnStatement.AUTHN_INSTANT_ATTRIB_NAME)
&& !DatatypeHelper.isEmpty(attribute.getValue())) {
authnStatement.setAuthnInstant(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
} else if (attribute.getLocalName().equals(AuthnStatement.SESSION_INDEX_ATTRIB_NAME)) {
authnStatement.setSessionIndex(attribute.getValue());
} else if (attribute.getLocalName().equals(AuthnStatement.SESSION_NOT_ON_OR_AFTER_ATTRIB_NAME)
&& !DatatypeHelper.isEmpty(attribute.getValue())) {
authnStatement.setSessionNotOnOrAfter(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
} else {
super.processAttribute(samlObject, attribute);
}
}
示例3: testProfileCompliance
import org.opensaml.saml2.core.AuthnStatement; //导入方法依赖的package包/类
@Test
public void testProfileCompliance() {
assertFalse(new UserAssertionImpl(assertion).isOCESProfileCompliant());
assertFalse(new UserAssertionImpl(assertion).isOIOSAMLCompliant());
as.setSignature(SAMLUtil.createSignature("key"));
as.setIssuer(SAMLUtil.createIssuer("issuer"));
as.setSubject(SAMLUtil.createSubject("id", "url", new DateTime()));
AuthnStatement st = SAMLUtil.buildXMLObject(AuthnStatement.class);
st.setSessionIndex("idx");
as.getAuthnStatements().add(st);
attributeStatement.getAttributes().add(AttributeUtil.createCommonName("name"));
attributeStatement.getAttributes().add(AttributeUtil.createSurname("surname"));
attributeStatement.getAttributes().add(AttributeUtil.createUid("uid"));
attributeStatement.getAttributes().add(AttributeUtil.createMail("mail"));
attributeStatement.getAttributes().add(AttributeUtil.createAssuranceLevel(2));
attributeStatement.getAttributes().add(createAttribute(OIOSAMLConstants.ATTRIBUTE_SPECVER_NAME, "DK-SAML-2.0"));
assertTrue(new UserAssertionImpl(assertion).isOIOSAMLCompliant());
assertFalse(new UserAssertionImpl(assertion).isOCESProfileCompliant());
as.getSubject().getNameID().setFormat(NameIDFormat.X509SUBJECT.getFormat());
attributeStatement.getAttributes().add(AttributeUtil.createSerialNumber("number"));
attributeStatement.getAttributes().add(createAttribute(OIOSAMLConstants.ATTRIBUTE_YOUTH_CERTIFICATE_NAME, "true"));
attributeStatement.getAttributes().add(AttributeUtil.createPidNumberIdentifier("pid"));
attributeStatement.getAttributes().add(AttributeUtil.createUid("PID:pid"));
assertTrue(new UserAssertionImpl(assertion).isOIOSAMLCompliant());
assertTrue(new UserAssertionImpl(assertion).isOCESProfileCompliant());
attributeStatement.getAttributes().add(AttributeUtil.createRidNumberIdentifier("rid"));
assertTrue(new UserAssertionImpl(assertion).isOIOSAMLCompliant());
assertFalse(new UserAssertionImpl(assertion).isOCESProfileCompliant());
}
示例4: getSessionIndex
import org.opensaml.saml2.core.AuthnStatement; //导入方法依赖的package包/类
@Test
public void getSessionIndex() {
String expectedSessionIndex = "expected SessionIndex";
AuthnStatement authnStatement = new AuthnStatementStubImpl();
authnStatement.setSessionIndex(expectedSessionIndex);
List<AuthnStatement> authnStatements = new ArrayList<AuthnStatement>();
authnStatements.add(authnStatement);
Assertion assertion = new AssertionStubImpl(authnStatements);
assertEquals(expectedSessionIndex, new OIOAssertion(assertion).getSessionIndex());
}
示例5: testSingleElementOptionalAttributesMarshall
import org.opensaml.saml2.core.AuthnStatement; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementOptionalAttributesMarshall() {
QName qname = new QName(SAMLConstants.SAML20_NS, AuthnStatement.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
AuthnStatement authnStatement = (AuthnStatement) buildXMLObject(qname);
authnStatement.setAuthnInstant(expectedAuthnInstant);
authnStatement.setSessionIndex(expectedSessionIndex);
authnStatement.setSessionNotOnOrAfter(expectedSessionNotOnOrAfter);
assertEquals(expectedOptionalAttributesDOM, authnStatement);
}
示例6: buildMockResponse
import org.opensaml.saml2.core.AuthnStatement; //导入方法依赖的package包/类
private Response buildMockResponse() throws Exception {
Response samlMessage = new ResponseBuilder().buildObject();
samlMessage.setID("foo");
samlMessage.setVersion(SAMLVersion.VERSION_20);
samlMessage.setIssueInstant(new DateTime(0));
Issuer issuer = new IssuerBuilder().buildObject();
issuer.setValue("MockedIssuer");
samlMessage.setIssuer(issuer);
Status status = new StatusBuilder().buildObject();
StatusCode statusCode = new StatusCodeBuilder().buildObject();
statusCode.setValue(StatusCode.SUCCESS_URI);
status.setStatusCode(statusCode);
samlMessage.setStatus(status);
Assertion assertion = new AssertionBuilder().buildObject();
Subject subject = new SubjectBuilder().buildObject();
NameID nameID = new NameIDBuilder().buildObject();
nameID.setValue("SOME-UNIQUE-ID");
nameID.setFormat(NameIDType.PERSISTENT);
subject.setNameID(nameID);
assertion.setSubject(subject);
AuthnStatement authnStatement = new AuthnStatementBuilder().buildObject();
authnStatement.setSessionIndex("Some Session String");
assertion.getAuthnStatements().add(authnStatement);
AttributeStatement attributeStatement = new AttributeStatementBuilder().buildObject();
assertion.getAttributeStatements().add(attributeStatement);
samlMessage.getAssertions().add(assertion);
return samlMessage;
}
示例7: createAuthnStatement
import org.opensaml.saml2.core.AuthnStatement; //导入方法依赖的package包/类
private static AuthnStatement createAuthnStatement() {
AuthnStatement authnStatement = null;
AuthnContext authnContext = null;
SubjectLocality subjectLocality = null;
if (samlResponseData.getAuthnContextClassRef() != null
&& samlResponseData.getAuthnContextClassRef().length() > 0) {
authnContext = create(AuthnContext.DEFAULT_ELEMENT_NAME);
AuthnContextClassRef authnContextClassRef = create(AuthnContextClassRef.DEFAULT_ELEMENT_NAME);
if (samlResponseData.getAuthnContextClassRef().equals(
SamlResponseData.REPLACE_WITH_AUTHN_REQUEST)) {
authnContextClassRef.setAuthnContextClassRef(authnRequest
.getRequestedAuthnContext().getAuthnContextClassRefs()
.get(0).getAuthnContextClassRef());
} else {
authnContextClassRef.setAuthnContextClassRef(samlResponseData
.getAuthnContextClassRef());
}
authnContext.setAuthnContextClassRef(authnContextClassRef);
}
if (samlResponseData.getSubjectLocalityAddress() != null
&& samlResponseData.getSubjectLocalityAddress().length() > 0) {
subjectLocality = create(SubjectLocality.DEFAULT_ELEMENT_NAME);
subjectLocality.setAddress(samlResponseData
.getSubjectLocalityAddress());
}
if (samlResponseData.getSubjectLocalityDNSName() != null
&& samlResponseData.getSubjectLocalityDNSName().length() > 0) {
if (subjectLocality == null)
subjectLocality = create(SubjectLocality.DEFAULT_ELEMENT_NAME);
subjectLocality.setDNSName(samlResponseData
.getSubjectLocalityDNSName());
}
if (authnContext != null || subjectLocality != null
|| samlResponseData.getAuthnInstant() != null) {
authnStatement = create(AuthnStatement.DEFAULT_ELEMENT_NAME);
if (samlResponseData.getAuthnInstant() != null) {
authnStatement.setAuthnInstant(startTime
.plusMinutes(samlResponseData.getAuthnInstant()));
}
authnStatement.setSessionIndex(GENERATOR.generateIdentifier());
authnStatement.setAuthnContext(authnContext);
authnStatement.setSubjectLocality(subjectLocality);
}
return authnStatement;
}