use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class CasKryoTranscoderTests method verifyEncodeDecodeTGTWithUnmodifiableSet.
@Test
public void verifyEncodeDecodeTGTWithUnmodifiableSet() {
val newAttributes = new HashMap<String, List<Object>>();
newAttributes.put(NICKNAME_KEY, List.of(CollectionUtils.wrapSet(NICKNAME_VALUE)));
val userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
val expectedTGT = new MockTicketGrantingTicket(TGT_ID, userPassCredential, newAttributes);
expectedTGT.grantServiceTicket(ST_ID, null, null, false, true);
val result = transcoder.encode(expectedTGT);
assertEquals(expectedTGT, transcoder.decode(result));
assertEquals(expectedTGT, transcoder.decode(result));
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class LdapPasswordManagementServiceTests method verifyPasswordChangedFails.
@Test
public void verifyPasswordChangedFails() {
val credential = new UsernamePasswordCredential("caspm", "123456");
val bean = new PasswordChangeRequest();
bean.setConfirmedPassword("Mellon");
bean.setPassword("Mellon");
bean.setUsername(credential.getUsername());
assertFalse(passwordChangeService.change(credential, bean));
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class RestPasswordManagementService method changeInternal.
@Override
public boolean changeInternal(final Credential c, final PasswordChangeRequest bean) {
val rest = properties.getRest();
if (StringUtils.isBlank(rest.getEndpointUrlChange())) {
return false;
}
val upc = (UsernamePasswordCredential) c;
val headers = new HttpHeaders();
headers.setAccept(CollectionUtils.wrap(MediaType.APPLICATION_JSON));
headers.put("username", CollectionUtils.wrap(upc.getUsername()));
headers.put("password", CollectionUtils.wrap(bean.getPassword()));
headers.put("oldPassword", CollectionUtils.wrap(upc.getPassword()));
val entity = new HttpEntity<>(headers);
val result = restTemplate.exchange(rest.getEndpointUrlChange(), HttpMethod.POST, entity, Boolean.class);
return result.getStatusCodeValue() == HttpStatus.OK.value() && result.hasBody() && Objects.requireNonNull(result.getBody()).booleanValue();
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class ScimV1PrincipalAttributeMapper method map.
/**
* Map.
*
* @param user the user
* @param p the p
* @param credential the credential
*/
public void map(final UserResource user, final Principal p, final Credential credential) {
user.setUserName(p.getId());
if (credential instanceof UsernamePasswordCredential) {
user.setPassword(UsernamePasswordCredential.class.cast(credential).getPassword());
}
user.setActive(Boolean.TRUE);
user.setNickName(getPrincipalAttributeValue(p, "nickName"));
user.setDisplayName(getPrincipalAttributeValue(p, "displayName"));
val name = new Name(getPrincipalAttributeValue(p, "formattedName"), getPrincipalAttributeValue(p, "familyName"), getPrincipalAttributeValue(p, "middleName"), getPrincipalAttributeValue(p, "givenName"), getPrincipalAttributeValue(p, "honorificPrefix"), getPrincipalAttributeValue(p, "honorificSuffix"));
user.setName(name);
val entry = new Entry(getPrincipalAttributeValue(p, "mail"), "primary");
user.setEmails(CollectionUtils.wrap(entry));
val entry2 = new Entry(getPrincipalAttributeValue(p, "phoneNumber"), "primary");
user.setPhoneNumbers(CollectionUtils.wrap(entry2));
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class SamlAuthenticationMetaDataPopulatorTests method verifyAuthenticationTypeFound.
@Test
public void verifyAuthenticationTypeFound() {
val credentials = new UsernamePasswordCredential();
val builder = CoreAuthenticationTestUtils.getAuthenticationBuilder();
this.populator.populateAttributes(builder, new DefaultAuthenticationTransactionFactory().newTransaction(credentials));
val auth = builder.build();
assertEquals(SamlAuthenticationMetaDataPopulator.AUTHN_METHOD_PASSWORD, auth.getAttributes().get(SamlAuthenticationMetaDataPopulator.ATTRIBUTE_AUTHENTICATION_METHOD).get(0));
}
Aggregations