Search in sources :

Example 1 with AssertionImpl

use of org.jasig.cas.client.validation.AssertionImpl in project spring-security by spring-projects.

the class CasAuthenticationTokenMixinTests method createCasAuthenticationToken.

private CasAuthenticationToken createCasAuthenticationToken() {
    User principal = new User("admin", "1234", Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER")));
    Collection<? extends GrantedAuthority> authorities = Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER"));
    Assertion assertion = new AssertionImpl(new AttributePrincipalImpl("assertName"), START_DATE, END_DATE, START_DATE, Collections.<String, Object>emptyMap());
    return new CasAuthenticationToken(KEY, principal, principal.getPassword(), authorities, new User("admin", "1234", authorities), assertion);
}
Also used : AssertionImpl(org.jasig.cas.client.validation.AssertionImpl) SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) User(org.springframework.security.core.userdetails.User) CasAuthenticationToken(org.springframework.security.cas.authentication.CasAuthenticationToken) Assertion(org.jasig.cas.client.validation.Assertion) AttributePrincipalImpl(org.jasig.cas.client.authentication.AttributePrincipalImpl)

Example 2 with AssertionImpl

use of org.jasig.cas.client.validation.AssertionImpl in project spring-security by spring-projects.

the class CasAuthenticationTokenTests method testNotEqualsDueToDifferentAuthenticationClass.

@Test
public void testNotEqualsDueToDifferentAuthenticationClass() {
    final Assertion assertion = new AssertionImpl("test");
    CasAuthenticationToken token1 = new CasAuthenticationToken("key", makeUserDetails(), "Password", ROLES, makeUserDetails(), assertion);
    UsernamePasswordAuthenticationToken token2 = new UsernamePasswordAuthenticationToken("Test", "Password", ROLES);
    assertThat(!token1.equals(token2)).isTrue();
}
Also used : AssertionImpl(org.jasig.cas.client.validation.AssertionImpl) Assertion(org.jasig.cas.client.validation.Assertion) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) Test(org.junit.Test)

Example 3 with AssertionImpl

use of org.jasig.cas.client.validation.AssertionImpl in project spring-security by spring-projects.

the class CasAuthenticationTokenTests method testNotEqualsDueToAssertion.

@Test
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, makeUserDetails(), assertion2);
    assertThat(!token1.equals(token2)).isTrue();
}
Also used : AssertionImpl(org.jasig.cas.client.validation.AssertionImpl) Assertion(org.jasig.cas.client.validation.Assertion) Test(org.junit.Test)

Example 4 with AssertionImpl

use of org.jasig.cas.client.validation.AssertionImpl in project spring-security by spring-projects.

the class CasAuthenticationTokenTests method testSetAuthenticated.

@Test
public void testSetAuthenticated() {
    final Assertion assertion = new AssertionImpl("test");
    CasAuthenticationToken token = new CasAuthenticationToken("key", makeUserDetails(), "Password", ROLES, makeUserDetails(), assertion);
    assertThat(token.isAuthenticated()).isTrue();
    token.setAuthenticated(false);
    assertThat(!token.isAuthenticated()).isTrue();
}
Also used : AssertionImpl(org.jasig.cas.client.validation.AssertionImpl) Assertion(org.jasig.cas.client.validation.Assertion) Test(org.junit.Test)

Example 5 with AssertionImpl

use of org.jasig.cas.client.validation.AssertionImpl in project spring-security by spring-projects.

the class CasAuthenticationTokenTests method testNotEqualsDueToKey.

@Test
public void testNotEqualsDueToKey() {
    final Assertion assertion = new AssertionImpl("test");
    CasAuthenticationToken token1 = new CasAuthenticationToken("key", makeUserDetails(), "Password", ROLES, makeUserDetails(), assertion);
    CasAuthenticationToken token2 = new CasAuthenticationToken("DIFFERENT_KEY", makeUserDetails(), "Password", ROLES, makeUserDetails(), assertion);
    assertThat(!token1.equals(token2)).isTrue();
}
Also used : AssertionImpl(org.jasig.cas.client.validation.AssertionImpl) Assertion(org.jasig.cas.client.validation.Assertion) Test(org.junit.Test)

Aggregations

AssertionImpl (org.jasig.cas.client.validation.AssertionImpl)15 Assertion (org.jasig.cas.client.validation.Assertion)12 Test (org.junit.Test)9 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)3 AttributePrincipalImpl (org.jasig.cas.client.authentication.AttributePrincipalImpl)2 TicketValidator (org.jasig.cas.client.validation.TicketValidator)2 ServiceProperties (org.springframework.security.cas.ServiceProperties)2 CasAuthenticationToken (org.springframework.security.cas.authentication.CasAuthenticationToken)2 ServiceAuthenticationDetails (org.springframework.security.cas.web.authentication.ServiceAuthenticationDetails)2 Authentication (org.springframework.security.core.Authentication)2 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)2 User (org.springframework.security.core.userdetails.User)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 AttributePrincipal (org.jasig.cas.client.authentication.AttributePrincipal)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 WebAuthenticationDetails (org.springframework.security.web.authentication.WebAuthenticationDetails)1