Search in sources :

Example 96 with Provides

use of com.google.inject.Provides in project keywhiz by square.

the class CryptoModule method baseDerivationKey.

@Provides
@Derivation
@Singleton
SecretKey baseDerivationKey(@Derivation Provider provider) {
    String alias = keyStoreConfig.alias();
    char[] password = keyStoreConfig.resolvedPassword().toCharArray();
    KeyStore keyStore;
    try (InputStream inputStream = keyStoreConfig.openPath()) {
        keyStore = KeyStore.getInstance(keyStoreConfig.type(), provider);
        keyStore.load(inputStream, password);
        return (SecretKey) keyStore.getKey(alias, password);
    } catch (CertificateException | IOException | KeyStoreException | NoSuchAlgorithmException | UnrecoverableKeyException e) {
        logger.error("Error loading base derivation key: {}", e.getMessage(), e);
        throw Throwables.propagate(e);
    }
}
Also used : SecretKey(javax.crypto.SecretKey) UnrecoverableKeyException(java.security.UnrecoverableKeyException) InputStream(java.io.InputStream) CertificateException(java.security.cert.CertificateException) IOException(java.io.IOException) KeyStoreException(java.security.KeyStoreException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) KeyStore(java.security.KeyStore) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 97 with Provides

use of com.google.inject.Provides in project EventHub by Codecademy.

the class UserStorageModule method getIdMap.

@Provides
public IdMap getIdMap(@Named("eventhub.userstorage.directory") String userStorageDirectory) throws IOException {
    String filename = userStorageDirectory + "/id_map.db";
    //noinspection ResultOfMethodCallIgnored
    new File(userStorageDirectory).mkdirs();
    Options options = new Options();
    options.createIfMissing(true);
    return IdMap.create(new DB(JniDBFactory.factory.open(new File(filename), options)));
}
Also used : Options(org.iq80.leveldb.Options) File(java.io.File) DB(com.codecademy.eventhub.base.DB) Provides(com.google.inject.Provides)

Example 98 with Provides

use of com.google.inject.Provides in project EventHub by Codecademy.

the class PropertiesIndexModule method getPropertiesIndex.

@Provides
public PropertiesIndex getPropertiesIndex(@Named("eventhub.directory") String eventIndexDirectory) throws IOException {
    //noinspection ResultOfMethodCallIgnored
    new File(eventIndexDirectory).mkdirs();
    Options options = new Options();
    options.createIfMissing(true);
    return new PropertiesIndex(new DB(JniDBFactory.factory.open(new File(eventIndexDirectory + "/properties_index.db"), options)));
}
Also used : Options(org.iq80.leveldb.Options) File(java.io.File) DB(com.codecademy.eventhub.base.DB) Provides(com.google.inject.Provides)

Example 99 with Provides

use of com.google.inject.Provides in project OpenAM by OpenRock.

the class CoreRestGuiceModule method getSessionResourceAuthzModule.

@Provides
@Inject
public AnyOfAuthzModule getSessionResourceAuthzModule(SSOTokenManager ssoTokenManager, PrivilegeAuthzModule privilegeAuthzModule, AdminOnlyAuthzModule adminOnlyAuthzModule) {
    SessionResourceAuthzModule sessionResourceAuthzModule = new SessionResourceAuthzModule(ssoTokenManager);
    List<CrestAuthorizationModule> authzList = new ArrayList<>(3);
    authzList.add(adminOnlyAuthzModule);
    authzList.add(privilegeAuthzModule);
    authzList.add(sessionResourceAuthzModule);
    return new AnyOfAuthzModule(authzList);
}
Also used : SessionResourceAuthzModule(org.forgerock.openam.core.rest.session.SessionResourceAuthzModule) ArrayList(java.util.ArrayList) AnyOfAuthzModule(org.forgerock.openam.core.rest.session.AnyOfAuthzModule) CrestAuthorizationModule(org.forgerock.authz.filter.crest.api.CrestAuthorizationModule) Inject(javax.inject.Inject) Provides(com.google.inject.Provides)

Example 100 with Provides

use of com.google.inject.Provides in project OpenAM by OpenRock.

the class CoreRestGuiceModule method getServerAttributeTitles.

@Provides
@Singleton
@Named("ServerAttributeTitles")
public Properties getServerAttributeTitles() throws IOException {
    Properties titleProperties = new Properties();
    titleProperties.load(getClass().getClassLoader().getResourceAsStream("amConsole.properties"));
    return titleProperties;
}
Also used : SystemProperties(com.iplanet.am.util.SystemProperties) Properties(java.util.Properties) Named(javax.inject.Named) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

Provides (com.google.inject.Provides)126 Singleton (javax.inject.Singleton)36 AbstractModule (com.google.inject.AbstractModule)26 Singleton (com.google.inject.Singleton)24 Injector (com.google.inject.Injector)22 Named (javax.inject.Named)17 LazySingleton (io.druid.guice.LazySingleton)12 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 Named (com.google.inject.name.Named)8 IOException (java.io.IOException)7 File (java.io.File)6 ArrayList (java.util.ArrayList)6 Inject (javax.inject.Inject)6 Properties (java.util.Properties)5 Client (javax.ws.rs.client.Client)5 Test (org.junit.Test)5 Key (com.google.inject.Key)4 ExecutorService (java.util.concurrent.ExecutorService)4 ConfigModule (co.cask.cdap.common.guice.ConfigModule)3 Binder (com.google.inject.Binder)3