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


Java Assertion.getPrimaryAuthentication方法代码示例

本文整理汇总了Java中org.jasig.cas.validation.Assertion.getPrimaryAuthentication方法的典型用法代码示例。如果您正苦于以下问题:Java Assertion.getPrimaryAuthentication方法的具体用法?Java Assertion.getPrimaryAuthentication怎么用?Java Assertion.getPrimaryAuthentication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jasig.cas.validation.Assertion的用法示例。


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

示例1: verifyValidateServiceTicketReturnOnlyAllowedAttribute

import org.jasig.cas.validation.Assertion; //导入方法依赖的package包/类
@Test
public void verifyValidateServiceTicketReturnOnlyAllowedAttribute() throws Exception {
    final Service service = getService("eduPersonTestInvalid");
    final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword();
    final AuthenticationContext ctx = TestUtils.getAuthenticationContext(getAuthenticationSystemSupport(), service);
    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
    final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(),
        service, ctx);

    final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(),
        service);
    final Authentication auth = assertion.getPrimaryAuthentication();
    final Map<String, Object> attributes = auth.getPrincipal().getAttributes();
    assertEquals(1, attributes.size());
    assertEquals("adopters", attributes.get("groupMembership"));
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:17,代码来源:CentralAuthenticationServiceImplTests.java

示例2: verifyValidateServiceTicketWithInvalidUsernameAttribute

import org.jasig.cas.validation.Assertion; //导入方法依赖的package包/类
@Test
public void verifyValidateServiceTicketWithInvalidUsernameAttribute() throws Exception {
    final Service svc = getService("eduPersonTestInvalid");
    final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword();
    final AuthenticationContext ctx = TestUtils.getAuthenticationContext(getAuthenticationSystemSupport(), svc);
    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);


    final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), svc, ctx);

    final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(), svc);
    final Authentication auth = assertion.getPrimaryAuthentication();

    /*
     * The attribute specified for this service does not resolve.
     * Therefore, we expect the default to be returned.
     */
    assertEquals(auth.getPrincipal().getId(), cred.getUsername());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:20,代码来源:CentralAuthenticationServiceImplTests.java

示例3: verifyValidateServiceTicketWithInvalidUsernameAttribute

import org.jasig.cas.validation.Assertion; //导入方法依赖的package包/类
@Test
public void verifyValidateServiceTicketWithInvalidUsernameAttribute() throws Exception {
    final UsernamePasswordCredential cred =  TestUtils.getCredentialsWithSameUsernameAndPassword();
    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred);

    final Service svc = TestUtils.getService("eduPersonTestInvalid");
    final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), svc);

    final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(), svc);
    final Authentication auth = assertion.getPrimaryAuthentication();

    /*
     * The attribute specified for this service does not resolve.
     * Therefore, we expect the default to be returned.
     */
    assertEquals(auth.getPrincipal().getId(), cred.getUsername());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:CentralAuthenticationServiceImplTests.java

示例4: testValidateServiceTicketWithInvalidUsernameAttribute

import org.jasig.cas.validation.Assertion; //导入方法依赖的package包/类
@Test
public void testValidateServiceTicketWithInvalidUsernameAttribute() throws Exception {
    final UsernamePasswordCredential cred =  TestUtils.getCredentialsWithSameUsernameAndPassword();
    final String ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred);

    final Service svc = TestUtils.getService("eduPersonTestInvalid");
    final String serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket, svc);

    final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket, svc);
    final Authentication auth = assertion.getPrimaryAuthentication();

    /*
     * The attribute specified for this service does not resolve.
     * Therefore, we expect the default to be returned.
     */
    assertEquals(auth.getPrincipal().getId(), cred.getUsername());
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:18,代码来源:CentralAuthenticationServiceImplTests.java

示例5: verifyValidateServiceTicketWithoutUsernameAttribute

import org.jasig.cas.validation.Assertion; //导入方法依赖的package包/类
@Test
public void verifyValidateServiceTicketWithoutUsernameAttribute() throws Exception {
    final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword();
    final AuthenticationContext ctx =TestUtils.getAuthenticationContext(getAuthenticationSystemSupport(), getService());

    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
    final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(),
        getService(), ctx);

    final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(),
        getService());
    final Authentication auth = assertion.getPrimaryAuthentication();
    assertEquals(auth.getPrincipal().getId(), cred.getUsername());
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:15,代码来源:CentralAuthenticationServiceImplTests.java

示例6: verifyValidateServiceTicketWithDefaultUsernameAttribute

import org.jasig.cas.validation.Assertion; //导入方法依赖的package包/类
@Test
public void verifyValidateServiceTicketWithDefaultUsernameAttribute() throws Exception {
    final Service svc = getService("testDefault");
    final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword();
    final AuthenticationContext ctx = TestUtils.getAuthenticationContext(getAuthenticationSystemSupport(), svc);
    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);


    final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), svc, ctx);

    final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(), svc);
    final Authentication auth = assertion.getPrimaryAuthentication();
    assertEquals(auth.getPrincipal().getId(), cred.getUsername());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:15,代码来源:CentralAuthenticationServiceImplTests.java

示例7: verifyValidateServiceTicketReturnAllAttributes

import org.jasig.cas.validation.Assertion; //导入方法依赖的package包/类
@Test
public void verifyValidateServiceTicketReturnAllAttributes() throws Exception {
    final Service service = getService("eduPersonTest");
    final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword();
    final AuthenticationContext ctx = TestUtils.getAuthenticationContext(getAuthenticationSystemSupport(), service);
    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
    final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(),
        service, ctx);

    final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(),
        service);
    final Authentication auth = assertion.getPrimaryAuthentication();
    assertEquals(3, auth.getPrincipal().getAttributes().size());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:15,代码来源:CentralAuthenticationServiceImplTests.java

