use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class AbstractServicesManager method load.
/**
* For the duration of the read, the cache store should not remain empty.
* Otherwise, lookup operations during that loading time window might produce
* unauthorized failure errors. Invalidation attempts must happen after the load
* to minimize chances of failures.
*/
@Override
public synchronized Collection<RegisteredService> load() {
LOGGER.trace("Loading services from [{}]", configurationContext.getServiceRegistry().getName());
val servicesMap = configurationContext.getServiceRegistry().load().stream().filter(this::supports).filter(this::validateAndFilterServiceByEnvironment).peek(this::loadInternal).collect(Collectors.toMap(r -> {
LOGGER.trace("Adding registered service [{}] with name [{}] and internal identifier [{}]", r.getServiceId(), r.getName(), r.getId());
return r.getId();
}, Function.identity(), (r, s) -> s));
configurationContext.getServicesCache().invalidateAll();
configurationContext.getServicesCache().putAll(servicesMap);
loadInternal();
publishEvent(new CasRegisteredServicesLoadedEvent(this, getAllServices()));
evaluateExpiredServiceDefinitions();
LOGGER.info("Loaded [{}] service(s) from [{}].", configurationContext.getServicesCache().asMap().size(), configurationContext.getServiceRegistry().getName());
return configurationContext.getServicesCache().asMap().values();
}
use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class DefaultCasAttributeEncoderTests method checkAttributesEncodedCorrectly.
@Test
public void checkAttributesEncodedCorrectly() {
final Service service = RegisteredServiceTestUtils.getService("testencryption");
final ProtocolAttributeEncoder encoder = new DefaultCasProtocolAttributeEncoder(this.servicesManager, NoOpCipherExecutor.getInstance());
final Map<String, Object> encoded = encoder.encodeAttributes(this.attributes, this.servicesManager.findServiceBy(service));
assertEquals(encoded.size(), this.attributes.size());
checkEncryptedValues(CasViewConstants.MODEL_ATTRIBUTE_NAME_PRINCIPAL_CREDENTIAL, encoded);
checkEncryptedValues(CasViewConstants.MODEL_ATTRIBUTE_NAME_PROXY_GRANTING_TICKET, encoded);
}
use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class DefaultCasAttributeEncoderTests method checkNoPublicKeyDefined.
@Test
public void checkNoPublicKeyDefined() {
final Service service = RegisteredServiceTestUtils.getService("testDefault");
final ProtocolAttributeEncoder encoder = new DefaultCasProtocolAttributeEncoder(this.servicesManager, NoOpCipherExecutor.getInstance());
final Map<String, Object> encoded = encoder.encodeAttributes(this.attributes, this.servicesManager.findServiceBy(service));
assertEquals(encoded.size(), this.attributes.size() - 2);
}
use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class LogoutManagerImpl method performLogoutForTicket.
private void performLogoutForTicket(final TicketGrantingTicket ticket, final List<LogoutRequest> logoutRequests) {
ticket.getServices().entrySet().stream().filter(entry -> entry.getValue() instanceof WebApplicationService).forEach(entry -> {
final Service service = entry.getValue();
LOGGER.debug("Handling single logout callback for [{}]", service);
final LogoutRequest logoutRequest = this.singleLogoutServiceMessageHandler.handle((WebApplicationService) service, entry.getKey());
if (logoutRequest != null) {
LOGGER.debug("Captured logout request [{}]", logoutRequest);
logoutRequests.add(logoutRequest);
}
});
final Collection<ProxyGrantingTicket> proxyGrantingTickets = ticket.getProxyGrantingTickets();
if (proxyGrantingTickets.isEmpty()) {
LOGGER.debug("There are no proxy-granting tickets associated with [{}] to process for single logout", ticket.getId());
} else {
proxyGrantingTickets.forEach(proxyGrantingTicket -> performLogoutForTicket(proxyGrantingTicket, logoutRequests));
}
}
use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class DefaultServicesManagerTests method verifyMatchesExistingService.
@Test
public void verifyMatchesExistingService() {
final RegexRegisteredService r = new RegexRegisteredService();
r.setId(1000);
r.setName(TEST);
r.setServiceId(TEST);
final Service service = new SimpleService(TEST);
final Service service2 = new SimpleService("fdfa");
this.defaultServicesManager.save(r);
assertTrue(this.defaultServicesManager.matchesExistingService(service));
assertEquals(r, this.defaultServicesManager.findServiceBy(service));
assertNull(this.defaultServicesManager.findServiceBy(service2));
}
Aggregations