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


Java AuthnContext类代码示例

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


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

示例1: buildAssertion

import org.opensaml.saml2.core.AuthnContext; //导入依赖的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;
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:24,代码来源:TestHelper.java

示例2: getAuthnContextClassRef

import org.opensaml.saml2.core.AuthnContext; //导入依赖的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;
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:25,代码来源:OIOAssertion.java

示例3: getAuthnContextClassRef

import org.opensaml.saml2.core.AuthnContext; //导入依赖的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());
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:21,代码来源:OIOAssertionTest.java

示例4: testChildElementsMarshall

import org.opensaml.saml2.core.AuthnContext; //导入依赖的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);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:22,代码来源:AuthnContextTest.java

示例5: getSAMLBuilder

import org.opensaml.saml2.core.AuthnContext; //导入依赖的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;
    }
 
开发者ID:mwdb,项目名称:OA2C,代码行数:24,代码来源:LocalSamlTokenFactory.java

示例6: createAuthnStatement

import org.opensaml.saml2.core.AuthnContext; //导入依赖的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;
}
 
开发者ID:rackerlabs,项目名称:saml-generator,代码行数:20,代码来源:SamlAssertionProducer.java

示例7: processChildElement

import org.opensaml.saml2.core.AuthnContext; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
    AuthnStatement authnStatement = (AuthnStatement) parentObject;
    if (childObject instanceof SubjectLocality) {
        authnStatement.setSubjectLocality((SubjectLocality) childObject);
    } else if (childObject instanceof AuthnContext) {
        authnStatement.setAuthnContext((AuthnContext) childObject);
    } else {
        super.processChildElement(parentObject, childObject);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:AuthnStatementUnmarshaller.java

示例8: processChildElement

import org.opensaml.saml2.core.AuthnContext; //导入依赖的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);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:AuthnContextUnmarshaller.java

示例9: SAMLConfigBean

import org.opensaml.saml2.core.AuthnContext; //导入依赖的package包/类
@GeneratePojoBuilder
SAMLConfigBean(final String idpServerName,
               final String spServerName,
               final Integer spHttpsPort,
               final String spContextPath,
               final Resource keystoreResource,
               final String keystoreAlias,
               final String keystorePassword,
               final String keystorePrivateKeyPassword,
               final String successLoginDefaultUrl,
               final String successLogoutUrl,
               final String failedLoginDefaultUrl,
               final Boolean storeCsrfTokenInCookie,
               final SAMLUserDetailsService samlUserDetailsService,
               final Set<String> authnContexts) {

    //@formatter:off
    this.idpServerName = expect(idpServerName, "IdP server name").not().toBeBlank().check();

    this.spServerName = expect(spServerName, "Sp server name").not().toBeBlank().check();
    this.spHttpsPort = Optional.fromNullable(spHttpsPort).or(443);
    this.spContextPath = Optional.fromNullable(spContextPath).or("");

    this.keystoreResource = (Resource) expect(keystoreResource, "Key store").not().toBeNull().check();
    this.keystoreAlias = expect(keystoreAlias, "Keystore alias").not().toBeBlank().check();
    this.keystorePassword = expect(keystorePassword, "Keystore password").not().toBeBlank().check();
    this.keystorePrivateKeyPassword = expect(keystorePrivateKeyPassword, "Keystore private key password").not().toBeBlank().check();

    this.successLoginDefaultUrl = expect(successLoginDefaultUrl, "Success login URL").not().toBeBlank().check();
    this.successLogoutUrl = expect(successLogoutUrl, "Success logout URL").not().toBeBlank().check();
    this.failedLoginDefaultUrl = Optional.fromNullable(failedLoginDefaultUrl).or("");

    this.storeCsrfTokenInCookie = MoreObjects.firstNonNull(storeCsrfTokenInCookie, false);
    this.samlUserDetailsService = samlUserDetailsService;

    this.authnContexts = Optional.fromNullable(authnContexts).or(ImmutableSet.of(AuthnContext.PASSWORD_AUTHN_CTX));
    //@formatter:on
}
 
开发者ID:choonchernlim,项目名称:spring-security-adfs-saml2,代码行数:39,代码来源:SAMLConfigBean.java

示例10: createAuthnContext

import org.opensaml.saml2.core.AuthnContext; //导入依赖的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;
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:16,代码来源:SAMLUtil.java

示例11: testCreateAuthnContext

import org.opensaml.saml2.core.AuthnContext; //导入依赖的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());
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:13,代码来源:SAMLUtilTest.java

示例12: populateRequiredData

import org.opensaml.saml2.core.AuthnContext; //导入依赖的package包/类
/** {@inheritDoc} */
protected void populateRequiredData() {
    super.populateRequiredData();
    AuthnStatement authnStatement = (AuthnStatement) target;
    AuthnContext authnContext = (AuthnContext) buildXMLObject(new QName(SAMLConstants.SAML20_NS,
            AuthnContext.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX));
    authnStatement.setAuthnInstant(new DateTime(1984, 8, 26, 10, 01, 30, 43, ISOChronology.getInstanceUTC()));
    authnStatement.setAuthnContext(authnContext);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:10,代码来源:AuthnStatementSchemaTest.java

示例13: testChildElementsMarshall

import org.opensaml.saml2.core.AuthnContext; //导入依赖的package包/类
/** {@inheritDoc} */
public void testChildElementsMarshall() {
    QName qname = new QName(SAMLConstants.SAML20_NS, AuthnStatement.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
    AuthnStatement authnStatement = (AuthnStatement) buildXMLObject(qname);

    QName subjectLocalityQName = new QName(SAMLConstants.SAML20_NS, SubjectLocality.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
    authnStatement.setSubjectLocality((SubjectLocality) buildXMLObject(subjectLocalityQName));
    
    QName authnContextQName = new QName(SAMLConstants.SAML20_NS, AuthnContext.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
    authnStatement.setAuthnContext((AuthnContext) buildXMLObject(authnContextQName));
    
    assertEquals(expectedChildElementsDOM, authnStatement);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:14,代码来源:AuthnStatementTest.java

示例14: testSingleElementMarshall

import org.opensaml.saml2.core.AuthnContext; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementMarshall() {
    QName qname = new QName(SAMLConstants.SAML20_NS, AuthnContext.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
    AuthnContext authnContext = (AuthnContext) buildXMLObject(qname);

    assertEquals(expectedDOM, authnContext);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:8,代码来源:AuthnContextTest.java

示例15: testChildElementsUnmarshall

import org.opensaml.saml2.core.AuthnContext; //导入依赖的package包/类
/** {@inheritDoc} */
public void testChildElementsUnmarshall() {
    AuthnContext authnContext = (AuthnContext) unmarshallElement(childElementsFile);

    assertNotNull("AuthnContextClassRef element not present", authnContext.getAuthnContextClassRef());
    assertNotNull("AuthnContextDecl element not present", authnContext.getAuthContextDecl());
    assertNotNull("AuthnContextDeclRef element not present", authnContext.getAuthnContextDeclRef());
    assertEquals("AuthenticatingAuthorityCount Count", expectedAuthenticatingAuthorityCount, authnContext
            .getAuthenticatingAuthorities().size());
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:11,代码来源:AuthnContextTest.java


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