示例8: verifyValidateServiceTicketAnonymous

import org.jasig.cas.validation.Assertion; //导入方法依赖的package包/类
@Test
public void verifyValidateServiceTicketAnonymous() throws Exception {
    final Service service = getService("testAnonymous");
    final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword();
    final AuthenticationContext ctx = TestUtils.getAuthenticationContext(getAuthenticationSystemSupport(), service);
    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
    final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(),
        service, ctx);

    final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(),
        service);
    final Authentication auth = assertion.getPrimaryAuthentication();
    assertNotEquals(cred.getUsername(), auth.getPrincipal().getId());
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:15,代码来源:CentralAuthenticationServiceImplTests.java

示例9: verifyValidateServiceTicketWithoutUsernameAttribute

import org.jasig.cas.validation.Assertion; //导入方法依赖的package包/类
@Test
public void verifyValidateServiceTicketWithoutUsernameAttribute() throws Exception {
    final UsernamePasswordCredential cred =  TestUtils.getCredentialsWithSameUsernameAndPassword();
    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred);
    final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(),
            TestUtils.getService());

    final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(),
            TestUtils.getService());
    final Authentication auth = assertion.getPrimaryAuthentication();
    assertEquals(auth.getPrincipal().getId(), cred.getUsername());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:13,代码来源:CentralAuthenticationServiceImplTests.java

示例10: verifyValidateServiceTicketWithDefaultUsernameAttribute

import org.jasig.cas.validation.Assertion; //导入方法依赖的package包/类
@Test
public void verifyValidateServiceTicketWithDefaultUsernameAttribute() throws Exception {
    final UsernamePasswordCredential cred =  TestUtils.getCredentialsWithSameUsernameAndPassword();
    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred);

    final Service svc = TestUtils.getService("testDefault");
    final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), svc);

    final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(), svc);
    final Authentication auth = assertion.getPrimaryAuthentication();
    assertEquals(auth.getPrincipal().getId(), cred.getUsername());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:13,代码来源:CentralAuthenticationServiceImplTests.java

示例11: verifyValidateServiceTicketNoAttributesReturned

import org.jasig.cas.validation.Assertion; //导入方法依赖的package包/类
@Test
public void verifyValidateServiceTicketNoAttributesReturned() throws Exception {
    final Service service = TestUtils.getService();
    final UsernamePasswordCredential cred =  TestUtils.getCredentialsWithSameUsernameAndPassword();
    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred);
    final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(),
            service);

    final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(),
            service);
    final Authentication auth = assertion.getPrimaryAuthentication();
    assertEquals(0, auth.getPrincipal().getAttributes().size());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:14,代码来源:CentralAuthenticationServiceImplTests.java

示例12: verifyValidateServiceTicketReturnAllAttributes

import org.jasig.cas.validation.Assertion; //导入方法依赖的package包/类
@Test
public void verifyValidateServiceTicketReturnAllAttributes() throws Exception {
    final Service service = TestUtils.getService("eduPersonTest");
    final UsernamePasswordCredential cred =  TestUtils.getCredentialsWithSameUsernameAndPassword();
    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred);
    final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(),
            service);

    final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(),
            service);
    final Authentication auth = assertion.getPrimaryAuthentication();
    assertEquals(3, auth.getPrincipal().getAttributes().size());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:14,代码来源:CentralAuthenticationServiceImplTests.java

示例13: verifyValidateServiceTicketReturnOnlyAllowedAttribute

import org.jasig.cas.validation.Assertion; //导入方法依赖的package包/类
@Test
public void verifyValidateServiceTicketReturnOnlyAllowedAttribute() throws Exception {
    final Service service = TestUtils.getService("eduPersonTestInvalid");
    final UsernamePasswordCredential cred =  TestUtils.getCredentialsWithSameUsernameAndPassword();
    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred);
    final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(),
            service);

    final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(),
            service);
    final Authentication auth = assertion.getPrimaryAuthentication();
    final Map<String, Object> attributes = auth.getPrincipal().getAttributes();
    assertEquals(1, attributes.size());
    assertEquals("adopters", attributes.get("groupMembership"));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:16,代码来源:CentralAuthenticationServiceImplTests.java

示例14: verifyValidateServiceTicketAnonymous

import org.jasig.cas.validation.Assertion; //导入方法依赖的package包/类
@Test
public void verifyValidateServiceTicketAnonymous() throws Exception {
    final Service service = TestUtils.getService("testAnonymous");
    final UsernamePasswordCredential cred =  TestUtils.getCredentialsWithSameUsernameAndPassword();
    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred);
    final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(),
            service);

    final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(),
            service);
    final Authentication auth = assertion.getPrimaryAuthentication();
    assertNotEquals(cred.getUsername(), auth.getPrincipal().getId());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:14,代码来源:CentralAuthenticationServiceImplTests.java

示例15: testValidateServiceTicketNoAttributesReturned

import org.jasig.cas.validation.Assertion; //导入方法依赖的package包/类
@Test
public void testValidateServiceTicketNoAttributesReturned() throws Exception {
    final Service service = TestUtils.getService();
    final UsernamePasswordCredential cred =  TestUtils.getCredentialsWithSameUsernameAndPassword();
    final String ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred);
    final String serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket,
            service);

    final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket,
            service);
    final Authentication auth = assertion.getPrimaryAuthentication();
    assertEquals(0, auth.getPrincipal().getAttributes().size());
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:14,代码来源:CentralAuthenticationServiceImplTests.java


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