use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class ConfirmConsentAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) {
final HttpServletRequest request = WebUtils.getHttpServletRequestFromExternalWebflowContext(requestContext);
final Service service = this.authenticationRequestServiceSelectionStrategies.resolveService(WebUtils.getService(requestContext));
final RegisteredService registeredService = getRegisteredServiceForConsent(requestContext, service);
final Authentication authentication = WebUtils.getAuthentication(requestContext);
final int optionValue = Integer.parseInt(request.getParameter("option"));
final ConsentOptions option = ConsentOptions.valueOf(optionValue);
final long reminder = Long.parseLong(request.getParameter("reminder"));
final String reminderTimeUnit = request.getParameter("reminderTimeUnit");
final ChronoUnit unit = ChronoUnit.valueOf(reminderTimeUnit.toUpperCase());
consentEngine.storeConsentDecision(service, registeredService, authentication, reminder, unit, option);
return new EventFactorySupport().success(this);
}
use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class ImmutableAssertionTests method verifyGetService.
@Test
public void verifyGetService() {
final Service service = RegisteredServiceTestUtils.getService();
final List<Authentication> list = new ArrayList<>();
list.add(CoreAuthenticationTestUtils.getAuthentication());
final Assertion assertion = new ImmutableAssertion(CoreAuthenticationTestUtils.getAuthentication(), list, false, service);
assertEquals(service, assertion.getService());
}
use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class AnonymousRegisteredServiceUsernameAttributeProviderTests method verifyPrincipalResolution.
@Test
public void verifyPrincipalResolution() {
final AnonymousRegisteredServiceUsernameAttributeProvider provider = new AnonymousRegisteredServiceUsernameAttributeProvider(new ShibbolethCompatiblePersistentIdGenerator(CASROX));
final Service service = mock(Service.class);
when(service.getId()).thenReturn("id");
final Principal principal = mock(Principal.class);
when(principal.getId()).thenReturn("uid");
final String id = provider.resolveUsername(principal, service, RegisteredServiceTestUtils.getRegisteredService("id"));
assertNotNull(id);
}
use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class AbstractTicketRegistry method deleteChildren.
/**
* Delete TGT's service tickets.
*
* @param ticket the ticket
* @return the count of tickets that were removed including child tickets and zero if the ticket was not deleted
*/
protected int deleteChildren(final TicketGrantingTicket ticket) {
final AtomicInteger count = new AtomicInteger(0);
final Map<String, Service> services = ticket.getServices();
if (services != null && !services.isEmpty()) {
services.keySet().stream().forEach(ticketId -> {
if (deleteSingleTicket(ticketId)) {
LOGGER.debug("Removed ticket [{}]", ticketId);
count.incrementAndGet();
} else {
LOGGER.debug("Unable to remove ticket [{}]", ticketId);
}
});
}
return count.intValue();
}
use of org.apereo.cas.authentication.principal.Service in project cas by apereo.
the class TicketGrantingTicketImplTests method verifyWebApplicationServices.
@Test
public void verifyWebApplicationServices() {
final Service testService = RegisteredServiceTestUtils.getService(TGT_ID);
final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, null, null, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
t.grantServiceTicket(ID_GENERATOR.getNewTicketId(ServiceTicket.PREFIX), testService, new NeverExpiresExpirationPolicy(), false, true);
Map<String, Service> services = t.getServices();
assertEquals(1, services.size());
final String ticketId = services.keySet().iterator().next();
assertEquals(testService, services.get(ticketId));
t.removeAllServices();
services = t.getServices();
assertEquals(0, services.size());
}
Aggregations