Search in sources :

Example 36 with Provides

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

the class CoreGuiceModule method getSAML2TokenRepository.

@Provides
@Singleton
SAML2TokenRepository getSAML2TokenRepository() {
    final String DEFAULT_REPOSITORY_CLASS = "org.forgerock.openam.cts.impl.SAML2CTSPersistentStore";
    final String REPOSITORY_CLASS_PROPERTY = "com.sun.identity.saml2.plugins.SAML2RepositoryImpl";
    final String CTS_SAML2_REPOSITORY_CLASS_NAME = SystemPropertiesManager.get(REPOSITORY_CLASS_PROPERTY, DEFAULT_REPOSITORY_CLASS);
    SAML2TokenRepository result;
    try {
        // Use Guice to create class to get all of its dependency goodness
        result = InjectorHolder.getInstance(Class.forName(CTS_SAML2_REPOSITORY_CLASS_NAME).asSubclass(SAML2TokenRepository.class));
    } catch (ClassNotFoundException e) {
        throw new IllegalStateException(e);
    }
    return result;
}
Also used : SAML2TokenRepository(org.forgerock.openam.federation.saml2.SAML2TokenRepository) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 37 with Provides

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

the class RestGuiceModule method getInternalCrestRealmRouter.

@Provides
@Named("InternalCrestRouter")
@Singleton
Router getInternalCrestRealmRouter(@Named("CrestRealmRouter") Router crestRealmRouter) {
    Router internalCrestRouter = new Router();
    internalCrestRouter.setDefaultRoute(crestRealmRouter);
    return internalCrestRouter;
}
Also used : Router(org.forgerock.json.resource.Router) Named(javax.inject.Named) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 38 with Provides

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

the class ForgerockRestGuiceModule method getPrivilegeDefinitions.

@Provides
@Singleton
public Map<String, PrivilegeDefinition> getPrivilegeDefinitions() {
    final Map<String, PrivilegeDefinition> definitions = new HashMap<>();
    final PrivilegeDefinition evaluateDefinition = PrivilegeDefinition.getInstance("evaluate", PrivilegeDefinition.Action.READ);
    definitions.put("evaluate", evaluateDefinition);
    definitions.put("evaluateTree", evaluateDefinition);
    definitions.put("copy", PrivilegeDefinition.getInstance("modify", PrivilegeDefinition.Action.MODIFY));
    definitions.put("move", PrivilegeDefinition.getInstance("modify", PrivilegeDefinition.Action.MODIFY));
    definitions.put("schema", PrivilegeDefinition.getInstance("schema", PrivilegeDefinition.Action.READ));
    definitions.put("validate", PrivilegeDefinition.getInstance("validate", PrivilegeDefinition.Action.READ));
    definitions.put("template", PrivilegeDefinition.getInstance("template", PrivilegeDefinition.Action.READ));
    definitions.put("getPropertyNames", PrivilegeDefinition.getInstance("getPropertyNames", PrivilegeDefinition.Action.READ));
    definitions.put("getProperty", PrivilegeDefinition.getInstance("getProperty", PrivilegeDefinition.Action.READ));
    definitions.put("setProperty", PrivilegeDefinition.getInstance("setProperty", PrivilegeDefinition.Action.MODIFY));
    definitions.put("deleteProperty", PrivilegeDefinition.getInstance("deleteProperty", PrivilegeDefinition.Action.MODIFY));
    return definitions;
}
Also used : HashMap(java.util.HashMap) PrivilegeDefinition(org.forgerock.openam.rest.authz.PrivilegeDefinition) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 39 with Provides

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

the class SoapSTSInstanceModule method getProperties.

/*
     */
/**
     * These properties configure the web-service deployment, and are primarily referenced by the ws-security interceptors
     * deployed as part of CXF. These interceptors are responsible for enforcing the security-policy bindings protecting
     * the STS. To this end, various crypto objects are required, and the TokenValidators for the configured validated
     * token types are plugged-in.
     * @param wssValidatorFactory the factory class which will produce the wss Validator instances to enforce SecurityPolicy bindings
     * @param logger for error state logging
     * @return the Map that serves to configure the web-service deployment
     * @throws WSSecurityException In case an unexpected TokenType is encountered, or a TokenValidator could not be created.
     */
@Provides
@Named(AMSTSConstants.STS_WEB_SERVICE_PROPERTIES)
@Inject
Map<String, Object> getProperties(WSSValidatorFactory wssValidatorFactory, Logger logger) throws WSSecurityException {
    Map<String, Object> properties = new HashMap<>();
    // KeystoreConfig may be null for a TLS-based SecurityPolicy binding, or for the AM-bare binding.
    if (stsInstanceConfig.getKeystoreConfig() != null) {
        properties.put(SecurityConstants.CALLBACK_HANDLER, new SoapSTSCallbackHandler(stsInstanceConfig.getKeystoreConfig(), logger));
        Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties());
        properties.put(SecurityConstants.ENCRYPT_CRYPTO, crypto);
        properties.put(SecurityConstants.SIGNATURE_CRYPTO, crypto);
        properties.put(SecurityConstants.SIGNATURE_USERNAME, stsInstanceConfig.getKeystoreConfig().getSignatureKeyAlias());
    }
    properties.put("faultStackTraceEnabled", "true");
    properties.put("exceptionMessageCauseEnabled", "true");
    processSecurityPolicyTokenValidatorConfiguration(properties, wssValidatorFactory, logger);
    return properties;
}
Also used : Crypto(org.apache.ws.security.components.crypto.Crypto) HashMap(java.util.HashMap) SoapSTSCallbackHandler(org.forgerock.openam.sts.soap.SoapSTSCallbackHandler) Inject(javax.inject.Inject) Named(javax.inject.Named) Provides(com.google.inject.Provides)

Example 40 with Provides

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

the class RadiusServerGuiceModule method getRadiusServiceConfigManger.

/**
     * Guice provider for the ServiceConfigManager.
     *
     * @return a ServiceConfigurationManager that can be used
     * @throws RadiusLifecycleException - when the service config manager can not be obtained.
     */
@Provides
@Named("RadiusServer")
protected ServiceConfigManager getRadiusServiceConfigManger() throws RadiusLifecycleException {
    ServiceConfigManager mgr = null;
    // get a ServiceConfigManager for our service
    try {
        final SSOToken admTk = AccessController.doPrivileged(AdminTokenAction.getInstance());
        mgr = new ServiceConfigManager(RadiusServerConstants.RADIUS_SERVICE_NAME, admTk);
    } catch (final Exception e) {
        throw new RadiusLifecycleException("Could not obtain ServiceConfigManger for the RADIUS service.", e);
    }
    return mgr;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) Named(javax.inject.Named) 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