use of org.apereo.cas.services.RegisteredServiceAccessStrategy in project cas by apereo.
the class CoreAuthenticationTestUtils method getRegisteredService.
public static RegisteredService getRegisteredService(final String url) {
final RegisteredService service = mock(RegisteredService.class);
when(service.getServiceId()).thenReturn(url);
when(service.getName()).thenReturn("service name");
when(service.getId()).thenReturn(Long.MAX_VALUE);
when(service.getDescription()).thenReturn("service description");
final RegisteredServiceAccessStrategy access = mock(RegisteredServiceAccessStrategy.class);
when(access.isServiceAccessAllowed()).thenReturn(true);
when(service.getAccessStrategy()).thenReturn(access);
return service;
}
use of org.apereo.cas.services.RegisteredServiceAccessStrategy in project cas by apereo.
the class InitialFlowSetupAction method configureWebflowContextForService.
private void configureWebflowContextForService(final RequestContext context) {
final Service service = WebUtils.getService(this.argumentExtractors, context);
if (service != null) {
LOGGER.debug("Placing service in context scope: [{}]", service.getId());
final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
if (registeredService != null && registeredService.getAccessStrategy().isServiceAccessAllowed()) {
LOGGER.debug("Placing registered service [{}] with id [{}] in context scope", registeredService.getServiceId(), registeredService.getId());
WebUtils.putRegisteredService(context, registeredService);
final RegisteredServiceAccessStrategy accessStrategy = registeredService.getAccessStrategy();
if (accessStrategy.getUnauthorizedRedirectUrl() != null) {
LOGGER.debug("Placing registered service's unauthorized redirect url [{}] with id [{}] in context scope", accessStrategy.getUnauthorizedRedirectUrl(), registeredService.getServiceId());
WebUtils.putUnauthorizedRedirectUrl(context, accessStrategy.getUnauthorizedRedirectUrl());
}
}
} else if (!casProperties.getSso().isMissingService()) {
LOGGER.warn("No service authentication request is available at [{}]. CAS is configured to disable the flow.", WebUtils.getHttpServletRequest(context).getRequestURL());
throw new NoSuchFlowExecutionException(context.getFlowExecutionContext().getKey(), new UnauthorizedServiceException("screen.service.required.message", "Service is required"));
}
WebUtils.putService(context, service);
}
use of org.apereo.cas.services.RegisteredServiceAccessStrategy in project cas by apereo.
the class DefaultRegisteredServiceFactory method createRegisteredService.
@Override
public RegisteredService createRegisteredService(final ServiceData data) {
final RegisteredService svc = this.registeredServiceMapper.toRegisteredService(data);
if (svc instanceof AbstractRegisteredService) {
final AbstractRegisteredService absSvc = (AbstractRegisteredService) svc;
final RegisteredServiceAccessStrategy accessStrategy = this.accessStrategyMapper.toAccessStrategy(data);
if (accessStrategy != null) {
absSvc.setAccessStrategy(accessStrategy);
}
final RegisteredServiceUsernameAttributeProvider usernameAttributeProvider = this.usernameAttributeProviderMapper.toUsernameAttributeProvider(data);
if (usernameAttributeProvider != null) {
absSvc.setUsernameAttributeProvider(usernameAttributeProvider);
}
final RegisteredServiceProxyPolicy proxyPolicy = this.proxyPolicyMapper.toProxyPolicy(data);
if (proxyPolicy != null) {
absSvc.setProxyPolicy(proxyPolicy);
}
final RegisteredServiceAttributeReleasePolicy attrPolicy = this.attributeReleasePolicyMapper.toAttributeReleasePolicy(data);
if (attrPolicy != null) {
absSvc.setAttributeReleasePolicy(attrPolicy);
}
final RegisteredServiceMultifactorPolicy mfaPolicy = this.multifactorAuthenticationMapper.toMultifactorPolicy(data);
if (mfaPolicy != null) {
absSvc.setMultifactorPolicy(mfaPolicy);
}
}
return svc;
}
Aggregations