use of org.apereo.cas.services.DefaultRegisteredServiceProperty in project cas by apereo.
the class WsFederationNavigationControllerTests method verifyOperation.
@Test
public void verifyOperation() {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
RequestContextHolder.setRequestContext(context);
ExternalContextHolder.setExternalContext(context.getExternalContext());
request.setRemoteAddr("185.86.151.11");
request.setLocalAddr("185.88.151.11");
request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "Mozilla/5.0 (Windows NT 10.0; WOW64)");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val config = wsFederationConfigurations.toList().get(0);
val registeredService = RegisteredServiceTestUtils.getRegisteredService("https://wsfedservice");
registeredService.setProperties(Map.of(RegisteredServiceProperty.RegisteredServiceProperties.WSFED_RELYING_PARTY_ID.getPropertyName(), new DefaultRegisteredServiceProperty(config.getRelyingPartyIdentifier())));
val service = RegisteredServiceTestUtils.getService(registeredService.getServiceId());
servicesManager.save(registeredService);
request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, service.getId());
val id = config.getId();
request.addParameter(WsFederationNavigationController.PARAMETER_NAME, id);
val view = wsFederationNavigationController.redirectToProvider(request, response);
assertTrue(view instanceof RedirectView);
}
use of org.apereo.cas.services.DefaultRegisteredServiceProperty in project cas by apereo.
the class OidcRegisteredServiceJwtAccessTokenCipherExecutorTests method verifyEncKey.
@Test
public void verifyEncKey() throws Exception {
val service = getOidcRegisteredService("whatever");
service.getProperties().put(RegisteredServiceProperty.RegisteredServiceProperties.ACCESS_TOKEN_AS_JWT_ENCRYPTION_ENABLED.getPropertyName(), new DefaultRegisteredServiceProperty("true"));
val key = EncodingUtils.newJsonWebKey(2048);
service.getProperties().put(RegisteredServiceProperty.RegisteredServiceProperties.ACCESS_TOKEN_AS_JWT_ENCRYPTION_KEY.getPropertyName(), new DefaultRegisteredServiceProperty(key.toJson(JsonWebKey.OutputControlLevel.INCLUDE_PRIVATE)));
val at = getAccessToken();
val encoded = oidcRegisteredServiceJwtAccessTokenCipherExecutor.encode(at.getId(), Optional.of(service));
assertNotNull(encoded);
}
use of org.apereo.cas.services.DefaultRegisteredServiceProperty in project cas by apereo.
the class OidcRegisteredServiceJwtAccessTokenCipherExecutorTests method verifyNoEncKey.
@Test
public void verifyNoEncKey() throws Exception {
val service = getOidcRegisteredService("whatever");
service.getProperties().put(RegisteredServiceProperty.RegisteredServiceProperties.ACCESS_TOKEN_AS_JWT_ENCRYPTION_ENABLED.getPropertyName(), new DefaultRegisteredServiceProperty("true"));
val at = getAccessToken();
val encoded = oidcRegisteredServiceJwtAccessTokenCipherExecutor.encode(at.getId(), Optional.of(service));
assertNotNull(encoded);
}
use of org.apereo.cas.services.DefaultRegisteredServiceProperty in project cas by apereo.
the class OidcJwtAccessTokenEncoderTests method getRegisteredServiceForJwtAccessTokenWithKeys.
private OidcRegisteredService getRegisteredServiceForJwtAccessTokenWithKeys(final OAuth20AccessToken accessToken) {
val registeredService = getOidcRegisteredService(accessToken.getClientId());
registeredService.setJwtAccessToken(true);
val property = new DefaultRegisteredServiceProperty("false");
registeredService.setProperties(Map.of(RegisteredServiceProperty.RegisteredServiceProperties.ACCESS_TOKEN_AS_JWT_ENCRYPTION_ENABLED.getPropertyName(), property, RegisteredServiceProperty.RegisteredServiceProperties.ACCESS_TOKEN_AS_JWT_SIGNING_ENABLED.getPropertyName(), property));
this.servicesManager.save(registeredService);
return registeredService;
}
use of org.apereo.cas.services.DefaultRegisteredServiceProperty in project cas by apereo.
the class OidcRegisteredServiceJwtAccessTokenCipherExecutorNoCacheTests method verifyEmptyCacheOperation.
@Test
public void verifyEmptyCacheOperation() {
val id = UUID.randomUUID().toString();
val defaultCache = mock(LoadingCache.class);
when(defaultCache.get(any())).thenReturn(Optional.empty());
val serviceCache = mock(LoadingCache.class);
when(serviceCache.get(any())).thenReturn(Optional.empty());
val cipher = new OidcRegisteredServiceJwtAccessTokenCipherExecutor(defaultCache, serviceCache, OidcIssuerService.immutable(id));
val service = getOidcRegisteredService("whatever");
assertTrue(cipher.getSigningKey(service).isEmpty());
service.getProperties().put(RegisteredServiceProperty.RegisteredServiceProperties.ACCESS_TOKEN_AS_JWT_ENCRYPTION_ENABLED.getPropertyName(), new DefaultRegisteredServiceProperty("true"));
assertTrue(cipher.getEncryptionKey(service).isEmpty());
when(serviceCache.get(any())).thenReturn(Optional.of(new JsonWebKeySet(mock(PublicJsonWebKey.class))));
assertTrue(cipher.getEncryptionKey(service).isEmpty());
}
Aggregations