use of org.apereo.cas.services.UnauthorizedSsoServiceException in project cas by apereo.
the class RegisteredServiceAuthenticationPolicyResolver method supports.
@Override
public boolean supports(final AuthenticationTransaction transaction) {
val service = authenticationServiceSelectionPlan.resolveService(transaction.getService());
if (service != null) {
val registeredService = this.servicesManager.findServiceBy(service);
LOGGER.trace("Located registered service definition [{}] for this authentication transaction", registeredService);
if (registeredService == null || !registeredService.getAccessStrategy().isServiceAccessAllowed()) {
LOGGER.warn("Service [{}] is not allowed to use SSO.", service);
throw new UnauthorizedSsoServiceException();
}
val authenticationPolicy = registeredService.getAuthenticationPolicy();
if (authenticationPolicy != null) {
val criteria = authenticationPolicy.getCriteria();
return criteria != null;
}
}
return false;
}
use of org.apereo.cas.services.UnauthorizedSsoServiceException in project cas by apereo.
the class DefaultSecurityTokenServiceTokenFetcher method fetch.
@Override
public Optional<SecurityToken> fetch(final Service service, final String principalId) {
val resolvedService = this.selectionStrategy.resolveServiceFrom(service);
LOGGER.debug("Resolved service as [{}]", resolvedService);
if (resolvedService != null) {
val rp = this.servicesManager.findServiceBy(resolvedService, WSFederationRegisteredService.class);
if (rp == null || !rp.getAccessStrategy().isServiceAccessAllowed()) {
LOGGER.warn("Service [{}] is not allowed to use SSO.", rp);
throw new UnauthorizedSsoServiceException();
}
LOGGER.debug("Building security token service client for registered service [{}]", rp);
val sts = clientBuilder.buildClientForSecurityTokenRequests(rp);
return Optional.ofNullable(invokeSecurityTokenServiceForToken(rp, sts, principalId));
}
return Optional.empty();
}
Aggregations