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


Java SamlAuthenticationMetaDataPopulator类代码示例

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


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

示例1: prepareResponse

import org.jasig.cas.support.saml.authentication.SamlAuthenticationMetaDataPopulator; //导入依赖的package包/类
@Override
protected void prepareResponse(final Response response, final Map<String, Object> model) {

    final DateTime issuedAt = response.getIssueInstant();
    final Service service = getAssertionFrom(model).getService();

    final Authentication authentication = getPrimaryAuthenticationFrom(model);
    final String authenticationMethod = (String) authentication.getAttributes().get(
            SamlAuthenticationMetaDataPopulator.ATTRIBUTE_AUTHENTICATION_METHOD);

    final AuthenticationStatement authnStatement = this.samlObjectBuilder.newAuthenticationStatement(
            authentication.getAuthenticationDate().toDate(), authenticationMethod, getPrincipal(model).getId());

    final Assertion assertion = this.samlObjectBuilder.newAssertion(authnStatement, this.issuer, issuedAt,
            this.samlObjectBuilder.generateSecureRandomId());
    final Conditions conditions = this.samlObjectBuilder.newConditions(issuedAt, service.getId(), this.issueLength);
    assertion.setConditions(conditions);

    final Subject subject = this.samlObjectBuilder.newSubject(getPrincipal(model).getId());
    final Map<String, Object> attributesToSend = prepareSamlAttributes(model, service);

    if (!attributesToSend.isEmpty()) {
        assertion.getAttributeStatements().add(this.samlObjectBuilder.newAttributeStatement(
                subject, attributesToSend, VALIDATION_SAML_ATTRIBUTE_NAMESPACE));
    }

    response.setStatus(this.samlObjectBuilder.newStatus(StatusCode.SUCCESS, null));
    response.getAssertions().add(assertion);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:30,代码来源:Saml10SuccessResponseView.java

示例2: newAuthenticationStatement

import org.jasig.cas.support.saml.authentication.SamlAuthenticationMetaDataPopulator; //导入依赖的package包/类
/**
 * New authentication statement.
 *
 * @param authenticationDate the authentication date
 * @param authenticationMethod the authentication method
 * @param subjectId the subject id
 * @return the authentication statement
 */
public AuthenticationStatement newAuthenticationStatement(final Date authenticationDate,
                                                          final String authenticationMethod,
                                                          final String subjectId) {

    final AuthenticationStatement authnStatement = newSamlObject(AuthenticationStatement.class);
    authnStatement.setAuthenticationInstant(new DateTime(authenticationDate));
    authnStatement.setAuthenticationMethod(
            authenticationMethod != null
                    ? authenticationMethod
                    : SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_UNSPECIFIED);
    authnStatement.setSubject(newSubject(subjectId));
    return authnStatement;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:Saml10ObjectBuilder.java

示例3: verifyResponse

import org.jasig.cas.support.saml.authentication.SamlAuthenticationMetaDataPopulator; //导入依赖的package包/类
@Test
public void verifyResponse() throws Exception {
    final Map<String, Object> model = new HashMap<>();

    final Map<String, Object> attributes = new HashMap<>();
    attributes.put("testAttribute", "testValue");
    attributes.put("testEmptyCollection", Collections.emptyList());
    attributes.put("testAttributeCollection", Arrays.asList("tac1", "tac2"));
    final Principal principal = new DefaultPrincipalFactory().createPrincipal("testPrincipal", attributes);

    final Map<String, Object> authAttributes = new HashMap<>();
    authAttributes.put(
            SamlAuthenticationMetaDataPopulator.ATTRIBUTE_AUTHENTICATION_METHOD,
            SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_SSL_TLS_CLIENT);
    authAttributes.put("testSamlAttribute", "value");

    final Authentication primary =
            org.jasig.cas.authentication.TestUtils.getAuthentication(principal, authAttributes);
    final Assertion assertion = new ImmutableAssertion(
            primary, Collections.singletonList(primary),
            org.jasig.cas.authentication.TestUtils.getService(), true);
    model.put("assertion", assertion);

    final MockHttpServletResponse servletResponse = new MockHttpServletResponse();

    this.response.renderMergedOutputModel(model, new MockHttpServletRequest(), servletResponse);
    final String written = servletResponse.getContentAsString();

    assertTrue(written.contains("testPrincipal"));
    assertTrue(written.contains("testAttribute"));
    assertTrue(written.contains("testValue"));
    assertFalse(written.contains("testEmptyCollection"));
    assertTrue(written.contains("testAttributeCollection"));
    assertTrue(written.contains("tac1"));
    assertTrue(written.contains("tac2"));
    assertTrue(written.contains(SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_SSL_TLS_CLIENT));
    assertTrue(written.contains("AuthenticationMethod"));
    assertTrue(written.contains("AssertionID"));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:40,代码来源:Saml10SuccessResponseViewTests.java

示例4: verifyResponseWithNoAttributes

import org.jasig.cas.support.saml.authentication.SamlAuthenticationMetaDataPopulator; //导入依赖的package包/类
@Test
public void verifyResponseWithNoAttributes() throws Exception {
    final Map<String, Object> model = new HashMap<>();

    final Principal principal = new DefaultPrincipalFactory().createPrincipal("testPrincipal");

    final Map<String, Object> authAttributes = new HashMap<>();
    authAttributes.put(
            SamlAuthenticationMetaDataPopulator.ATTRIBUTE_AUTHENTICATION_METHOD,
            SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_SSL_TLS_CLIENT);
    authAttributes.put("testSamlAttribute", "value");

    final Authentication primary = org.jasig.cas.authentication.TestUtils.getAuthentication(principal, authAttributes);

    final Assertion assertion = new ImmutableAssertion(
            primary, Collections.singletonList(primary),
            org.jasig.cas.authentication.TestUtils.getService(), true);
    model.put("assertion", assertion);

    final MockHttpServletResponse servletResponse = new MockHttpServletResponse();

    this.response.renderMergedOutputModel(model, new MockHttpServletRequest(), servletResponse);
    final String written = servletResponse.getContentAsString();

    assertTrue(written.contains("testPrincipal"));
    assertTrue(written.contains(SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_SSL_TLS_CLIENT));
    assertTrue(written.contains("AuthenticationMethod="));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:29,代码来源:Saml10SuccessResponseViewTests.java

示例5: prepareResponse

import org.jasig.cas.support.saml.authentication.SamlAuthenticationMetaDataPopulator; //导入依赖的package包/类
@Override
protected void prepareResponse(final Response response, final Map<String, Object> model) {

    final DateTime issuedAt = response.getIssueInstant();
    final Service service = getAssertionFrom(model).getService();

    final Authentication authentication = getPrimaryAuthenticationFrom(model);
    final String authenticationMethod = (String) authentication.getAttributes().get(
            SamlAuthenticationMetaDataPopulator.ATTRIBUTE_AUTHENTICATION_METHOD);

    final AuthenticationStatement authnStatement = this.samlObjectBuilder.newAuthenticationStatement(
            authentication.getAuthenticationDate(), authenticationMethod, getPrincipal(model).getId());

    final Assertion assertion = this.samlObjectBuilder.newAssertion(authnStatement, this.issuer, issuedAt,
            this.samlObjectBuilder.generateSecureRandomId());
    final Conditions conditions = this.samlObjectBuilder.newConditions(issuedAt, service.getId(), this.issueLength);
    assertion.setConditions(conditions);

    final Subject subject = this.samlObjectBuilder.newSubject(getPrincipal(model).getId());
    final Map<String, Object> attributesToSend = prepareSamlAttributes(model);

    if (!attributesToSend.isEmpty()) {
        assertion.getAttributeStatements().add(this.samlObjectBuilder.newAttributeStatement(
                subject, attributesToSend, VALIDATION_SAML_ATTRIBUTE_NAMESPACE));
    }

    response.setStatus(this.samlObjectBuilder.newStatus(StatusCode.SUCCESS, null));
    response.getAssertions().add(assertion);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:30,代码来源:Saml10SuccessResponseView.java

示例6: verifyResponse

import org.jasig.cas.support.saml.authentication.SamlAuthenticationMetaDataPopulator; //导入依赖的package包/类
@Test
public void verifyResponse() throws Exception {
    final Map<String, Object> model = new HashMap<>();

    final Map<String, Object> attributes = new HashMap<>();
    attributes.put("testAttribute", "testValue");
    attributes.put("testEmptyCollection", Collections.emptyList());
    attributes.put("testAttributeCollection", Arrays.asList("tac1", "tac2"));
    final Principal principal = new DefaultPrincipalFactory().createPrincipal("testPrincipal", attributes);

    final Map<String, Object> authAttributes = new HashMap<>();
    authAttributes.put(
            SamlAuthenticationMetaDataPopulator.ATTRIBUTE_AUTHENTICATION_METHOD,
            SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_SSL_TLS_CLIENT);
    authAttributes.put("testSamlAttribute", "value");

    final Authentication primary = TestUtils.getAuthentication(principal, authAttributes);
    final Assertion assertion = new ImmutableAssertion(
            primary, Collections.singletonList(primary), TestUtils.getService(), true);
    model.put("assertion", assertion);

    final MockHttpServletResponse servletResponse = new MockHttpServletResponse();

    this.response.renderMergedOutputModel(model, new MockHttpServletRequest(), servletResponse);
    final String written = servletResponse.getContentAsString();

    assertTrue(written.contains("testPrincipal"));
    assertTrue(written.contains("testAttribute"));
    assertTrue(written.contains("testValue"));
    assertFalse(written.contains("testEmptyCollection"));
    assertTrue(written.contains("testAttributeCollection"));
    assertTrue(written.contains("tac1"));
    assertTrue(written.contains("tac2"));
    assertTrue(written.contains(SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_SSL_TLS_CLIENT));
    assertTrue(written.contains("AuthenticationMethod"));
    assertTrue(written.contains("AssertionID"));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:38,代码来源:Saml10SuccessResponseViewTests.java

示例7: verifyResponseWithNoAttributes

import org.jasig.cas.support.saml.authentication.SamlAuthenticationMetaDataPopulator; //导入依赖的package包/类
@Test
public void verifyResponseWithNoAttributes() throws Exception {
    final Map<String, Object> model = new HashMap<>();

    final Principal principal = new DefaultPrincipalFactory().createPrincipal("testPrincipal");

    final Map<String, Object> authAttributes = new HashMap<>();
    authAttributes.put(
            SamlAuthenticationMetaDataPopulator.ATTRIBUTE_AUTHENTICATION_METHOD,
            SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_SSL_TLS_CLIENT);
    authAttributes.put("testSamlAttribute", "value");

    final Authentication primary = TestUtils.getAuthentication(principal, authAttributes);

    final Assertion assertion = new ImmutableAssertion(
            primary, Collections.singletonList(primary), TestUtils.getService(), true);
    model.put("assertion", assertion);

    final MockHttpServletResponse servletResponse = new MockHttpServletResponse();

    this.response.renderMergedOutputModel(model, new MockHttpServletRequest(), servletResponse);
    final String written = servletResponse.getContentAsString();

    assertTrue(written.contains("testPrincipal"));
    assertTrue(written.contains(SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_SSL_TLS_CLIENT));
    assertTrue(written.contains("AuthenticationMethod="));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:28,代码来源:Saml10SuccessResponseViewTests.java

示例8: newAuthenticationStatement

import org.jasig.cas.support.saml.authentication.SamlAuthenticationMetaDataPopulator; //导入依赖的package包/类
private AuthenticationStatement newAuthenticationStatement(final Authentication authentication) {
    final String authenticationMethod = (String) authentication.getAttributes().get(
            SamlAuthenticationMetaDataPopulator.ATTRIBUTE_AUTHENTICATION_METHOD);
    final AuthenticationStatement authnStatement = newSamlObject(AuthenticationStatement.class);
    authnStatement.setAuthenticationInstant(new DateTime(authentication.getAuthenticatedDate()));
    authnStatement.setAuthenticationMethod(
            authenticationMethod != null
            ? authenticationMethod
                    : SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_UNSPECIFIED);
    authnStatement.setSubject(newSubject(authentication.getPrincipal().getId()));
    return authnStatement;
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:13,代码来源:Saml10SuccessResponseView.java

示例9: testResponse

import org.jasig.cas.support.saml.authentication.SamlAuthenticationMetaDataPopulator; //导入依赖的package包/类
@Test
public void testResponse() throws Exception {
    final Map<String, Object> model = new HashMap<String, Object>();

    final Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put("testAttribute", "testValue");
    attributes.put("testEmptyCollection", Collections.emptyList());
    attributes.put("testAttributeCollection", Arrays.asList(new String[] {"tac1", "tac2"}));
    final SimplePrincipal principal = new SimplePrincipal("testPrincipal", attributes);

    final Map<String, Object> authAttributes = new HashMap<String, Object>();
    authAttributes.put(
            SamlAuthenticationMetaDataPopulator.ATTRIBUTE_AUTHENTICATION_METHOD,
            SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_SSL_TLS_CLIENT);
    authAttributes.put("testSamlAttribute", "value");

    final Authentication primary = TestUtils.getAuthentication(principal, authAttributes);
    final Assertion assertion = new ImmutableAssertion(
            primary, Collections.singletonList(primary), TestUtils.getService(), true);
    model.put("assertion", assertion);

    final MockHttpServletResponse servletResponse = new MockHttpServletResponse();

    this.response.renderMergedOutputModel(model, new MockHttpServletRequest(), servletResponse);
    final String written = servletResponse.getContentAsString();

    assertTrue(written.contains("testPrincipal"));
    assertTrue(written.contains("testAttribute"));
    assertTrue(written.contains("testValue"));
    assertFalse(written.contains("testEmptyCollection"));
    assertTrue(written.contains("testAttributeCollection"));
    assertTrue(written.contains("tac1"));
    assertTrue(written.contains("tac2"));
    assertTrue(written.contains(SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_SSL_TLS_CLIENT));
    assertTrue(written.contains("AuthenticationMethod"));
    assertTrue(written.contains("AssertionID"));
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:38,代码来源:Saml10SuccessResponseViewTests.java

示例10: testResponseWithNoAttributes

import org.jasig.cas.support.saml.authentication.SamlAuthenticationMetaDataPopulator; //导入依赖的package包/类
@Test
public void testResponseWithNoAttributes() throws Exception {
    final Map<String, Object> model = new HashMap<String, Object>();

    final SimplePrincipal principal = new SimplePrincipal("testPrincipal");

    final Map<String, Object> authAttributes = new HashMap<String, Object>();
    authAttributes.put(
            SamlAuthenticationMetaDataPopulator.ATTRIBUTE_AUTHENTICATION_METHOD,
            SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_SSL_TLS_CLIENT);
    authAttributes.put("testSamlAttribute", "value");

    final Authentication primary = TestUtils.getAuthentication(principal, authAttributes);

    final Assertion assertion = new ImmutableAssertion(
            primary, Collections.singletonList(primary), TestUtils.getService(), true);
    model.put("assertion", assertion);

    final MockHttpServletResponse servletResponse = new MockHttpServletResponse();

    this.response.renderMergedOutputModel(model, new MockHttpServletRequest(), servletResponse);
    final String written = servletResponse.getContentAsString();

    assertTrue(written.contains("testPrincipal"));
    assertTrue(written.contains(SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_SSL_TLS_CLIENT));
    assertTrue(written.contains("AuthenticationMethod"));
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:28,代码来源:Saml10SuccessResponseViewTests.java

示例11: prepareResponse

import org.jasig.cas.support.saml.authentication.SamlAuthenticationMetaDataPopulator; //导入依赖的package包/类
@Override
protected void prepareResponse(final Response response, final Map<String, Object> model) {

    final DateTime issuedAt = response.getIssueInstant();
    final Service service = getAssertionFrom(model).getService();

    final Authentication authentication = getPrimaryAuthenticationFrom(model);
    final String authenticationMethod = (String) authentication.getAttributes().get(
            SamlAuthenticationMetaDataPopulator.ATTRIBUTE_AUTHENTICATION_METHOD);

    final AuthenticationStatement authnStatement = this.samlObjectBuilder.newAuthenticationStatement(
            authentication.getAuthenticationDate(), authenticationMethod, getPrincipal(model).getId());

    final Assertion assertion = this.samlObjectBuilder.newAssertion(authnStatement, this.issuer, issuedAt,
            this.samlObjectBuilder.generateSecureRandomId());
    final Conditions conditions = this.samlObjectBuilder.newConditions(issuedAt, service.getId(), this.issueLength);
    assertion.setConditions(conditions);

    final Subject subject = this.samlObjectBuilder.newSubject(getPrincipal(model).getId());
    final Map<String, Object> attributesToSend = prepareSamlAttributes(model, service);

    if (!attributesToSend.isEmpty()) {
        assertion.getAttributeStatements().add(this.samlObjectBuilder.newAttributeStatement(
                subject, attributesToSend, VALIDATION_SAML_ATTRIBUTE_NAMESPACE));
    }

    response.setStatus(this.samlObjectBuilder.newStatus(StatusCode.SUCCESS, null));
    response.getAssertions().add(assertion);
}
 
开发者ID:xuchengdong,项目名称:cas4.1.9,代码行数:30,代码来源:Saml10SuccessResponseView.java


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