Search in sources :

Example 1 with SamlMetadataUIInfo

use of org.apereo.cas.support.saml.mdui.SamlMetadataUIInfo in project cas by apereo.

the class SamlIdPMetadataUIAction method doExecute.

@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
    final Service service = this.serviceSelectionStrategy.resolveService(WebUtils.getService(requestContext));
    final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
    RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(service, registeredService);
    if (registeredService instanceof SamlRegisteredService) {
        final SamlRegisteredService samlService = SamlRegisteredService.class.cast(registeredService);
        final Optional<SamlRegisteredServiceServiceProviderMetadataFacade> adaptor = SamlRegisteredServiceServiceProviderMetadataFacade.get(resolver, samlService, service.getId());
        if (!adaptor.isPresent()) {
            throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, "Cannot find metadata linked to " + service.getId());
        }
        final SamlMetadataUIInfo mdui = MetadataUIUtils.locateMetadataUserInterfaceForEntityId(adaptor.get().getEntityDescriptor(), service.getId(), registeredService);
        WebUtils.putServiceUserInterfaceMetadata(requestContext, mdui);
    }
    return success();
}
Also used : RegisteredService(org.apereo.cas.services.RegisteredService) SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) SamlMetadataUIInfo(org.apereo.cas.support.saml.mdui.SamlMetadataUIInfo) SamlRegisteredServiceServiceProviderMetadataFacade(org.apereo.cas.support.saml.services.idp.metadata.SamlRegisteredServiceServiceProviderMetadataFacade) SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) RegisteredService(org.apereo.cas.services.RegisteredService) SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) Service(org.apereo.cas.authentication.principal.Service) UnauthorizedServiceException(org.apereo.cas.services.UnauthorizedServiceException)

Example 2 with SamlMetadataUIInfo

use of org.apereo.cas.support.saml.mdui.SamlMetadataUIInfo in project cas by apereo.

the class SamlMetadataUIParserAction method doExecute.

@Override
public Event doExecute(final RequestContext requestContext) throws Exception {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(requestContext);
    final String entityId = request.getParameter(this.entityIdParameterName);
    if (StringUtils.isBlank(entityId)) {
        LOGGER.debug("No entity id found for parameter [{}]", this.entityIdParameterName);
        return success();
    }
    final WebApplicationService service = this.serviceFactory.createService(entityId);
    final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
    if (registeredService == null || !registeredService.getAccessStrategy().isServiceAccessAllowed()) {
        LOGGER.debug("Entity id [{}] is not recognized/allowed by the CAS service registry", entityId);
        if (registeredService != null) {
            WebUtils.putUnauthorizedRedirectUrlIntoFlowScope(requestContext, registeredService.getAccessStrategy().getUnauthorizedRedirectUrl());
        }
        throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, "Entity [" + entityId + "] not recognized");
    }
    final SamlMetadataUIInfo mdui = MetadataUIUtils.locateMetadataUserInterfaceForEntityId(this.metadataAdapter, entityId, registeredService);
    WebUtils.putServiceUserInterfaceMetadata(requestContext, mdui);
    return success();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) WebApplicationService(org.apereo.cas.authentication.principal.WebApplicationService) RegisteredService(org.apereo.cas.services.RegisteredService) SamlMetadataUIInfo(org.apereo.cas.support.saml.mdui.SamlMetadataUIInfo) UnauthorizedServiceException(org.apereo.cas.services.UnauthorizedServiceException)

Aggregations

RegisteredService (org.apereo.cas.services.RegisteredService)2 UnauthorizedServiceException (org.apereo.cas.services.UnauthorizedServiceException)2 SamlMetadataUIInfo (org.apereo.cas.support.saml.mdui.SamlMetadataUIInfo)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Service (org.apereo.cas.authentication.principal.Service)1 WebApplicationService (org.apereo.cas.authentication.principal.WebApplicationService)1 SamlRegisteredService (org.apereo.cas.support.saml.services.SamlRegisteredService)1 SamlRegisteredServiceServiceProviderMetadataFacade (org.apereo.cas.support.saml.services.idp.metadata.SamlRegisteredServiceServiceProviderMetadataFacade)1