Search in sources :

Example 31 with UsernamePasswordCredential

use of org.apereo.cas.authentication.UsernamePasswordCredential in project cas by apereo.

the class CasKryoTranscoderTests method verifyEncodeDecodeTGTWithListOrderedMap.

@Test
public void verifyEncodeDecodeTGTWithListOrderedMap() {
    final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
    final TicketGrantingTicket expectedTGT = new MockTicketGrantingTicket(TGT_ID, userPassCredential, this.principalAttributes);
    expectedTGT.grantServiceTicket(ST_ID, null, null, false, true);
    final CachedData result = transcoder.encode(expectedTGT);
    assertEquals(expectedTGT, transcoder.decode(result));
    assertEquals(expectedTGT, transcoder.decode(result));
}
Also used : MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Credential(org.apereo.cas.authentication.Credential) CachedData(net.spy.memcached.CachedData) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Test(org.junit.Test)

Example 32 with UsernamePasswordCredential

use of org.apereo.cas.authentication.UsernamePasswordCredential in project cas by apereo.

the class CasKryoTranscoderTests method verifyEncodeDecodeTGTWithUnmodifiableSet.

@Test
public void verifyEncodeDecodeTGTWithUnmodifiableSet() {
    final Map<String, Object> newAttributes = new HashMap<>();
    final Set<String> values = new HashSet<>();
    values.add(NICKNAME_VALUE);
    // CHECKSTYLE:OFF
    newAttributes.put(NICKNAME_KEY, Collections.unmodifiableSet(values));
    // CHECKSTYLE:ON
    final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
    final TicketGrantingTicket expectedTGT = new MockTicketGrantingTicket(TGT_ID, userPassCredential, newAttributes);
    expectedTGT.grantServiceTicket(ST_ID, null, null, false, true);
    final CachedData result = transcoder.encode(expectedTGT);
    assertEquals(expectedTGT, transcoder.decode(result));
    assertEquals(expectedTGT, transcoder.decode(result));
}
Also used : MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Credential(org.apereo.cas.authentication.Credential) CachedData(net.spy.memcached.CachedData) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 33 with UsernamePasswordCredential

use of org.apereo.cas.authentication.UsernamePasswordCredential in project cas by apereo.

the class CasKryoTranscoderTests method verifyEncodeDecodeTGTWithUnmodifiableMap.

@Test
public void verifyEncodeDecodeTGTWithUnmodifiableMap() {
    final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
    final TicketGrantingTicket expectedTGT = new MockTicketGrantingTicket(TGT_ID, userPassCredential, new HashMap<>(this.principalAttributes));
    expectedTGT.grantServiceTicket(ST_ID, null, null, false, true);
    final CachedData result = transcoder.encode(expectedTGT);
    assertEquals(expectedTGT, transcoder.decode(result));
    assertEquals(expectedTGT, transcoder.decode(result));
}
Also used : MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Credential(org.apereo.cas.authentication.Credential) CachedData(net.spy.memcached.CachedData) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Test(org.junit.Test)

Example 34 with UsernamePasswordCredential

use of org.apereo.cas.authentication.UsernamePasswordCredential in project cas by apereo.

the class CasKryoTranscoderTests method verifyEncodeDecodeTGTWithLinkedHashMap.

@Test
public void verifyEncodeDecodeTGTWithLinkedHashMap() {
    final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
    final TicketGrantingTicket expectedTGT = new MockTicketGrantingTicket(TGT_ID, userPassCredential, new LinkedHashMap<>(this.principalAttributes));
    expectedTGT.grantServiceTicket(ST_ID, null, null, false, true);
    final CachedData result = transcoder.encode(expectedTGT);
    assertEquals(expectedTGT, transcoder.decode(result));
    assertEquals(expectedTGT, transcoder.decode(result));
}
Also used : MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Credential(org.apereo.cas.authentication.Credential) CachedData(net.spy.memcached.CachedData) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Test(org.junit.Test)

Example 35 with UsernamePasswordCredential

use of org.apereo.cas.authentication.UsernamePasswordCredential in project cas by apereo.

the class PrincipalScimProvisionerAction method doExecute.

@Override
protected Event doExecute(final RequestContext requestContext) {
    final UsernamePasswordCredential c = (UsernamePasswordCredential) WebUtils.getCredential(requestContext);
    if (c == null) {
        LOGGER.debug("No credential found in the request context to provision");
        return success();
    }
    final Authentication authentication = WebUtils.getAuthentication(requestContext);
    if (authentication == null) {
        LOGGER.debug("No authentication found in the request context to provision");
        return success();
    }
    final Principal p = authentication.getPrincipal();
    LOGGER.debug("Starting to provision principal [{}]", p);
    final boolean res = this.scimProvisioner.create(p, c);
    if (res) {
        LOGGER.debug("Provisioning of principal [{}] executed successfully", p);
    } else {
        LOGGER.warn("Provisioning of principal [{}] has failed", p);
    }
    return success();
}
Also used : Authentication(org.apereo.cas.authentication.Authentication) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) Principal(org.apereo.cas.authentication.principal.Principal)

Aggregations

UsernamePasswordCredential (org.apereo.cas.authentication.UsernamePasswordCredential)96 Test (org.junit.Test)58 Credential (org.apereo.cas.authentication.Credential)25 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)22 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)17 HashMap (java.util.HashMap)10 LinkedHashMap (java.util.LinkedHashMap)9 CachedData (net.spy.memcached.CachedData)9 Authentication (org.apereo.cas.authentication.Authentication)9 AuthenticationResult (org.apereo.cas.authentication.AuthenticationResult)9 HttpBasedServiceCredential (org.apereo.cas.authentication.HttpBasedServiceCredential)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 Service (org.apereo.cas.authentication.principal.Service)8 ServiceTicket (org.apereo.cas.ticket.ServiceTicket)8 BasicCredentialMetaData (org.apereo.cas.authentication.BasicCredentialMetaData)6 DefaultAuthenticationBuilder (org.apereo.cas.authentication.DefaultAuthenticationBuilder)6 Assertion (org.apereo.cas.validation.Assertion)6 AuthenticationBuilder (org.apereo.cas.authentication.AuthenticationBuilder)5 PasswordChangeBean (org.apereo.cas.pm.PasswordChangeBean)5 ClassPathResource (org.springframework.core.io.ClassPathResource)5