Search in sources :

Example 1 with WebKeyStorage

use of org.gluu.oxauth.model.common.WebKeyStorage in project oxAuth by GluuFederation.

the class CryptoProviderFactory method getCryptoProvider.

public static AbstractCryptoProvider getCryptoProvider(AppConfiguration configuration) throws Exception {
    AbstractCryptoProvider cryptoProvider = null;
    WebKeyStorage webKeyStorage = configuration.getWebKeysStorage();
    if (webKeyStorage == null) {
        return null;
    }
    switch(webKeyStorage) {
        case KEYSTORE:
            cryptoProvider = getKeyStoreProvider(configuration);
            break;
        case PKCS11:
            cryptoProvider = new OxElevenCryptoProvider(configuration.getOxElevenGenerateKeyEndpoint(), configuration.getOxElevenSignEndpoint(), configuration.getOxElevenVerifySignatureEndpoint(), configuration.getOxElevenDeleteKeyEndpoint(), configuration.getOxElevenTestModeToken());
            break;
    }
    if (configuration.getKeyRegenerationEnabled()) {
        // set interval only if re-generation is enabled
        cryptoProvider.setKeyRegenerationIntervalInDays(configuration.getKeyRegenerationInterval() / 24);
    }
    return cryptoProvider;
}
Also used : WebKeyStorage(org.gluu.oxauth.model.common.WebKeyStorage)

Example 2 with WebKeyStorage

use of org.gluu.oxauth.model.common.WebKeyStorage in project oxAuth by GluuFederation.

the class CryptoProviderProviderFactory method getCryptoProvider.

@Produces
@ApplicationScoped
public AbstractCryptoProvider getCryptoProvider() throws Exception {
    log.debug("Started to create crypto provider");
    WebKeyStorage webKeyStorage = appConfiguration.getWebKeysStorage();
    if (webKeyStorage == null) {
        throw new RuntimeException("Failed to initialize cryptoProvider, cryptoProviderType is not specified!");
    }
    AbstractCryptoProvider cryptoProvider = org.gluu.oxauth.model.crypto.CryptoProviderFactory.getCryptoProvider(appConfiguration);
    if (cryptoProvider == null) {
        throw new RuntimeException("Failed to initialize cryptoProvider, cryptoProviderType is unsupported: " + webKeyStorage);
    }
    return cryptoProvider;
}
Also used : WebKeyStorage(org.gluu.oxauth.model.common.WebKeyStorage) AbstractCryptoProvider(org.gluu.oxauth.model.crypto.AbstractCryptoProvider) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Aggregations

WebKeyStorage (org.gluu.oxauth.model.common.WebKeyStorage)2 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Produces (javax.enterprise.inject.Produces)1 AbstractCryptoProvider (org.gluu.oxauth.model.crypto.AbstractCryptoProvider)1