Search in sources :

Example 16 with Inject

use of javax.inject.Inject in project toydi by tokuhirom.

the class ToyDI method instantiateMembers.

public void instantiateMembers(Object object) throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
    for (final Field field : object.getClass().getDeclaredFields()) {
        Inject inject = field.getAnnotation(Inject.class);
        if (inject != null) {
            field.setAccessible(true);
            final Class<?> type = field.getType();
            Object value = this.getInstance(type);
            field.set(object, value);
        }
    }
}
Also used : Inject(javax.inject.Inject) Field(java.lang.reflect.Field)

Example 17 with Inject

use of javax.inject.Inject in project OpenAM by OpenRock.

the class CoreGuiceModule method getSessionBlacklist.

@Provides
@Singleton
@Inject
public static SessionBlacklist getSessionBlacklist(final CTSSessionBlacklist ctsBlacklist, final SessionServiceConfig serviceConfig) {
    if (!serviceConfig.isSessionBlacklistingEnabled()) {
        return NoOpSessionBlacklist.INSTANCE;
    }
    final long purgeDelayMs = serviceConfig.getSessionBlacklistPurgeDelay(TimeUnit.MILLISECONDS);
    final int cacheSize = serviceConfig.getSessionBlacklistCacheSize();
    final long pollIntervalMs = serviceConfig.getSessionBlacklistPollInterval(TimeUnit.MILLISECONDS);
    SessionBlacklist blacklist = ctsBlacklist;
    if (cacheSize > 0) {
        blacklist = new CachingSessionBlacklist(blacklist, cacheSize, purgeDelayMs);
    }
    if (pollIntervalMs > 0) {
        blacklist = new BloomFilterSessionBlacklist(blacklist, serviceConfig);
    }
    return blacklist;
}
Also used : BloomFilterSessionBlacklist(org.forgerock.openam.session.blacklist.BloomFilterSessionBlacklist) CachingSessionBlacklist(org.forgerock.openam.session.blacklist.CachingSessionBlacklist) CTSSessionBlacklist(org.forgerock.openam.session.blacklist.CTSSessionBlacklist) NoOpSessionBlacklist(org.forgerock.openam.session.blacklist.NoOpSessionBlacklist) SessionBlacklist(org.forgerock.openam.session.blacklist.SessionBlacklist) BloomFilterSessionBlacklist(org.forgerock.openam.session.blacklist.BloomFilterSessionBlacklist) CachingSessionBlacklist(org.forgerock.openam.session.blacklist.CachingSessionBlacklist) Inject(javax.inject.Inject) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 18 with Inject

use of javax.inject.Inject 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 19 with Inject

use of javax.inject.Inject in project OpenAM by OpenRock.

the class OAuth2GuiceModule method getOAuth2AuditContextProviders.

@Inject
@Provides
@Singleton
@Named(OAUTH2_AUDIT_CONTEXT_PROVIDERS)
Set<OAuth2AuditContextProvider> getOAuth2AuditContextProviders(TokenStore tokenStore, OAuth2RequestFactory<?, Request> requestFactory) {
    Set<OAuth2AuditContextProvider> set = new HashSet<>();
    set.add(new OAuth2AuditAccessTokenContextProvider(tokenStore, requestFactory));
    set.add(new OAuth2AuditRefreshTokenContextProvider(tokenStore, requestFactory));
    set.add(new OAuth2AuditSSOTokenContextProvider());
    return set;
}
Also used : OAuth2AuditRefreshTokenContextProvider(org.forgerock.openam.rest.audit.OAuth2AuditRefreshTokenContextProvider) OAuth2AuditContextProvider(org.forgerock.openam.rest.audit.OAuth2AuditContextProvider) OAuth2AuditAccessTokenContextProvider(org.forgerock.openam.rest.audit.OAuth2AuditAccessTokenContextProvider) OAuth2AuditSSOTokenContextProvider(org.forgerock.openam.rest.audit.OAuth2AuditSSOTokenContextProvider) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Named(javax.inject.Named) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 20 with Inject

use of javax.inject.Inject in project OpenAM by OpenRock.

the class SoapSTSInstanceModule method getSTSProperties.

/**
     * This method will provide the instance of the STSPropertiesMBean necessary both for the STS proper, and for the
     * CXF interceptor-set which enforces the SecurityPolicy bindings.
     *
     * It should be a singleton because this same instance is shared by all of the token operation instances, as well as
     * by the CXF interceptor-set
     */
@Provides
@Singleton
@Inject
STSPropertiesMBean getSTSProperties(Logger logger) {
    StaticSTSProperties stsProperties = new StaticSTSProperties();
    // KeystoreConfig may be null for a TLS-based SecurityPolicy binding, or for the AM-bare binding.
    if (stsInstanceConfig.getKeystoreConfig() != null) {
        stsProperties.setCallbackHandler(new SoapSTSCallbackHandler(stsInstanceConfig.getKeystoreConfig(), logger));
        Crypto crypto;
        try {
            crypto = CryptoFactory.getInstance(getEncryptionProperties());
        } catch (WSSecurityException e) {
            String message = "Exception caught initializing the CryptoFactory: " + e;
            logger.error(message, e);
            throw new IllegalStateException(message);
        }
        stsProperties.setSignatureCrypto(crypto);
        stsProperties.setEncryptionCrypto(crypto);
        stsProperties.setSignatureUsername(stsInstanceConfig.getKeystoreConfig().getSignatureKeyAlias());
    }
    return stsProperties;
}
Also used : Crypto(org.apache.ws.security.components.crypto.Crypto) SoapSTSCallbackHandler(org.forgerock.openam.sts.soap.SoapSTSCallbackHandler) WSSecurityException(org.apache.ws.security.WSSecurityException) StaticSTSProperties(org.apache.cxf.sts.StaticSTSProperties) Inject(javax.inject.Inject) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

Inject (javax.inject.Inject)23 Field (java.lang.reflect.Field)8 Provides (com.google.inject.Provides)6 ArrayList (java.util.ArrayList)5 Named (javax.inject.Named)5 Singleton (javax.inject.Singleton)3 Element (javax.lang.model.element.Element)2 Crypto (org.apache.ws.security.components.crypto.Crypto)2 Bundle (android.os.Bundle)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 TextView (android.widget.TextView)1 Toast (android.widget.Toast)1 RestLiInternalException (com.linkedin.restli.internal.server.RestLiInternalException)1 AnnotationSet (com.linkedin.restli.internal.server.model.AnnotationSet)1 Annotation (java.lang.annotation.Annotation)1 Constructor (java.lang.reflect.Constructor)1 Method (java.lang.reflect.Method)1 Type (java.lang.reflect.Type)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1