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


Java Assertion类代码示例

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


Assertion类属于org.jasig.cas.validation包,在下文中一共展示了Assertion类的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:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数: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: verifyAllowsAccessToHighSecurityServiceWithPasswordAndOTPViaRenew

import org.jasig.cas.validation.Assertion; //导入依赖的package包/类
@Test
public void verifyAllowsAccessToHighSecurityServiceWithPasswordAndOTPViaRenew() throws Exception {
    // Note the original credential used to start SSO session does not satisfy security policy

    final AuthenticationContext ctx = processAuthenticationAttempt(HIGH_SERVICE, newUserPassCredentials("alice", "alice"));
    final TicketGrantingTicket tgt = cas.createTicketGrantingTicket(ctx);
    assertNotNull(tgt);
    final AuthenticationContext ctx2 = processAuthenticationAttempt(HIGH_SERVICE, newUserPassCredentials("alice", "alice"),
            new OneTimePasswordCredential("alice", "31415"));

    final ServiceTicket st = cas.grantServiceTicket(
            tgt.getId(),
            HIGH_SERVICE,
            ctx2);

    assertNotNull(st);
    // Confirm the authentication in the assertion is the one that satisfies security policy
    final Assertion assertion = cas.validateServiceTicket(st.getId(), HIGH_SERVICE);
    assertEquals(2, assertion.getPrimaryAuthentication().getSuccesses().size());
    assertTrue(assertion.getPrimaryAuthentication().getSuccesses().containsKey("passwordHandler"));
    assertTrue(assertion.getPrimaryAuthentication().getSuccesses().containsKey("oneTimePasswordHandler"));
    assertTrue(assertion.getPrimaryAuthentication().getAttributes().containsKey(
            SuccessfulHandlerMetaDataPopulator.SUCCESSFUL_AUTHENTICATION_HANDLERS));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:25,代码来源:MultifactorAuthenticationTests.java

示例4: generateSuccessView

import org.jasig.cas.validation.Assertion; //导入依赖的package包/类
/**
 * Generate the success view. The result will contain the assertion and the proxy iou.
 *
 * @param assertion the assertion
 * @param proxyIou the proxy iou
 * @param service the validated service
 * @param proxyGrantingTicket the proxy granting ticket
 * @return the model and view, pointed to the view name set by
 */
private ModelAndView generateSuccessView(final Assertion assertion, final String proxyIou,
                                         final WebApplicationService service,
                                         final TicketGrantingTicket proxyGrantingTicket) {

    final ModelAndView modelAndView = getModelAndView(true, service);

    modelAndView.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_ASSERTION, assertion);
    modelAndView.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_SERVICE, service);
    modelAndView.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_PROXY_GRANTING_TICKET_IOU, proxyIou);
    if (proxyGrantingTicket != null) {
        modelAndView.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_PROXY_GRANTING_TICKET, proxyGrantingTicket.getId());
    }
    final Map<String, ?> augmentedModelObjects = augmentSuccessViewModelObjects(assertion);
    if (augmentedModelObjects != null) {
        modelAndView.addAllObjects(augmentedModelObjects);
    }
    return modelAndView;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:28,代码来源:AbstractServiceValidateController.java

示例5: verifyResolverAssertionReturnValue

