use of org.apereo.cas.authentication.UsernamePasswordCredential in project cas by apereo.
the class X509CredentialFactoryTests method createDefaultCredential.
@Test
public void createDefaultCredential() {
final MultiValueMap<String, String> requestBody = new LinkedMultiValueMap<>();
requestBody.add("username", "name");
requestBody.add("password", "passwd");
final Credential cred = factory.fromRequestBody(requestBody);
assertTrue(cred instanceof UsernamePasswordCredential);
}
use of org.apereo.cas.authentication.UsernamePasswordCredential in project cas by apereo.
the class PrincipalBearingCredentialsAuthenticationHandlerTests method verifySupports.
@Test
public void verifySupports() {
final PrincipalBearingCredential credentials = new PrincipalBearingCredential(new DefaultPrincipalFactory().createPrincipal("scott"));
assertTrue(this.handler.supports(credentials));
assertFalse(this.handler.supports(new UsernamePasswordCredential()));
}
use of org.apereo.cas.authentication.UsernamePasswordCredential in project cas by apereo.
the class KryoTranscoderTests method verifyEncodeDecodeTGTImpl.
@Test
public void verifyEncodeDecodeTGTImpl() throws Exception {
final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
final AuthenticationBuilder bldr = new DefaultAuthenticationBuilder(new DefaultPrincipalFactory().createPrincipal("user", new HashMap<>(this.principalAttributes)));
bldr.setAttributes(new HashMap<>(this.principalAttributes));
bldr.setAuthenticationDate(ZonedDateTime.now());
bldr.addCredential(new BasicCredentialMetaData(userPassCredential));
bldr.addFailure("error", AccountNotFoundException.class);
bldr.addSuccess("authn", new DefaultHandlerResult(new AcceptUsersAuthenticationHandler(""), new BasicCredentialMetaData(userPassCredential)));
final TicketGrantingTicket expectedTGT = new TicketGrantingTicketImpl(TGT_ID, RegisteredServiceTestUtils.getService(), null, bldr.build(), new NeverExpiresExpirationPolicy());
final ServiceTicket ticket = expectedTGT.grantServiceTicket(ST_ID, RegisteredServiceTestUtils.getService(), new NeverExpiresExpirationPolicy(), false, true);
CachedData result = transcoder.encode(expectedTGT);
final TicketGrantingTicket resultTicket = (TicketGrantingTicket) transcoder.decode(result);
assertEquals(expectedTGT, resultTicket);
result = transcoder.encode(ticket);
final ServiceTicket resultStTicket = (ServiceTicket) transcoder.decode(result);
assertEquals(ticket, resultStTicket);
}
use of org.apereo.cas.authentication.UsernamePasswordCredential in project cas by apereo.
the class KryoTranscoderTests method verifyEncodeDecodeTGTWithSingleton.
@Test
public void verifyEncodeDecodeTGTWithSingleton() throws Exception {
final Map<String, Object> newAttributes = new HashMap<>();
newAttributes.put(NICKNAME_KEY, Collections.singleton(NICKNAME_VALUE));
final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
final TicketGrantingTicket expectedTGT = new MockTicketGrantingTicket(TGT_ID, userPassCredential, newAttributes);
expectedTGT.grantServiceTicket(ST_ID, null, null, false, true);
assertEquals(expectedTGT, transcoder.decode(transcoder.encode(expectedTGT)));
}
use of org.apereo.cas.authentication.UsernamePasswordCredential in project cas by apereo.
the class KryoTranscoderTests method verifyEncodeDecodeTGTWithUnmodifiableSet.
@Test
public void verifyEncodeDecodeTGTWithUnmodifiableSet() throws Exception {
final Map<String, Object> newAttributes = new HashMap<>();
final Set<String> values = new HashSet<>();
values.add(NICKNAME_VALUE);
newAttributes.put(NICKNAME_KEY, Collections.unmodifiableSet(values));
final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
final TicketGrantingTicket expectedTGT = new MockTicketGrantingTicket(TGT_ID, userPassCredential, newAttributes);
expectedTGT.grantServiceTicket(ST_ID, null, null, false, true);
assertEquals(expectedTGT, transcoder.decode(transcoder.encode(expectedTGT)));
}
Aggregations