use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class WSFederationAuthenticationServiceSelectionStrategy method getReplyAsParameter.
private static Optional<NameValuePair> getReplyAsParameter(final Service service) {
try {
final URIBuilder builder = new URIBuilder(service.getId());
final Optional param = builder.getQueryParams().stream().filter(p -> p.getName().equals(WSFederationConstants.WREPLY)).findFirst();
return param;
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return Optional.empty();
}
use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class WSFederationMetadataUIAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) {
Service service = WebUtils.getService(requestContext);
if (service != null) {
service = serviceSelectionStrategy.resolveServiceFrom(service);
final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(service, registeredService);
if (registeredService instanceof WSFederationRegisteredService) {
final WSFederationRegisteredService wsfed = WSFederationRegisteredService.class.cast(registeredService);
WebUtils.putServiceUserInterfaceMetadata(requestContext, new DefaultRegisteredServiceUserInterfaceInfo(wsfed));
}
}
return success();
}
use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class SecurityTokenServiceAuthenticationMetaDataPopulator method populateAttributes.
@Override
public void populateAttributes(final AuthenticationBuilder builder, final AuthenticationTransaction transaction) {
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);
}
}
use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class WsFederationAction method prepareLoginViewWithWsFederationClients.
private void prepareLoginViewWithWsFederationClients(final RequestContext context) {
final List<WsFedClient> clients = new ArrayList<>();
final HttpServletRequest request = WebUtils.getHttpServletRequestFromExternalWebflowContext(context);
final Service service = (Service) context.getFlowScope().get(CasProtocolConstants.PARAMETER_SERVICE);
this.configurations.forEach(cfg -> {
final WsFedClient c = new WsFedClient();
c.setName(cfg.getName());
final String id = UUID.randomUUID().toString();
final String rpId = wsFederationHelper.getRelyingPartyIdentifier(service, cfg);
c.setAuthorizationUrl(cfg.getAuthorizationUrl(rpId, id));
c.setReplyingPartyId(rpId);
c.setId(id);
c.setRedirectUrl(WsFederationNavigationController.getRelativeRedirectUrlFor(cfg, service, request));
c.setAutoRedirect(cfg.isAutoRedirect());
clients.add(c);
});
context.getFlowScope().put("wsfedUrls", clients);
}
use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class LogoutManagerImplTests method setUp.
@Before
public void setUp() {
when(client.isValidEndPoint(any(String.class))).thenReturn(true);
when(client.isValidEndPoint(any(URL.class))).thenReturn(true);
when(client.sendMessageToEndPoint(any(HttpMessage.class))).thenReturn(true);
singleLogoutServiceMessageHandler = new DefaultSingleLogoutServiceMessageHandler(client, new SamlCompliantLogoutMessageCreator(), servicesManager, new DefaultSingleLogoutServiceLogoutUrlBuilder(), true, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
final Map<String, Service> services = new HashMap<>();
this.simpleWebApplicationServiceImpl = RegisteredServiceTestUtils.getService(URL);
services.put(ID, this.simpleWebApplicationServiceImpl);
when(this.tgt.getServices()).thenReturn(services);
this.logoutManager = new LogoutManagerImpl(new SamlCompliantLogoutMessageCreator(), singleLogoutServiceMessageHandler, false);
this.registeredService = RegisteredServiceTestUtils.getRegisteredService(URL);
when(servicesManager.findServiceBy(this.simpleWebApplicationServiceImpl)).thenReturn(this.registeredService);
}
Aggregations