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));
}
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));
}
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));
}
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));
}
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();
}
Aggregations