Package org.jasig.cas.client.validation

Examples of org.jasig.cas.client.validation.Assertion


        assertTrue(!token1.equals(token2));
    }

    public void testNotEqualsDueToAssertion() {
        final Assertion assertion = new AssertionImpl("test");
        final Assertion assertion2 = new AssertionImpl("test");

        CasAuthenticationToken token1 = new CasAuthenticationToken("key", makeUserDetails(), "Password", ROLES,
                makeUserDetails(), assertion);

        CasAuthenticationToken token2 = new CasAuthenticationToken("key", makeUserDetails(), "Password", ROLES,
View Full Code Here


        assertTrue(!token1.equals(token2));
    }

    public void testSetAuthenticated() {
        final Assertion assertion = new AssertionImpl("test");
        CasAuthenticationToken token = new CasAuthenticationToken("key", makeUserDetails(), "Password", ROLES,
                makeUserDetails(), assertion);
        assertTrue(token.isAuthenticated());
        token.setAuthenticated(false);
        assertTrue(!token.isAuthenticated());
View Full Code Here

        token.setAuthenticated(false);
        assertTrue(!token.isAuthenticated());
    }

    public void testToString() {
        final Assertion assertion = new AssertionImpl("test");
        CasAuthenticationToken token = new CasAuthenticationToken("key", makeUserDetails(), "Password",ROLES,
                makeUserDetails(), assertion);
        String result = token.toString();
        assertTrue(result.lastIndexOf("Credentials (Service/Proxy Ticket):") != -1);
    }
View Full Code Here

    protected CasAuthenticationToken getToken() {
        List<String> proxyList = new ArrayList<String>();
        proxyList.add("https://localhost/newPortal/j_spring_cas_security_check");

        User user = new User("rod", "password", true, true, true, true, AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"));
        final Assertion assertion = new AssertionImpl("rod");

        return new CasAuthenticationToken("key", user, "ST-0-ER94xMJmn6pha35CQRoZ",
                AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"), user, assertion);
    }
View Full Code Here

    @Test
    public void correctlyExtractsNamedAttributesFromAssertionAndConvertsThemToAuthorities() {
        GrantedAuthorityFromAssertionAttributesUserDetailsService uds =
                new GrantedAuthorityFromAssertionAttributesUserDetailsService(new String[] {"a", "b", "c", "d"});
        uds.setConvertToUpperCase(false);
        Assertion assertion = mock(Assertion.class);
        AttributePrincipal principal = mock(AttributePrincipal.class);
        Map<String, Object> attributes = new HashMap<String, Object>();
        attributes.put("a", Arrays.asList("role_a1", "role_a2"));
        attributes.put("b", "role_b");
        attributes.put("c", "role_c");
        attributes.put("d", null);
        attributes.put("someother", "unused");
        when(assertion.getPrincipal()).thenReturn(principal);
        when(principal.getAttributes()).thenReturn(attributes);
        when(principal.getName()).thenReturn("somebody");
        CasAssertionAuthenticationToken token = new CasAssertionAuthenticationToken(assertion, "ticket");
        UserDetails user = uds.loadUserDetails(token);
        Set<String> roles = AuthorityUtils.authorityListToSet(user.getAuthorities());
View Full Code Here

    Cas20ProxyTicketValidator ticketValidator = new Cas20ProxyTicketValidator(casServerUrl);
      ticketValidator.setRenew(this.renewTicket);
     
      //String serviceUrl = "http://"+ httpRequest.getServerName() +":" + httpRequest.getServerPort() +
      //httpRequest.getContextPath() +"/private/classic";
      Assertion assertion = ticketValidator.validate(ticket, this.casServiceUrl);
     
      log.debug("------------------------------------------------------------------------------------");
      log.debug("Service: "+this.casServiceUrl);
      log.debug("Principal: "+assertion.getPrincipal().getName());
      log.debug("------------------------------------------------------------------------------------");

      String principal = assertion.getPrincipal().getName();
       this.saveSSOCredentials(principal, httpRequest);
  }   
View Full Code Here

  }

  private CasAuthentication authenticateNow(CasAuthentication auth)
      throws AuthenticationException {
    try {
      final Assertion assertion = ticketValidator.validate(auth.getCredentials().toString(),
          auth.getLoginUrl());
      final UserDetail userDetails = userDetailService.loadDetail(auth);
      userDetailChecker.check(userDetails);
      return new CasAuthentication(key, userDetails, auth.getCredentials(),
          userDetails.getAuthorities(), userDetails, assertion);
View Full Code Here

    @Override
    protected CasProfile retrieveUserProfile(final CasCredentials credentials, final WebContext context) {
        final String ticket = credentials.getServiceTicket();
        try {
            final String contextualCallbackUrl = getContextualCallbackUrl(context);
            final Assertion assertion = this.ticketValidator.validate(ticket, contextualCallbackUrl);
            final AttributePrincipal principal = assertion.getPrincipal();
            logger.debug("principal : {}", principal);
            final CasProfile casProfile;
            if (this.casProxyReceptor != null) {
                casProfile = new CasProxyProfile();
            } else {
View Full Code Here

     *
     * @return String
     */
    public String readUserIdentifier(HttpServletRequest request){
    HttpSession session=request.getSession();
    Assertion assertion = (Assertion) session.getAttribute(AbstractCasFilter.CONST_CAS_ASSERTION);
    String userInSession=assertion.getPrincipal().getName();
  String user=(String)request.getRemoteUser();
  logger.debug("CAS user in HttpServletRequest:"+user);
  logger.debug("CAS user in HttpSession:"+userInSession);
  return user;
    }
View Full Code Here

     * @param session PortletSession
     *
     * @return String
     */
    public String readUserIdentifier(PortletSession session){
    Assertion assertion = (Assertion) session.getAttribute(AbstractCasFilter.CONST_CAS_ASSERTION);
    String user=assertion.getPrincipal().getName();
  logger.debug("CAS user in PortletSession:"+user);
  return user;
    }
View Full Code Here

TOP

Related Classes of org.jasig.cas.client.validation.Assertion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.