use of io.jans.as.model.crypto.AbstractCryptoProvider in project jans by JanssenProject.
the class ConfigurationFactory method destroyCryptoProviderInstance.
private void destroyCryptoProviderInstance() {
log.trace("Destroyed crypto provider instance.");
AbstractCryptoProvider abstractCryptoProvider = abstractCryptoProviderInstance.get();
abstractCryptoProviderInstance.destroy(abstractCryptoProvider);
CryptoProviderFactory.reset();
}
use of io.jans.as.model.crypto.AbstractCryptoProvider in project jans by JanssenProject.
the class ConfigurationFactory method createFromLdap.
private boolean createFromLdap(boolean recoverFromFiles) {
log.info("Loading configuration from '{}' DB...", baseConfiguration.getString("persistence.type"));
try {
final io.jans.as.model.config.Conf c = loadConfigurationFromPersistence();
if (c != null) {
init(c);
// Destroy old configuration
if (this.loaded) {
destroy(AppConfiguration.class);
destroy(io.jans.as.model.config.StaticConfiguration.class);
destroy(io.jans.as.model.config.WebKeysConfiguration.class);
destroy(ErrorResponseFactory.class);
}
this.loaded = true;
configurationUpdateEvent.select(ConfigurationUpdate.Literal.INSTANCE).fire(conf);
destroyCryptoProviderInstance();
AbstractCryptoProvider newAbstractCryptoProvider = abstractCryptoProviderInstance.get();
cryptoProviderEvent.select(CryptoProviderEvent.Literal.INSTANCE).fire(newAbstractCryptoProvider);
return true;
}
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
}
if (recoverFromFiles) {
log.info("Unable to find configuration in LDAP, try to load configuration from file system... ");
if (createFromFile()) {
this.loadedFromLdap = false;
return true;
}
}
return false;
}
use of io.jans.as.model.crypto.AbstractCryptoProvider in project jans by JanssenProject.
the class SubjectIdentifierGenerator method generatePairwiseSubjectIdentifier.
public static String generatePairwiseSubjectIdentifier(String sectorIdentifier, String localAccountId, String key, String salt, AppConfiguration configuration) throws Exception {
AbstractCryptoProvider cryptoProvider = CryptoProviderFactory.getCryptoProvider(configuration);
String signingInput = sectorIdentifier + localAccountId + salt;
return cryptoProvider.sign(signingInput, null, key, SignatureAlgorithm.HS256);
}
use of io.jans.as.model.crypto.AbstractCryptoProvider in project jans by JanssenProject.
the class ConfigurationFactory method destroyCryptoProviderInstance.
public void destroyCryptoProviderInstance(Class<? extends AbstractCryptoProvider> clazz) {
AbstractCryptoProvider abstractCryptoProvider = abstractCryptoProviderInstance.get();
abstractCryptoProviderInstance.destroy(abstractCryptoProvider);
}
use of io.jans.as.model.crypto.AbstractCryptoProvider in project jans by JanssenProject.
the class OpenIDRequestObjectHttpTest method requestParameterMethodAlgNone.
@Parameters({ "userId", "userSecret", "redirectUri", "redirectUris", "sectorIdentifierUri" })
@Test
public void requestParameterMethodAlgNone(final String userId, final String userSecret, final String redirectUri, final String redirectUris, final String sectorIdentifierUri) {
try {
showTitle("requestParameterMethodAlgNone");
List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN);
// 1. Dynamic Client Registration
RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "jans test app", StringUtils.spaceSeparatedToList(redirectUris));
registerRequest.setResponseTypes(responseTypes);
registerRequest.setRequestObjectSigningAlg(SignatureAlgorithm.NONE);
registerRequest.addCustomAttribute("jansTrustedClnt", "true");
registerRequest.setSectorIdentifierUri(sectorIdentifierUri);
RegisterClient registerClient = new RegisterClient(registrationEndpoint);
registerClient.setRequest(registerRequest);
RegisterResponse response = registerClient.exec();
showClient(registerClient);
assertRegisterResponseOk(response, 201, true);
String clientId = response.getClientId();
// 2. Request authorization
AbstractCryptoProvider cryptoProvider = createCryptoProviderWithAllowedNone();
List<String> scopes = Arrays.asList("openid", "profile", "address", "email");
String nonce = UUID.randomUUID().toString();
String state = UUID.randomUUID().toString();
AuthorizationRequest request = new AuthorizationRequest(responseTypes, clientId, scopes, redirectUri, nonce);
request.setState(state);
request.setAuthUsername(userId);
request.setAuthPassword(userSecret);
request.getPrompts().add(Prompt.NONE);
JwtAuthorizationRequest jwtAuthorizationRequest = new JwtAuthorizationRequest(request, SignatureAlgorithm.NONE, cryptoProvider);
jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.NAME, ClaimValue.createNull()));
jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.NICKNAME, ClaimValue.createEssential(false)));
jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL, ClaimValue.createNull()));
jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL_VERIFIED, ClaimValue.createNull()));
jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.PICTURE, ClaimValue.createEssential(false)));
jwtAuthorizationRequest.addIdTokenClaim(new Claim(JwtClaimName.AUTHENTICATION_TIME, ClaimValue.createNull()));
jwtAuthorizationRequest.addIdTokenClaim(new Claim(JwtClaimName.AUTHENTICATION_CONTEXT_CLASS_REFERENCE, ClaimValue.createValueList(new String[] { ACR_VALUE })));
jwtAuthorizationRequest.getIdTokenMember().setMaxAge(86400);
String authJwt = jwtAuthorizationRequest.getEncodedJwt();
request.setRequest(authJwt);
AuthorizeClient authorizeClient = new AuthorizeClient(authorizationEndpoint);
authorizeClient.setRequest(request);
AuthorizationResponse response1 = authorizeClient.exec();
showClient(authorizeClient);
assertEquals(response1.getStatus(), 302, "Unexpected response code: " + response1.getStatus());
assertNotNull(response1.getLocation(), "The location is null");
assertNotNull(response1.getAccessToken(), "The accessToken is null");
assertNotNull(response1.getTokenType(), "The tokenType is null");
assertNotNull(response1.getIdToken(), "The idToken is null");
assertNotNull(response1.getState(), "The state is null");
String accessToken = response1.getAccessToken();
// 3. Request user info
UserInfoClient userInfoClient = new UserInfoClient(userInfoEndpoint);
UserInfoResponse response3 = userInfoClient.execUserInfo(accessToken);
showClient(userInfoClient);
assertUserInfoBasicMinimumResponseOk(response3, 200);
assertUserInfoPersonalDataNotNull(response3);
assertNotNull(response3.getClaim(JwtClaimName.ADDRESS));
} catch (Exception e) {
fail(e.getMessage(), e);
}
}
Aggregations