use of org.apereo.cas.services.RegexRegisteredService in project cas by apereo.
the class ManageRegisteredServicesMultiActionControllerTests method verifyCustomComponents.
@Test
public void verifyCustomComponents() throws Exception {
// override the RegisteredServiceMapper
this.registeredServiceFactory = new DefaultRegisteredServiceFactory(new DefaultAccessStrategyMapper(), policyMapper, new DefaultProxyPolicyMapper(), new CustomRegisteredServiceMapper(), new DefaultUsernameAttributeProviderMapper(), Collections.emptyList());
this.controller = new ManageRegisteredServicesMultiActionController(this.servicesManager, this.registeredServiceFactory, new WebApplicationServiceFactory(), "https://cas.example.org");
final RegexRegisteredService r = new RegexRegisteredService();
r.setId(1200);
r.setName(NAME);
r.setDescription(UNIQUE_DESCRIPTION);
r.setServiceId("test");
r.setEvaluationOrder(2);
this.servicesManager.save(r);
final MockHttpServletResponse response = new MockHttpServletResponse();
final ModelAndView mv = this.controller.manage(response);
assertTrue(mv.getModel().containsKey("defaultServiceUrl"));
assertTrue(mv.getModel().containsKey("status"));
this.controller.getServices(response);
final String content = response.getContentAsString();
assertTrue(content.contains(SERVICES));
assertTrue(content.contains(UNIQUE_DESCRIPTION));
assertTrue(content.contains("customComponent1"));
assertTrue(content.contains("key2"));
}
use of org.apereo.cas.services.RegexRegisteredService in project cas by apereo.
the class BaseWSFederationRequestController method registerCallback.
/**
* Register callback service.
*
* @param callbackUrl the callback url
* @return the service
*/
private Service registerCallback(final String callbackUrl) {
final Service callbackService = this.webApplicationServiceFactory.createService(callbackUrl);
if (!this.servicesManager.matchesExistingService(callbackService)) {
LOGGER.debug("Initializing callback service [{}]", callbackService);
final RegexRegisteredService service = new RegexRegisteredService();
service.setId(Math.abs(new SecureRandom().nextLong()));
service.setEvaluationOrder(0);
service.setName(service.getClass().getSimpleName());
service.setDescription("WS-Federation Authentication Request");
service.setServiceId(callbackService.getId().concat(".+"));
LOGGER.debug("Saving callback service [{}] into the registry", service);
this.servicesManager.save(service);
this.servicesManager.load();
}
return callbackService;
}
use of org.apereo.cas.services.RegexRegisteredService in project cas by apereo.
the class RegisteredServiceSimpleFormControllerTests method verifyAddRegexRegisteredService.
@Test
public void verifyAddRegexRegisteredService() throws Exception {
final RegexRegisteredService svc = new RegexRegisteredService();
svc.setDescription(DESCRIPTION);
svc.setServiceId("^serviceId");
svc.setName(NAME);
svc.setId(1000);
svc.setEvaluationOrder(1000);
final RegisteredServiceEditBean.ServiceData data = registeredServiceFactory.createServiceData(svc);
this.controller.saveService(new MockHttpServletRequest(), new MockHttpServletResponse(), data, mock(BindingResult.class));
final Collection<RegisteredService> services = this.manager.getAllServices();
assertEquals(1, services.size());
this.manager.getAllServices().forEach(rs -> assertTrue(rs instanceof RegexRegisteredService));
}
use of org.apereo.cas.services.RegexRegisteredService in project cas by apereo.
the class LogoutActionTests method verifyLogoutForServiceWithFollowRedirectsAndMatchingService.
@Test
public void verifyLogoutForServiceWithFollowRedirectsAndMatchingService() throws Exception {
this.request.addParameter("service", TEST_SERVICE_ID);
final RegexRegisteredService impl = new RegexRegisteredService();
impl.setServiceId(TEST_SERVICE_ID);
impl.setName(TEST_SERVICE_ID);
this.serviceManager.save(impl);
final LogoutProperties properties = new LogoutProperties();
properties.setFollowServiceRedirects(true);
this.logoutAction = new LogoutAction(getWebApplicationServiceFactory(), this.serviceManager, properties);
final Event event = this.logoutAction.doExecute(this.requestContext);
assertEquals(CasWebflowConstants.TRANSITION_ID_FINISH, event.getId());
assertEquals(TEST_SERVICE_ID, this.requestContext.getFlowScope().get("logoutRedirectUrl"));
}
use of org.apereo.cas.services.RegexRegisteredService in project cas by apereo.
the class ServiceAuthorizationCheckTests method setUpMocks.
@Before
public void setUpMocks() {
final RegexRegisteredService authorizedRegisteredService = new RegexRegisteredService();
final RegexRegisteredService unauthorizedRegisteredService = new RegexRegisteredService();
unauthorizedRegisteredService.setAccessStrategy(new DefaultRegisteredServiceAccessStrategy(false, false));
final List<RegisteredService> list = new ArrayList<>();
list.add(authorizedRegisteredService);
list.add(unauthorizedRegisteredService);
when(this.servicesManager.findServiceBy(this.authorizedService)).thenReturn(authorizedRegisteredService);
when(this.servicesManager.findServiceBy(this.unauthorizedService)).thenReturn(unauthorizedRegisteredService);
when(this.servicesManager.findServiceBy(this.undefinedService)).thenReturn(null);
when(this.servicesManager.getAllServices()).thenReturn(list);
this.serviceAuthorizationCheck = new ServiceAuthorizationCheck(this.servicesManager, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
}
Aggregations