Search in sources :

Example 1 with HttpClientHandler

use of org.forgerock.http.handler.HttpClientHandler in project OpenAM by OpenRock.

the class ScriptingGuiceModule method configure.

@Override
protected void configure() {
    bind(ScriptValidator.class).to(StandardScriptValidator.class);
    bind(Logger.class).annotatedWith(Names.named("ScriptLogger")).toInstance(logger);
    install(new FactoryModuleBuilder().implement(new TypeLiteral<ScriptingService>() {
    }, ScriptConfigurationService.class).build(new TypeLiteral<ScriptingServiceFactory>() {
    }));
    install(new FactoryModuleBuilder().implement(new TypeLiteral<ScriptingDataStore>() {
    }, ScriptConfigurationDataStore.class).build(new TypeLiteral<ScriptingDataStoreFactory>() {
    }));
    bind(StandardScriptEngineManager.class).annotatedWith(Names.named(AUTHENTICATION_SERVER_SIDE.name())).toInstance(new StandardScriptEngineManager());
    bind(StandardScriptEngineManager.class).annotatedWith(Names.named(POLICY_CONDITION.name())).toInstance(new StandardScriptEngineManager());
    bind(StandardScriptEngineManager.class).annotatedWith(Names.named(OIDC_CLAIMS.name())).toInstance(new StandardScriptEngineManager());
    bind(RestletHttpClient.class).annotatedWith(Names.named(SupportedScriptingLanguage.JAVASCRIPT.name())).to(JavaScriptHttpClient.class);
    bind(RestletHttpClient.class).annotatedWith(Names.named(SupportedScriptingLanguage.GROOVY.name())).to(GroovyHttpClient.class);
    try {
        bind(Client.class).annotatedWith(Names.named("ScriptingHttpClient")).toInstance(new Client(new HttpClientHandler()));
    } catch (HttpApplicationException e) {
        logger.error("Failed to create HttpClientHandler", e);
    }
}
Also used : StandardScriptEngineManager(org.forgerock.openam.scripting.StandardScriptEngineManager) ScriptingService(org.forgerock.openam.scripting.service.ScriptingService) TypeLiteral(com.google.inject.TypeLiteral) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) ScriptingDataStore(org.forgerock.openam.scripting.datastore.ScriptingDataStore) StandardScriptValidator(org.forgerock.openam.scripting.StandardScriptValidator) ScriptValidator(org.forgerock.openam.scripting.ScriptValidator) RestletHttpClient(org.forgerock.http.client.RestletHttpClient) JavaScriptHttpClient(org.forgerock.openam.scripting.api.http.JavaScriptHttpClient) Client(org.forgerock.http.Client) GroovyHttpClient(org.forgerock.openam.scripting.api.http.GroovyHttpClient) HttpClientHandler(org.forgerock.http.handler.HttpClientHandler) HttpApplicationException(org.forgerock.http.HttpApplicationException)

Example 2 with HttpClientHandler

use of org.forgerock.http.handler.HttpClientHandler in project OpenAM by OpenRock.

the class SelfServiceGuiceModule method configure.

