Search in sources :

Example 6 with WebApplicationServiceFactory

use of org.apereo.cas.authentication.principal.WebApplicationServiceFactory in project cas by apereo.

the class WebUtilTests method verifyFindService.

@Test
public void verifyFindService() {
    final DefaultArgumentExtractor casArgumentExtractor = new DefaultArgumentExtractor(new WebApplicationServiceFactory());
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setParameter(CasProtocolConstants.PARAMETER_SERVICE, "test");
    final Service service = WebUtils.getService(Arrays.asList(casArgumentExtractor), request);
    assertNotNull(service);
    assertEquals("test", service.getId());
}
Also used : DefaultArgumentExtractor(org.apereo.cas.web.support.DefaultArgumentExtractor) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) WebApplicationServiceFactory(org.apereo.cas.authentication.principal.WebApplicationServiceFactory) Service(org.apereo.cas.authentication.principal.Service) Test(org.junit.Test)

Example 7 with WebApplicationServiceFactory

use of org.apereo.cas.authentication.principal.WebApplicationServiceFactory in project cas by apereo.

the class ManageRegisteredServicesMultiActionControllerTests method setUp.

@Before
public void setUp() throws Exception {
    this.servicesManager = new DefaultServicesManager(new InMemoryServiceRegistry());
    this.registeredServiceFactory = new DefaultRegisteredServiceFactory(new DefaultAccessStrategyMapper(), policyMapper, new DefaultProxyPolicyMapper(), new DefaultRegisteredServiceMapper(), new DefaultUsernameAttributeProviderMapper(), Collections.emptyList());
    this.controller = new ManageRegisteredServicesMultiActionController(this.servicesManager, this.registeredServiceFactory, new WebApplicationServiceFactory(), "https://cas.example.org");
}
Also used : WebApplicationServiceFactory(org.apereo.cas.authentication.principal.WebApplicationServiceFactory) DefaultAccessStrategyMapper(org.apereo.cas.mgmt.services.web.factory.DefaultAccessStrategyMapper) DefaultServicesManager(org.apereo.cas.services.DefaultServicesManager) DefaultRegisteredServiceFactory(org.apereo.cas.mgmt.services.web.factory.DefaultRegisteredServiceFactory) DefaultProxyPolicyMapper(org.apereo.cas.mgmt.services.web.factory.DefaultProxyPolicyMapper) DefaultRegisteredServiceMapper(org.apereo.cas.mgmt.services.web.factory.DefaultRegisteredServiceMapper) DefaultUsernameAttributeProviderMapper(org.apereo.cas.mgmt.services.web.factory.DefaultUsernameAttributeProviderMapper) ManageRegisteredServicesMultiActionController(org.apereo.cas.mgmt.services.web.ManageRegisteredServicesMultiActionController) InMemoryServiceRegistry(org.apereo.cas.services.InMemoryServiceRegistry) Before(org.junit.Before)

Example 8 with WebApplicationServiceFactory

use of org.apereo.cas.authentication.principal.WebApplicationServiceFactory in project cas by apereo.

the class OAuth20AccessTokenControllerTests method addRefreshToken.

private RefreshToken addRefreshToken(final Principal principal, final RegisteredService registeredService) {
    final Authentication authentication = getAuthentication(principal);
    final WebApplicationServiceFactory factory = new WebApplicationServiceFactory();
    final Service service = factory.createService(registeredService.getServiceId());
    final RefreshToken refreshToken = oAuthRefreshTokenFactory.create(service, authentication);
    oAuth20AccessTokenController.getTicketRegistry().addTicket(refreshToken);
    return refreshToken;
}
Also used : RefreshToken(org.apereo.cas.ticket.refreshtoken.RefreshToken) Authentication(org.apereo.cas.authentication.Authentication) WebApplicationServiceFactory(org.apereo.cas.authentication.principal.WebApplicationServiceFactory) OAuthRegisteredService(org.apereo.cas.support.oauth.services.OAuthRegisteredService) RegisteredService(org.apereo.cas.services.RegisteredService) Service(org.apereo.cas.authentication.principal.Service)

Example 9 with WebApplicationServiceFactory

use of org.apereo.cas.authentication.principal.WebApplicationServiceFactory in project cas by apereo.

the class RegisteredServiceTestUtils method getService.

public static AbstractWebApplicationService getService(final String name) {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("service", name);
    return (AbstractWebApplicationService) new WebApplicationServiceFactory().createService(request);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) WebApplicationServiceFactory(org.apereo.cas.authentication.principal.WebApplicationServiceFactory) AbstractWebApplicationService(org.apereo.cas.authentication.principal.AbstractWebApplicationService)

Example 10 with WebApplicationServiceFactory

use of org.apereo.cas.authentication.principal.WebApplicationServiceFactory in project cas by apereo.

the class SamlRegisteredServiceTests method checkPattern.

@Test
public void checkPattern() {
    final SamlRegisteredService service = new SamlRegisteredService();
    service.setName(SAML_SERVICE);
    service.setServiceId("^http://.+");
    service.setMetadataLocation(METADATA_LOCATION);
    final InMemoryServiceRegistry dao = new InMemoryServiceRegistry();
    dao.setRegisteredServices(Collections.singletonList(service));
    final DefaultServicesManager impl = new DefaultServicesManager(dao);
    impl.load();
    final RegisteredService s = impl.findServiceBy(new WebApplicationServiceFactory().createService("http://mmoayyed.unicon.net:8081/sp/saml/SSO"));
    assertNotNull(s);
}
Also used : RegisteredService(org.apereo.cas.services.RegisteredService) SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) WebApplicationServiceFactory(org.apereo.cas.authentication.principal.WebApplicationServiceFactory) DefaultServicesManager(org.apereo.cas.services.DefaultServicesManager) InMemoryServiceRegistry(org.apereo.cas.services.InMemoryServiceRegistry) Test(org.junit.Test)

Aggregations

WebApplicationServiceFactory (org.apereo.cas.authentication.principal.WebApplicationServiceFactory)14 Service (org.apereo.cas.authentication.principal.Service)6 Test (org.junit.Test)6 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)6 RegisteredService (org.apereo.cas.services.RegisteredService)5 Authentication (org.apereo.cas.authentication.Authentication)4 OAuthRegisteredService (org.apereo.cas.support.oauth.services.OAuthRegisteredService)4 Before (org.junit.Before)3 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)3 Principal (org.apereo.cas.authentication.principal.Principal)2 ManageRegisteredServicesMultiActionController (org.apereo.cas.mgmt.services.web.ManageRegisteredServicesMultiActionController)2 DefaultAccessStrategyMapper (org.apereo.cas.mgmt.services.web.factory.DefaultAccessStrategyMapper)2 DefaultProxyPolicyMapper (org.apereo.cas.mgmt.services.web.factory.DefaultProxyPolicyMapper)2 DefaultRegisteredServiceFactory (org.apereo.cas.mgmt.services.web.factory.DefaultRegisteredServiceFactory)2 DefaultUsernameAttributeProviderMapper (org.apereo.cas.mgmt.services.web.factory.DefaultUsernameAttributeProviderMapper)2 DefaultServicesManager (org.apereo.cas.services.DefaultServicesManager)2 InMemoryServiceRegistry (org.apereo.cas.services.InMemoryServiceRegistry)2 OAuthCode (org.apereo.cas.ticket.code.OAuthCode)2 RefreshToken (org.apereo.cas.ticket.refreshtoken.RefreshToken)2 AlwaysExpiresExpirationPolicy (org.apereo.cas.ticket.support.AlwaysExpiresExpirationPolicy)2