import org.jasig.cas.validation.Assertion; //导入依赖的package包/类
@Test
public void verifyResolverAssertionReturnValue() throws Exception {
    final Credential c = TestUtils.getCredentialsWithSameUsernameAndPassword();
    final AuthenticationContext authnResult = TestUtils.getAuthenticationContext(getAuthenticationSystemSupport(), c);
    final Authentication authn = authnResult.getAuthentication();

    final TicketOrCredentialPrincipalResolver delegate = new TicketOrCredentialPrincipalResolver(getCentralAuthenticationService());
    final AssertionAsReturnValuePrincipalResolver res = new AssertionAsReturnValuePrincipalResolver(delegate);
    final JoinPoint jp = mock(JoinPoint.class);
    final Assertion returnedAssertion =
            new ImmutableAssertion(authnResult.getAuthentication(), Arrays.asList(authn), authnResult.getService(), true);

    final String result = res.resolveFrom(jp, returnedAssertion);
    assertNotNull(result);
    assertEquals(result, c.getId());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:AssertionAsReturnValuePrincipalResolverTests.java

示例6: getChainedAuthentications

import org.jasig.cas.validation.Assertion; //导入依赖的package包/类
/**
 * Gets chained authentications.
 *
 * @param model the model
 * @return the chained authentications
 */
protected final Collection<Authentication> getChainedAuthentications(final Map<String, Object> model) {
    final Collection<Authentication> chainedAuthenticationsToReturn = new ArrayList<>();

    final Assertion assertion = getAssertionFrom(model);
    final List<Authentication> chainedAuthentications = assertion.getChainedAuthentications();

    /**
     * Note that the last index in the list always describes the primary authentication
     * event. All others in the chain should denote proxies. Per the CAS protocol,
     * when authentication has proceeded through multiple proxies,
     * the order in which the proxies were traversed MUST be reflected in the response.
     * The most recently-visited proxy MUST be the first proxy listed, and all the
     * other proxies MUST be shifted down as new proxies are added. I
     */
    final int numberAuthenticationsExceptPrimary = chainedAuthentications.size() - 1;
    for (int i = 0; i < numberAuthenticationsExceptPrimary; i++) {
        chainedAuthenticationsToReturn.add(chainedAuthentications.get(i));
    }
    return chainedAuthenticationsToReturn;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:AbstractCasView.java

示例7: getChainedAuthentications

import org.jasig.cas.validation.Assertion; //导入依赖的package包/类
/**
 * Gets chained authentications.
 *
 * @param model the model
 * @return the chained authentications
 */
protected final Collection<Authentication> getChainedAuthentications(final Map<String, Object> model) {
    final List<Authentication> chainedAuthenticationsToReturn = new ArrayList<>();

    final Assertion assertion = getAssertionFrom(model);
    final List<Authentication> chainedAuthentications = assertion.getChainedAuthentications();

    /**
     * Note that the last index in the list always describes the primary authentication
     * event. All others in the chain should denote proxies. Per the CAS protocol,
     * when authentication has proceeded through multiple proxies,
     * the order in which the proxies were traversed MUST be reflected in the response.
     * The most recently-visited proxy MUST be the first proxy listed, and all the
     * other proxies MUST be shifted down as new proxies are added. I
     */
    final int numberAuthenticationsExceptPrimary = chainedAuthentications.size() - 1;
    for (int i = 0; i < numberAuthenticationsExceptPrimary; i++) {
        chainedAuthenticationsToReturn.add(chainedAuthentications.get(i));
    }
    return chainedAuthenticationsToReturn;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:AbstractCasView.java

示例8: verifyChainedAuthenticationsOnValidation

import org.jasig.cas.validation.Assertion; //导入依赖的package包/类
@Test
public void verifyChainedAuthenticationsOnValidation() throws TicketException {
    final Service svc = TestUtils.getService(SVC2_ID);
    final ServiceTicket st = this.cas.grantServiceTicket(TGT2_ID, svc);
    assertNotNull(st);
    
    final Assertion assertion = this.cas.validateServiceTicket(st.getId(), svc);
    assertNotNull(assertion);
    
    assertEquals(assertion.getService(), svc);
    assertEquals(assertion.getPrimaryAuthentication().getPrincipal().getId(), PRINCIPAL);
    assertTrue(assertion.getChainedAuthentications().size()  == 2);
    for (int i = 0; i < assertion.getChainedAuthentications().size(); i++) {
        final Authentication auth = assertion.getChainedAuthentications().get(i);
        assertEquals(auth, authentication);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:CentralAuthenticationServiceImplWithMockitoTests.java

示例9: 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

示例10: verifyAllowsAccessToHighSecurityServiceWithPasswordAndOTPViaRenew

import org.jasig.cas.validation.Assertion; //导入依赖的package包/类
@Test
public void verifyAllowsAccessToHighSecurityServiceWithPasswordAndOTPViaRenew() throws Exception {
    // Note the original credential used to start SSO session does not satisfy security policy
    final TicketGrantingTicket tgt = cas.createTicketGrantingTicket(newUserPassCredentials("alice", "alice"));
    assertNotNull(tgt);
    final Service service = newService("https://example.com/high/");
    final ServiceTicket st = cas.grantServiceTicket(
            tgt.getId(),
            service,
            newUserPassCredentials("alice", "alice"),
            new OneTimePasswordCredential("alice", "31415"));
    assertNotNull(st);
    // Confirm the authentication in the assertion is the one that satisfies security policy
    final Assertion assertion = cas.validateServiceTicket(st.getId(), service);
    assertEquals(2, assertion.getPrimaryAuthentication().getSuccesses().size());
    assertTrue(assertion.getPrimaryAuthentication().getSuccesses().containsKey("passwordHandler"));
    assertTrue(assertion.getPrimaryAuthentication().getSuccesses().containsKey("oneTimePasswordHandler"));
    assertTrue(assertion.getPrimaryAuthentication().getAttributes().containsKey(
            SuccessfulHandlerMetaDataPopulator.SUCCESSFUL_AUTHENTICATION_HANDLERS));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:21,代码来源:MultifactorAuthenticationTests.java

示例11: generateSuccessView

import org.jasig.cas.validation.Assertion; //导入依赖的package包/类
/**
 * Generate the success view. The result will contain the assertion and the proxy iou.
 *
 * @param assertion the assertion
 * @param proxyIou the proxy iou
 * @param service the validated service
 * @param proxyGrantingTicket the proxy granting ticket
 * @return the model and view, pointed to the view name set by
 */
private ModelAndView generateSuccessView(final Assertion assertion, final String proxyIou,
                                         final WebApplicationService service,
                                         final TicketGrantingTicket proxyGrantingTicket) {

    final ModelAndView success = new ModelAndView(this.successView);
    success.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_ASSERTION, assertion);
    success.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_SERVICE, service);
    success.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_PROXY_GRANTING_TICKET_IOU, proxyIou);
    if (proxyGrantingTicket != null) {
        success.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_PROXY_GRANTING_TICKET, proxyGrantingTicket.getId());
    }
    final Map<String, ?> augmentedModelObjects = augmentSuccessViewModelObjects(assertion);
    if (augmentedModelObjects != null) {
        success.addAllObjects(augmentedModelObjects);
    }
    return success;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:ServiceValidateController.java

示例12: testResponseWithoutAuthMethod

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

    final Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put("testAttribute", "testValue");
    final SimplePrincipal principal = new SimplePrincipal("testPrincipal", attributes);

    final Authentication primary = TestUtils.getAuthentication(principal);

    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"));
    assertTrue(written.contains("urn:oasis:names:tc:SAML:1.0:am:unspecified"));
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:25,代码来源:Saml10SuccessResponseViewTests.java

示例13: testChainedAuthenticationsOnValidation

import org.jasig.cas.validation.Assertion; //导入依赖的package包/类
@Test
public void testChainedAuthenticationsOnValidation() throws TicketException {
    final Service svc = TestUtils.getService(SVC2_ID);
    final String st = this.cas.grantServiceTicket(TGT2_ID, svc);
    assertNotNull(st);
    
    final Assertion assertion = this.cas.validateServiceTicket(st, svc);
    assertNotNull(assertion);
    
    assertEquals(assertion.getService(), svc);
    assertEquals(assertion.getPrimaryAuthentication().getPrincipal().getId(), PRINCIPAL);
    assertTrue(assertion.getChainedAuthentications().size()  == 2);
    for (int i = 0; i < assertion.getChainedAuthentications().size(); i++) {
        final Authentication auth = assertion.getChainedAuthentications().get(i);
        assertEquals(auth, authentication);
    }
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:18,代码来源:CentralAuthenticationServiceImplWithMokitoTests.java

示例14: 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

示例15: testAllowsAccessToHighSecurityServiceWithPasswordAndOTPViaRenew

import org.jasig.cas.validation.Assertion; //导入依赖的package包/类
@Test
public void testAllowsAccessToHighSecurityServiceWithPasswordAndOTPViaRenew() throws Exception {
    // Note the original credential used to start SSO session does not satisfy security policy
    final String tgt = cas.createTicketGrantingTicket(newUserPassCredentials("alice", "alice"));
    assertNotNull(tgt);
    final Service service = newService("https://example.com/high/");
    final String st = cas.grantServiceTicket(
            tgt,
            service,
            newUserPassCredentials("alice", "alice"),
            new OneTimePasswordCredential("alice", "31415"));
    assertNotNull(st);
    // Confirm the authentication in the assertion is the one that satisfies security policy
    final Assertion assertion = cas.validateServiceTicket(st, service);
    assertEquals(2, assertion.getPrimaryAuthentication().getSuccesses().size());
    assertTrue(assertion.getPrimaryAuthentication().getSuccesses().containsKey("passwordHandler"));
    assertTrue(assertion.getPrimaryAuthentication().getSuccesses().containsKey("oneTimePasswordHandler"));
    assertTrue(assertion.getPrimaryAuthentication().getAttributes().containsKey(
            SuccessfulHandlerMetaDataPopulator.SUCCESSFUL_AUTHENTICATION_HANDLERS));
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:21,代码来源:MultifactorAuthenticationTests.java


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