use of org.apereo.cas.authentication.UsernamePasswordCredential in project cas by apereo.
the class RejectUsersAuthenticationHandlerTests method verifyPassesNullUserName.
@Test
public void verifyPassesNullUserName() throws Exception {
final UsernamePasswordCredential c = new UsernamePasswordCredential();
c.setUsername(null);
c.setPassword("user");
this.thrown.expect(AccountNotFoundException.class);
this.authenticationHandler.authenticate(c);
}
use of org.apereo.cas.authentication.UsernamePasswordCredential in project cas by apereo.
the class RejectUsersAuthenticationHandlerTests method verifyPassesNullUserNameAndPassword.
@Test
public void verifyPassesNullUserNameAndPassword() throws Exception {
this.thrown.expect(AccountNotFoundException.class);
this.authenticationHandler.authenticate(new UsernamePasswordCredential());
}
use of org.apereo.cas.authentication.UsernamePasswordCredential in project cas by apereo.
the class OAuth20UserAuthenticator method validate.
@Override
public void validate(final UsernamePasswordCredentials credentials, final WebContext context) throws CredentialsException {
final UsernamePasswordCredential casCredential = new UsernamePasswordCredential(credentials.getUsername(), credentials.getPassword());
try {
final String clientId = context.getRequestParameter(OAuth20Constants.CLIENT_ID);
final Service service = this.webApplicationServiceFactory.createService(clientId);
final RegisteredService registeredService = OAuth20Utils.getRegisteredOAuthServiceByClientId(this.servicesManager, clientId);
RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(registeredService);
final AuthenticationResult authenticationResult = this.authenticationSystemSupport.handleAndFinalizeSingleAuthenticationTransaction(null, casCredential);
final Authentication authentication = authenticationResult.getAuthentication();
final Principal principal = authentication.getPrincipal();
final OAuthUserProfile profile = new OAuthUserProfile();
final String id = registeredService.getUsernameAttributeProvider().resolveUsername(principal, service, registeredService);
LOGGER.debug("Created profile id [{}]", id);
profile.setId(id);
final Map<String, Object> attributes = registeredService.getAttributeReleasePolicy().getAttributes(principal, service, registeredService);
profile.addAttributes(attributes);
LOGGER.debug("Authenticated user profile [{}]", profile);
credentials.setUserProfile(profile);
} catch (final Exception e) {
throw new CredentialsException("Cannot login user using CAS internal authentication", e);
}
}
use of org.apereo.cas.authentication.UsernamePasswordCredential in project cas by apereo.
the class JcifsSpnegoAuthenticationHandlerTests method verifySupports.
@Test
public void verifySupports() {
final AuthenticationHandler authenticationHandler = new JcifsSpnegoAuthenticationHandler("", null, null, new MockJcifsAuthentication(), true, true);
assertFalse(authenticationHandler.supports(null));
assertTrue(authenticationHandler.supports(new SpnegoCredential(new byte[] { 0, 1, 2 })));
assertFalse(authenticationHandler.supports(new UsernamePasswordCredential()));
}
use of org.apereo.cas.authentication.UsernamePasswordCredential in project cas by apereo.
the class SurrogateWebflowEventResolver method loadSurrogates.
private boolean loadSurrogates(final RequestContext requestContext) {
final Credential c = WebUtils.getCredential(requestContext);
if (c instanceof UsernamePasswordCredential) {
final String username = c.getId();
final Collection<String> surrogates = surrogateService.getEligibleAccountsForSurrogateToProxy(username);
if (!surrogates.isEmpty()) {
surrogates.add(username);
requestContext.getFlowScope().put("surrogates", surrogates);
return true;
}
}
return false;
}
Aggregations