Search in sources :

Example 6 with Inject

use of javax.inject.Inject in project opennms by OpenNMS.

the class BeanUtils method assertAutowiring.

/**
     * Check that all fields that are marked with @Autowired are not null.
     * This will identify classes that have been loaded by Spring but have
     * not been autowired via {@code <context:annotation-config />}.
     */
public static <T> void assertAutowiring(T instance) {
    for (Field field : instance.getClass().getDeclaredFields()) {
        Autowired autowired = field.getAnnotation(Autowired.class);
        Inject inject = field.getAnnotation(Inject.class);
        Resource resource = field.getAnnotation(Resource.class);
        if ((autowired != null && autowired.required()) || (inject != null) || (resource != null)) {
            try {
                field.setAccessible(true);
                notNull(field.get(instance), "@Autowired/@Inject/@Resource field " + field.getName() + " cannot be null");
                LOG.debug("{} is not null", field.getName());
            } catch (IllegalAccessException e) {
                throw new IllegalArgumentException("Illegal access to @Autowired/@Resource field " + field.getName());
            }
        }
    }
}
Also used : Inject(javax.inject.Inject) Field(java.lang.reflect.Field) Autowired(org.springframework.beans.factory.annotation.Autowired) Resource(javax.annotation.Resource)

Example 7 with Inject

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

the class CoreRestGuiceModule method getAuthenticateHandler.

@Provides
@Named("AuthenticateHandler")
@Inject
Handler getAuthenticateHandler(@Named("InvalidRealmNames") Set<String> invalidRealms, HttpAccessAuditFilterFactory httpAuditFactory) {
    invalidRealms.add(firstPathSegment("authenticate"));
    org.forgerock.http.routing.Router authenticateVersionRouter = new org.forgerock.http.routing.Router();
    Handler authenticateHandlerV1 = Endpoints.from(AuthenticationServiceV1.class);
    Handler authenticateHandlerV2 = Endpoints.from(AuthenticationServiceV2.class);
    authenticateVersionRouter.addRoute(RouteMatchers.requestResourceApiVersionMatcher(version(1, 1)), authenticateHandlerV1);
    authenticateVersionRouter.addRoute(RouteMatchers.requestResourceApiVersionMatcher(version(2)), authenticateHandlerV2);
    return chainOf(authenticateVersionRouter, httpAuditFactory.createFilter(AUTHENTICATION));
}
Also used : ConsoleConfigHandler(org.forgerock.openam.sm.config.ConsoleConfigHandler) SmsRequestHandler(org.forgerock.openam.core.rest.sms.SmsRequestHandler) Handler(org.forgerock.http.Handler) Inject(javax.inject.Inject) Named(javax.inject.Named) Provides(com.google.inject.Provides)

Example 8 with Inject

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

use of javax.inject.Inject in project ACS by ACS-Community.

the class MyStatusBar method getNotified.

@Inject
@Optional
private void getNotified(@UIEventTopic(STATUS_BAR_TOPIC_ID) MessageWithTime msgWithTime) {
    if (slm != null) {
        String flashMsg = msgWithTime.msg;
        int timeSeconds = msgWithTime.timeSeconds;
        slm.setMessage(flashMsg);
        // TODO fix truncation of larger strings, e.g.
        //			slm.getControl().pack(true); ??
        clearFlashJob();
        msgRestoreJob = new Job(MyStatusBar.class.getSimpleName() + "RemoveFlashMessage") {

            @Override
            protected IStatus run(IProgressMonitor monitor) {
                // restore the previous message
                uiSync.syncExec(new Runnable() {

                    @Override
                    public void run() {
                        slm.setMessage(permanentMessage);
                    }
                });
                return Status.OK_STATUS;
            }
        };
        msgRestoreJob.schedule(timeSeconds * 1000);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) Job(org.eclipse.core.runtime.jobs.Job) Inject(javax.inject.Inject) Optional(org.eclipse.e4.core.di.annotations.Optional)

Example 10 with Inject

use of javax.inject.Inject in project che by eclipse.

the class DBInitializer method setUpInjectionManager.

@Inject
public void setUpInjectionManager(GuiceEntityListenerInjectionManager injManager, EntityManagerFactory emFactory) {
    final ServerSession session = emFactory.unwrap(ServerSession.class);
    session.setEntityListenerInjectionManager(injManager);
}
Also used : ServerSession(org.eclipse.persistence.sessions.server.ServerSession) Inject(javax.inject.Inject)

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