Source:
public void validate(final UsernamePasswordCredentials credentials, final WebContext context) throws CredentialsException { val casCredential = new UsernamePasswordCredential(credentials.getUsername(), credentials.getPassword()); try { val clientIdAndSecret = getClientIdAndClientSecret(context); if (clientIdAndSecret == null || StringUtils.isBlank(clientIdAndSecret.getKey())) { throw new CredentialsException("No client credentials could be identified in this request"); } val clientId = clientIdAndSecret.getKey(); val registeredService = OAuth20Utils.getRegisteredOAuthServiceByClientId(this.servicesManager, clientId); RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(registeredService); val clientSecret = clientIdAndSecret.getRight(); if (!OAuth20Utils.checkClientSecret(registeredService, clientSecret, registeredServiceCipherExecutor)) { throw new CredentialsException("Client Credentials provided for registered service is not valid" + registeredService.getName()); } val redirectUri = context.getRequestParameter(OAuth20Constants.REDIRECT_URI) .map(String::valueOf).orElse(StringUtils.EMPTY); val service = StringUtils.isNotBlank(redirectUri) ? this.webApplicationServiceFactory.createService(redirectUri) : null; val authenticationResult = authenticationSystemSupport.handleAndFinalizeSingleAuthenticationTransaction(service, casCredential); if (authenticationResult == null) { throw new CredentialsException("Could not authenticate the provided credentials"); } val authentication = authenticationResult.getAuthentication(); val principal = authentication.getPrincipal(); val attributes = registeredService.getAttributeReleasePolicy().getAttributes(principal, service, registeredService); val profile = new CommonProfile(); val id = registeredService.getUsernameAttributeProvider().resolveUsername(principal, service, registeredService); LOGGER.debug("Created profile id [{}]", id); profile.setId(id); profile.addAttributes((Map) 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); } }

Target:
public void validate(final UsernamePasswordCredentials credentials, final WebContext context) throws CredentialsException { val casCredential = new UsernamePasswordCredential(credentials.getUsername(), credentials.getPassword()); try { val clientIdAndSecret = getClientIdAndClientSecret(context); if (clientIdAndSecret == null || StringUtils.isBlank(clientIdAndSecret.getKey())) { throw new CredentialsException("No client credentials could be identified in this request"); } val clientId = clientIdAndSecret.getKey(); val registeredService = OAuth20Utils.getRegisteredOAuthServiceByClientId(this.servicesManager, clientId); RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(registeredService); val clientSecret = clientIdAndSecret.getRight(); if (!OAuth20Utils.checkClientSecret(registeredService, clientSecret, registeredServiceCipherExecutor)) { throw new CredentialsException("Client Credentials provided is not valid for registered service: " + registeredService.getName()); } val redirectUri = context.getRequestParameter(OAuth20Constants.REDIRECT_URI) .map(String::valueOf).orElse(StringUtils.EMPTY); val service = StringUtils.isNotBlank(redirectUri) ? this.webApplicationServiceFactory.createService(redirectUri) : null; val authenticationResult = authenticationSystemSupport.handleAndFinalizeSingleAuthenticationTransaction(service, casCredential); if (authenticationResult == null) { throw new CredentialsException("Could not authenticate the provided credentials"); } val authentication = authenticationResult.getAuthentication(); val principal = authentication.getPrincipal(); val attributes = registeredService.getAttributeReleasePolicy().getAttributes(principal, service, registeredService); val profile = new CommonProfile(); val id = registeredService.getUsernameAttributeProvider().resolveUsername(principal, service, registeredService); LOGGER.debug("Created profile id [{}]", id); profile.setId(id); profile.addAttributes((Map) 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); } }