本文整理汇总了Java中org.opensaml.saml2.core.AuthnContextClassRef类的典型用法代码示例。如果您正苦于以下问题:Java AuthnContextClassRef类的具体用法?Java AuthnContextClassRef怎么用?Java AuthnContextClassRef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuthnContextClassRef类属于org.opensaml.saml2.core包,在下文中一共展示了AuthnContextClassRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAuthnContextClassRef
import org.opensaml.saml2.core.AuthnContextClassRef; //导入依赖的package包/类
/**
* Return the value of the /AuthnStatement/AuthnContext/AuthnContextClassRef
* element in an assertion
*
* @return The value. <code>null</code>, if the assertion does not
* contain the element.
*/
public String getAuthnContextClassRef() {
String retVal = null;
if (assertion.getAuthnStatements() != null) {
if (assertion.getAuthnStatements().size() > 0) {
// We only look into the first AuthnStatement
AuthnStatement authnStatement = (AuthnStatement) assertion.getAuthnStatements().get(0);
AuthnContext authnContext = authnStatement.getAuthnContext();
if (authnContext != null) {
AuthnContextClassRef authnContextClassRef = authnContext.getAuthnContextClassRef();
if (authnContextClassRef != null) {
retVal = authnContextClassRef.getAuthnContextClassRef();
}
}
}
}
return retVal;
}
示例2: getAuthnContextClassRef
import org.opensaml.saml2.core.AuthnContextClassRef; //导入依赖的package包/类
@Test
public void getAuthnContextClassRef() {
String expectedAuthnContextClassRefString = "expected string";
AuthnContextClassRef authnContextClassRef = new AuthnContextClassRefStubImpl();
authnContextClassRef.setAuthnContextClassRef(expectedAuthnContextClassRefString);
AuthnContext authnContext = new AuthnContextStubImpl();
authnContext.setAuthnContextClassRef(authnContextClassRef);
AuthnStatement authnStatement= new AuthnStatementStubImpl();
authnStatement.setAuthnContext(authnContext);
List<AuthnStatement> authnStatements = new ArrayList<AuthnStatement>();
authnStatements.add(authnStatement);
Assertion assertion = new AssertionStubImpl(authnStatements);
assertEquals(expectedAuthnContextClassRefString, new OIOAssertion(assertion).getAuthnContextClassRef());
}
示例3: testChildElementsMarshall
import org.opensaml.saml2.core.AuthnContextClassRef; //导入依赖的package包/类
/** {@inheritDoc} */
public void testChildElementsMarshall() {
QName qname = new QName(SAMLConstants.SAML20_NS, AuthnContext.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
AuthnContext authnContext = (AuthnContext) buildXMLObject(qname);
QName authnContextClassRefQName = new QName(SAMLConstants.SAML20_NS, AuthnContextClassRef.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
authnContext.setAuthnContextClassRef((AuthnContextClassRef) buildXMLObject(authnContextClassRefQName));
QName authnContextDeclQName = new QName(SAMLConstants.SAML20_NS, AuthnContextDecl.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
authnContext.setAuthnContextDecl((AuthnContextDecl) buildXMLObject(authnContextDeclQName));
QName authnContextDeclRefQName = new QName(SAMLConstants.SAML20_NS, AuthnContextDeclRef.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
authnContext.setAuthnContextDeclRef((AuthnContextDeclRef) buildXMLObject(authnContextDeclRefQName));
QName authenticatingAuthorityQName = new QName(SAMLConstants.SAML20_NS, AuthenticatingAuthority.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
for (int i = 0; i < expectedAuthenticatingAuthorityCount; i++) {
authnContext.getAuthenticatingAuthorities().add((AuthenticatingAuthority) buildXMLObject(authenticatingAuthorityQName));
}
assertEquals(expectedChildElementsDOM, authnContext);
}
示例4: getSAMLBuilder
import org.opensaml.saml2.core.AuthnContextClassRef; //导入依赖的package包/类
private static XMLObjectBuilderFactory getSAMLBuilder() throws ConfigurationException {
if (builderFactory == null) {
// OpenSAML 2.3
DefaultBootstrap.bootstrap();
builderFactory = Configuration.getBuilderFactory();
nameIdBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(NameID.DEFAULT_ELEMENT_NAME);
confirmationMethodBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(SubjectConfirmationData.DEFAULT_ELEMENT_NAME);
subjectConfirmationBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(SubjectConfirmation.DEFAULT_ELEMENT_NAME);
subjectBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(Subject.DEFAULT_ELEMENT_NAME);
attrStatementBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AttributeStatement.DEFAULT_ELEMENT_NAME);
audienceRestrictionnBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AudienceRestriction.DEFAULT_ELEMENT_NAME);
audienceBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(Audience.DEFAULT_ELEMENT_NAME);
authStatementBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AuthnStatement.DEFAULT_ELEMENT_NAME);
authContextBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AuthnContext.DEFAULT_ELEMENT_NAME);
authContextClassRefBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AuthnContextClassRef.DEFAULT_ELEMENT_NAME);
issuerBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(Issuer.DEFAULT_ELEMENT_NAME);
assertionBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(Assertion.DEFAULT_ELEMENT_NAME);
}
return builderFactory;
}
示例5: createAuthnStatement
import org.opensaml.saml2.core.AuthnContextClassRef; //导入依赖的package包/类
private AuthnStatement createAuthnStatement(final DateTime issueDate) {
// create authcontextclassref object
AuthnContextClassRefBuilder classRefBuilder = new AuthnContextClassRefBuilder();
AuthnContextClassRef classRef = classRefBuilder.buildObject();
classRef.setAuthnContextClassRef("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport");
// create authcontext object
AuthnContextBuilder authContextBuilder = new AuthnContextBuilder();
AuthnContext authnContext = authContextBuilder.buildObject();
authnContext.setAuthnContextClassRef(classRef);
// create authenticationstatement object
AuthnStatementBuilder authStatementBuilder = new AuthnStatementBuilder();
AuthnStatement authnStatement = authStatementBuilder.buildObject();
authnStatement.setAuthnInstant(issueDate);
authnStatement.setAuthnContext(authnContext);
return authnStatement;
}
示例6: processChildElement
import org.opensaml.saml2.core.AuthnContextClassRef; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
AuthnContext authnContext = (AuthnContext) parentObject;
if (childObject instanceof AuthnContextClassRef) {
authnContext.setAuthnContextClassRef((AuthnContextClassRef) childObject);
} else if (childObject instanceof AuthnContextDecl) {
authnContext.setAuthnContextDecl((AuthnContextDecl) childObject);
} else if (childObject instanceof AuthnContextDeclRef) {
authnContext.setAuthnContextDeclRef((AuthnContextDeclRef) childObject);
} else if (childObject instanceof AuthenticatingAuthority) {
authnContext.getAuthenticatingAuthorities().add((AuthenticatingAuthority) childObject);
} else {
super.processChildElement(parentObject, childObject);
}
}
示例7: processChildElement
import org.opensaml.saml2.core.AuthnContextClassRef; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
throws UnmarshallingException {
RequestedAuthnContext rac = (RequestedAuthnContext) parentSAMLObject;
if (childSAMLObject instanceof AuthnContextClassRef) {
rac.getAuthnContextClassRefs().add((AuthnContextClassRef) childSAMLObject);
} else if (childSAMLObject instanceof AuthnContextDeclRef) {
rac.getAuthnContextDeclRefs().add((AuthnContextDeclRef) childSAMLObject);
} else {
super.processChildElement(parentSAMLObject, childSAMLObject);
}
}
示例8: buildRequestedAuthnContext
import org.opensaml.saml2.core.AuthnContextClassRef; //导入依赖的package包/类
private RequestedAuthnContext buildRequestedAuthnContext() {
// Create AuthnContextClassRef
AuthnContextClassRefBuilder authnContextClassRefBuilder = new AuthnContextClassRefBuilder();
AuthnContextClassRef authnContextClassRef = authnContextClassRefBuilder.buildObject(SAML2_ASSERTION, "AuthnContextClassRef", "saml");
authnContextClassRef.setAuthnContextClassRef(SAML2_PASSWORD_PROTECTED_TRANSPORT);
// Create RequestedAuthnContext
RequestedAuthnContextBuilder requestedAuthnContextBuilder = new RequestedAuthnContextBuilder();
RequestedAuthnContext requestedAuthnContext = requestedAuthnContextBuilder.buildObject();
requestedAuthnContext.setComparison(AuthnContextComparisonTypeEnumeration.EXACT);
requestedAuthnContext.getAuthnContextClassRefs().add(authnContextClassRef);
return requestedAuthnContext;
}
示例9: createAuthnContext
import org.opensaml.saml2.core.AuthnContextClassRef; //导入依赖的package包/类
/**
* Create an authnContext with a given authnContextClassRef.
*
* @param authnContextClassRefValue
* The value of the authnContextClassRef
* @return The SAML authnContext with the given authnContextClassRef
*/
public static AuthnContext createAuthnContext(
String authnContextClassRefValue) {
AuthnContext authnContext = buildXMLObject(AuthnContext.class);
AuthnContextClassRef authnContextClassRef = buildXMLObject(AuthnContextClassRef.class);
authnContextClassRef.setAuthnContextClassRef(authnContextClassRefValue);
authnContext.setAuthnContextClassRef(authnContextClassRef);
return authnContext;
}
示例10: testCreateAuthnContext
import org.opensaml.saml2.core.AuthnContextClassRef; //导入依赖的package包/类
@Test
public void testCreateAuthnContext() {
AuthnContext ac = SAMLUtil.createAuthnContext("ref");
assertNotNull(ac);
assertNull(ac.getAuthContextDecl());
assertTrue(ac.getAuthenticatingAuthorities().isEmpty());
assertNull(ac.getAuthnContextDeclRef());
AuthnContextClassRef cr = ac.getAuthnContextClassRef();
assertNotNull(cr);
assertEquals("ref", cr.getAuthnContextClassRef());
}
示例11: testURIFailure
import org.opensaml.saml2.core.AuthnContextClassRef; //导入依赖的package包/类
/**
* Tests absent Class Reference failure.
*
* @throws ValidationException
*/
public void testURIFailure() throws ValidationException {
AuthnContextClassRef authnContextClassRef = (AuthnContextClassRef) target;
authnContextClassRef.setAuthnContextClassRef(null);
assertValidationFail("ClassRef was null, should raise a Validation Exception");
authnContextClassRef.setAuthnContextClassRef("");
assertValidationFail("ClassRef was empty string, should raise a Validation Exception");
authnContextClassRef.setAuthnContextClassRef(" ");
assertValidationFail("ClassRef was white space, should raise a Validation Exception");
}
示例12: RequestedAuthnContextSchemaTest
import org.opensaml.saml2.core.AuthnContextClassRef; //导入依赖的package包/类
/**
* Constructor
*
*/
public RequestedAuthnContextSchemaTest() {
super();
targetQName = new QName(SAMLConstants.SAML20P_NS, RequestedAuthnContext.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20P_PREFIX);
validator = new RequestedAuthnContextSchemaValidator();
authnContextClassRef = (AuthnContextClassRef) buildXMLObject(new QName(SAMLConstants.SAML20_NS, AuthnContextClassRef.DEFAULT_ELEMENT_LOCAL_NAME));
authnContextDeclRef = (AuthnContextDeclRef) buildXMLObject(new QName(SAMLConstants.SAML20_NS, AuthnContextDeclRef.DEFAULT_ELEMENT_LOCAL_NAME));
}
示例13: testChildElementsMarshall
import org.opensaml.saml2.core.AuthnContextClassRef; //导入依赖的package包/类
/** {@inheritDoc} */
public void testChildElementsMarshall() {
QName qname = new QName(SAMLConstants.SAML20P_NS, RequestedAuthnContext.DEFAULT_ELEMENT_LOCAL_NAME);
RequestedAuthnContext rac = (RequestedAuthnContext) buildXMLObject(qname);
QName authnContextClassRefQName = new QName(SAMLConstants.SAML20_NS, AuthnContextClassRef.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
for (int i=0; i< expectedNumClassRefs; i++){
rac.getAuthnContextClassRefs().add((AuthnContextClassRef) buildXMLObject(authnContextClassRefQName));
}
assertEquals(expectedChildElementsDOM, rac);
}
示例14: testSingleElementUnmarshall
import org.opensaml.saml2.core.AuthnContextClassRef; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementUnmarshall() {
AuthnContextClassRef authnContextClassRef = (AuthnContextClassRef) unmarshallElement(singleElementFile);
String classRef = authnContextClassRef.getAuthnContextClassRef();
assertEquals("Class Reference was " + classRef + ", expected " + expectedClassRef, expectedClassRef, classRef);
}
示例15: testSingleElementMarshall
import org.opensaml.saml2.core.AuthnContextClassRef; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementMarshall() {
QName qname = new QName(SAMLConstants.SAML20_NS, AuthnContextClassRef.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
AuthnContextClassRef authnContextClassRef = (AuthnContextClassRef) buildXMLObject(qname);
authnContextClassRef.setAuthnContextClassRef(expectedClassRef);
assertEquals(expectedDOM, authnContextClassRef);
}