Search in sources :

Example 96 with Service

use of org.apereo.cas.authentication.principal.Service in project cas by apereo.

the class WSFederationValidateRequestController method handleLogoutRequest.

private void handleLogoutRequest(final WSFederationRequest fedRequest, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    String logoutUrl = casProperties.getServer().getLogoutUrl();
    if (StringUtils.isNotBlank(fedRequest.getWreply())) {
        final Service service = webApplicationServiceFactory.createService(fedRequest.getWreply());
        final WSFederationRegisteredService registeredService = getWsFederationRegisteredService(service);
        LOGGER.debug("Invoking logout operation for request [{}], redirecting next to [{}] matched against [{}]", fedRequest, fedRequest.getWreply(), registeredService);
        final String logoutParam = casProperties.getLogout().getRedirectParameter();
        logoutUrl = logoutUrl.concat("?").concat(logoutParam).concat("=").concat(service.getId());
    }
    final AuthenticationRedirectStrategy authenticationRedirectStrategy = new DefaultAuthenticationRedirectStrategy();
    authenticationRedirectStrategy.redirect(request, response, logoutUrl);
}
Also used : DefaultAuthenticationRedirectStrategy(org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy) DefaultAuthenticationRedirectStrategy(org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy) AuthenticationRedirectStrategy(org.jasig.cas.client.authentication.AuthenticationRedirectStrategy) WSFederationRegisteredService(org.apereo.cas.ws.idp.services.WSFederationRegisteredService) WebApplicationService(org.apereo.cas.authentication.principal.WebApplicationService) WSFederationRegisteredService(org.apereo.cas.ws.idp.services.WSFederationRegisteredService) Service(org.apereo.cas.authentication.principal.Service)

Example 97 with Service

use of org.apereo.cas.authentication.principal.Service in project cas by apereo.

the class SecurityTokenServiceAuthenticationPostProcessor method process.

@Override
public void process(final AuthenticationTransaction transaction, final AuthenticationBuilder builder) {
    if (!this.selectionStrategy.supports(transaction.getService())) {
        return;
    }
    final Service service = this.selectionStrategy.resolveServiceFrom(transaction.getService());
    if (service != null) {
        final WSFederationRegisteredService rp = this.servicesManager.findServiceBy(service, WSFederationRegisteredService.class);
        if (rp == null || !rp.getAccessStrategy().isServiceAccessAllowed()) {
            LOGGER.warn("Service [{}] is not allowed to use SSO.", rp);
            throw new UnauthorizedSsoServiceException();
        }
        final SecurityTokenServiceClient sts = clientBuilder.buildClientForSecurityTokenRequests(rp);
        invokeSecurityTokenServiceForToken(transaction, builder, rp, sts);
    }
}
Also used : UnauthorizedSsoServiceException(org.apereo.cas.services.UnauthorizedSsoServiceException) WSFederationRegisteredService(org.apereo.cas.ws.idp.services.WSFederationRegisteredService) WSFederationRegisteredService(org.apereo.cas.ws.idp.services.WSFederationRegisteredService) Service(org.apereo.cas.authentication.principal.Service)

Aggregations

Service (org.apereo.cas.authentication.principal.Service)97 Test (org.junit.Test)45 RegisteredService (org.apereo.cas.services.RegisteredService)35 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)33 AuthenticationResult (org.apereo.cas.authentication.AuthenticationResult)30 ServiceTicket (org.apereo.cas.ticket.ServiceTicket)30 Authentication (org.apereo.cas.authentication.Authentication)24 AbstractWebApplicationService (org.apereo.cas.authentication.principal.AbstractWebApplicationService)16 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)16 CentralAuthenticationService (org.apereo.cas.CentralAuthenticationService)14 WebApplicationService (org.apereo.cas.authentication.principal.WebApplicationService)14 Assertion (org.apereo.cas.validation.Assertion)10 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)10 NeverExpiresExpirationPolicy (org.apereo.cas.ticket.support.NeverExpiresExpirationPolicy)9 Credential (org.apereo.cas.authentication.Credential)8 UnauthorizedServiceException (org.apereo.cas.services.UnauthorizedServiceException)8 OAuthRegisteredService (org.apereo.cas.support.oauth.services.OAuthRegisteredService)7 TicketGrantingTicketImpl (org.apereo.cas.ticket.TicketGrantingTicketImpl)7 AuthenticationException (org.apereo.cas.authentication.AuthenticationException)6 AuthenticationResultBuilder (org.apereo.cas.authentication.AuthenticationResultBuilder)6