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();
}
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();
}
Aggregations