@Override
protected void configure() {
    install(new FactoryModuleBuilder().implement(SnapshotTokenHandlerFactory.class, JwtSnapshotTokenHandlerFactory.class).build(new TypeLiteral<KeyPairInjector<SnapshotTokenHandlerFactory>>() {
    }));
    bind(ProcessStore.class).to(ProcessStoreImpl.class);
    bind(ServiceConfigProviderFactory.class).to(ServiceConfigProviderFactoryImpl.class);
    bind(SelfServiceFactory.class).to(SelfServiceFactoryImpl.class);
    bind(KbaResource.class);
    try {
        bind(Client.class).annotatedWith(SelfService.class).toInstance(new Client(new HttpClientHandler()));
    } catch (HttpApplicationException haE) {
        throw new HttpClientCreationException("Unable to create http client", haE);
    }
    // Registration CREST services
    expose(new TypeLiteral<SelfServiceRequestHandler<UserRegistrationConsoleConfig>>() {
    });
    expose(new TypeLiteral<SelfServiceRequestHandler<ForgottenPasswordConsoleConfig>>() {
    });
    expose(new TypeLiteral<SelfServiceRequestHandler<ForgottenUsernameConsoleConfig>>() {
    });
    expose(UserUpdateService.class);
    expose(KbaResource.class);
    // Exposed to be accessible to custom progress stages
    expose(ConnectionFactory.class).annotatedWith(SelfService.class);
    expose(Client.class).annotatedWith(SelfService.class);
}
Also used : ProcessStore(org.forgerock.selfservice.core.ProcessStore) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) SnapshotTokenHandlerFactory(org.forgerock.selfservice.core.snapshot.SnapshotTokenHandlerFactory) Resources.newInternalConnectionFactory(org.forgerock.json.resource.Resources.newInternalConnectionFactory) ConnectionFactory(org.forgerock.json.resource.ConnectionFactory) TypeLiteral(com.google.inject.TypeLiteral) ServiceConfigProviderFactory(org.forgerock.openam.selfservice.config.ServiceConfigProviderFactory) SelfService(org.forgerock.selfservice.core.annotations.SelfService) Client(org.forgerock.http.Client) HttpClientHandler(org.forgerock.http.handler.HttpClientHandler) HttpApplicationException(org.forgerock.http.HttpApplicationException)

Example 3 with HttpClientHandler

use of org.forgerock.http.handler.HttpClientHandler in project OpenAM by OpenRock.

the class LogWriter method sendEvent.

private static void sendEvent(String topic, JsonValue eventJson, String sessionId, String baseUrl) throws HttpApplicationException, URISyntaxException {
    Client client = new Client(new HttpClientHandler());
    Request request = new Request();
    request.setMethod("POST");
    if (eventJson.isDefined(EVENT_REALM)) {
        String realm = eventJson.get(EVENT_REALM).asString();
        baseUrl = baseUrl + "/json/realm-audit" + (realm.endsWith("/") ? realm : realm + "/");
    } else {
        baseUrl = baseUrl + "/json/global-audit/";
    }
    request.setUri(baseUrl + topic + "?_action=create");
    request.getHeaders().add(SystemProperties.get("com.iplanet.am.cookie.name"), sessionId);
    request.getHeaders().add(new AcceptApiVersionHeader(version(1), version(1)));
    request.getEntity().setJson(eventJson.getObject());
    client.send(request).then(WARN_OF_FAILURES_FUNCTION);
}
Also used : Request(org.forgerock.http.protocol.Request) Client(org.forgerock.http.Client) AcceptApiVersionHeader(org.forgerock.http.header.AcceptApiVersionHeader) HttpClientHandler(org.forgerock.http.handler.HttpClientHandler)

Aggregations

Client (org.forgerock.http.Client)3 HttpClientHandler (org.forgerock.http.handler.HttpClientHandler)3 TypeLiteral (com.google.inject.TypeLiteral)2 FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)2 HttpApplicationException (org.forgerock.http.HttpApplicationException)2 RestletHttpClient (org.forgerock.http.client.RestletHttpClient)1 AcceptApiVersionHeader (org.forgerock.http.header.AcceptApiVersionHeader)1 Request (org.forgerock.http.protocol.Request)1 ConnectionFactory (org.forgerock.json.resource.ConnectionFactory)1 Resources.newInternalConnectionFactory (org.forgerock.json.resource.Resources.newInternalConnectionFactory)1 ScriptValidator (org.forgerock.openam.scripting.ScriptValidator)1 StandardScriptEngineManager (org.forgerock.openam.scripting.StandardScriptEngineManager)1 StandardScriptValidator (org.forgerock.openam.scripting.StandardScriptValidator)1 GroovyHttpClient (org.forgerock.openam.scripting.api.http.GroovyHttpClient)1 JavaScriptHttpClient (org.forgerock.openam.scripting.api.http.JavaScriptHttpClient)1 ScriptingDataStore (org.forgerock.openam.scripting.datastore.ScriptingDataStore)1 ScriptingService (org.forgerock.openam.scripting.service.ScriptingService)1 ServiceConfigProviderFactory (org.forgerock.openam.selfservice.config.ServiceConfigProviderFactory)1 ProcessStore (org.forgerock.selfservice.core.ProcessStore)1 SelfService (org.forgerock.selfservice.core.annotations.SelfService)1