use of org.apereo.cas.authentication.principal.WebApplicationServiceFactory in project cas by apereo.
the class CentralAuthenticationServiceImplTests method getService.
private static Service getService(final String name) {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, name);
return new WebApplicationServiceFactory().createService(request);
}
use of org.apereo.cas.authentication.principal.WebApplicationServiceFactory in project cas by apereo.
the class InitialFlowSetupActionCookieTests method setUp.
@Before
public void setUp() throws Exception {
this.warnCookieGenerator = new CookieRetrievingCookieGenerator("warn", "", 2, false, null);
this.warnCookieGenerator.setCookiePath(StringUtils.EMPTY);
this.tgtCookieGenerator = new CookieRetrievingCookieGenerator("tgt", "", 2, false, null);
this.tgtCookieGenerator.setCookiePath(StringUtils.EMPTY);
final List<ArgumentExtractor> argExtractors = Collections.singletonList(new DefaultArgumentExtractor(new WebApplicationServiceFactory()));
final ServicesManager servicesManager = mock(ServicesManager.class);
when(servicesManager.findServiceBy(any(Service.class))).thenReturn(RegisteredServiceTestUtils.getRegisteredService("test"));
this.action = new InitialFlowSetupAction(argExtractors, servicesManager, tgtCookieGenerator, warnCookieGenerator, casProperties);
this.action.afterPropertiesSet();
}
use of org.apereo.cas.authentication.principal.WebApplicationServiceFactory in project cas by apereo.
the class OAuth20AccessTokenControllerTests method addCode.
private OAuthCode addCode(final Principal principal, final RegisteredService registeredService) {
final Authentication authentication = getAuthentication(principal);
final WebApplicationServiceFactory factory = new WebApplicationServiceFactory();
final Service service = factory.createService(registeredService.getServiceId());
final OAuthCode code = oAuthCodeFactory.create(service, authentication);
oAuth20AccessTokenController.getTicketRegistry().addTicket(code);
return code;
}
use of org.apereo.cas.authentication.principal.WebApplicationServiceFactory in project cas by apereo.
the class OAuth20AccessTokenControllerTests method verifyRefreshTokenExpiredToken.
@Test
public void verifyRefreshTokenExpiredToken() throws Exception {
final Principal principal = createPrincipal();
final RegisteredService registeredService = addRegisteredService();
final Authentication authentication = getAuthentication(principal);
final WebApplicationServiceFactory factory = new WebApplicationServiceFactory();
final Service service = factory.createService(registeredService.getServiceId());
final DefaultRefreshTokenFactory expiringRefreshTokenFactory = new DefaultRefreshTokenFactory(new AlwaysExpiresExpirationPolicy());
final RefreshToken refreshToken = expiringRefreshTokenFactory.create(service, authentication);
oAuth20AccessTokenController.getTicketRegistry().addTicket(refreshToken);
final MockHttpServletRequest mockRequest = new MockHttpServletRequest(GET, CONTEXT + OAuthConstants.ACCESS_TOKEN_URL);
mockRequest.setParameter(OAuthConstants.GRANT_TYPE, OAuth20GrantTypes.REFRESH_TOKEN.name().toLowerCase());
mockRequest.setParameter(OAuthConstants.CLIENT_ID, CLIENT_ID);
mockRequest.setParameter(OAuthConstants.CLIENT_SECRET, CLIENT_SECRET);
mockRequest.setParameter(OAuthConstants.REFRESH_TOKEN, refreshToken.getId());
final MockHttpServletResponse mockResponse = new MockHttpServletResponse();
requiresAuthenticationInterceptor.preHandle(mockRequest, mockResponse, null);
oAuth20AccessTokenController.handleRequestInternal(mockRequest, mockResponse);
assertEquals(HttpStatus.SC_BAD_REQUEST, mockResponse.getStatus());
assertEquals(ERROR_EQUALS + OAuthConstants.INVALID_GRANT, mockResponse.getContentAsString());
}
Aggregations