Search in sources :

Example 6 with CasAuthenticationToken

use of org.springframework.security.cas.authentication.CasAuthenticationToken in project spring-security by spring-projects.

the class AbstractStatelessTicketCacheTests method getToken.

protected CasAuthenticationToken getToken() {
    List<String> proxyList = new ArrayList<String>();
    proxyList.add("https://localhost/newPortal/login/cas");
    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);
}
Also used : AssertionImpl(org.jasig.cas.client.validation.AssertionImpl) User(org.springframework.security.core.userdetails.User) CasAuthenticationToken(org.springframework.security.cas.authentication.CasAuthenticationToken) ArrayList(java.util.ArrayList) Assertion(org.jasig.cas.client.validation.Assertion)

Example 7 with CasAuthenticationToken

use of org.springframework.security.cas.authentication.CasAuthenticationToken in project spring-security by spring-projects.

the class NullStatelessTicketCacheTests method testInsertAndGet.

@Test
public void testInsertAndGet() {
    final CasAuthenticationToken token = getToken();
    cache.putTicketInCache(token);
    assertThat(cache.getByTicketId((String) token.getCredentials())).isNull();
}
Also used : CasAuthenticationToken(org.springframework.security.cas.authentication.CasAuthenticationToken) Test(org.junit.Test)

Example 8 with CasAuthenticationToken

use of org.springframework.security.cas.authentication.CasAuthenticationToken in project spring-security by spring-projects.

the class CasAuthenticationTokenMixinTests method serializeCasAuthenticationTestAfterEraseCredentialInvoked.

@Test
public void serializeCasAuthenticationTestAfterEraseCredentialInvoked() throws JsonProcessingException, JSONException {
    CasAuthenticationToken token = createCasAuthenticationToken();
    token.eraseCredentials();
    String actualJson = mapper.writeValueAsString(token);
    JSONAssert.assertEquals(CAS_TOKEN_CLEARED_JSON, actualJson, true);
}
Also used : CasAuthenticationToken(org.springframework.security.cas.authentication.CasAuthenticationToken) Test(org.junit.Test)

Example 9 with CasAuthenticationToken

use of org.springframework.security.cas.authentication.CasAuthenticationToken in project spring-security by spring-projects.

the class CasAuthenticationTokenMixinTests method deserializeCasAuthenticationTestAfterEraseCredentialInvoked.

@Test
public void deserializeCasAuthenticationTestAfterEraseCredentialInvoked() throws Exception {
    CasAuthenticationToken token = mapper.readValue(CAS_TOKEN_CLEARED_JSON, CasAuthenticationToken.class);
    assertThat(((UserDetails) token.getPrincipal()).getPassword()).isNull();
}
Also used : UserDetails(org.springframework.security.core.userdetails.UserDetails) CasAuthenticationToken(org.springframework.security.cas.authentication.CasAuthenticationToken) Test(org.junit.Test)

Aggregations

CasAuthenticationToken (org.springframework.security.cas.authentication.CasAuthenticationToken)9 Test (org.junit.Test)6 User (org.springframework.security.core.userdetails.User)3 Assertion (org.jasig.cas.client.validation.Assertion)2 AssertionImpl (org.jasig.cas.client.validation.AssertionImpl)2 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)2 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 AttributePrincipalImpl (org.jasig.cas.client.authentication.AttributePrincipalImpl)1 EhCacheBasedTicketCache (org.springframework.security.cas.authentication.EhCacheBasedTicketCache)1 UserDetails (org.springframework.security.core.userdetails.UserDetails)1