Search in sources :

Example 1 with RouteMatcher

use of org.forgerock.services.routing.RouteMatcher in project OpenAM by OpenRock.

the class CoreRestGuiceModule method configure.

@Override
protected void configure() {
    install(new FactoryModuleBuilder().implement(SmsRequestHandler.class, SmsRequestHandler.class).build(SmsRequestHandlerFactory.class));
    install(new FactoryModuleBuilder().implement(SmsCollectionProvider.class, SmsCollectionProvider.class).build(SmsCollectionProviderFactory.class));
    install(new FactoryModuleBuilder().implement(SmsSingletonProvider.class, SmsSingletonProvider.class).build(SmsSingletonProviderFactory.class));
    install(new FactoryModuleBuilder().implement(SmsGlobalSingletonProvider.class, SmsGlobalSingletonProvider.class).build(SmsGlobalSingletonProviderFactory.class));
    bind(DebugRecorder.class).to(DefaultDebugRecorder.class);
    MapBinder<RouteMatcher<Request>, Handler> chfEndpointHandlers = newMapBinder(binder(), new TypeLiteral<RouteMatcher<Request>>() {
    }, new TypeLiteral<Handler>() {
    });
    chfEndpointHandlers.addBinding(requestUriMatcher(EQUALS, "authenticate")).to(Key.get(Handler.class, Names.named("AuthenticateHandler")));
    MapBinder<Component, AbstractHttpAccessAuditFilter> httpAccessAuditFilterMapBinder = newMapBinder(binder(), Component.class, AbstractHttpAccessAuditFilter.class);
    httpAccessAuditFilterMapBinder.addBinding(AUTHENTICATION).to(AuthenticationAccessAuditFilter.class);
    Multibinder<UiRolePredicate> userUiRolePredicates = Multibinder.newSetBinder(binder(), UiRolePredicate.class);
    userUiRolePredicates.addBinding().to(SelfServiceUserUiRolePredicate.class);
    userUiRolePredicates.addBinding().to(GlobalAdminUiRolePredicate.class);
    userUiRolePredicates.addBinding().to(RealmAdminUiRolePredicate.class);
    MapBinder<MatchingResourcePath, CrestAuthorizationModule> smsGlobalAuthzModuleBinder = MapBinder.newMapBinder(binder(), MatchingResourcePath.class, CrestAuthorizationModule.class);
    smsGlobalAuthzModuleBinder.addBinding(resourcePath("realms")).to(AnyPrivilegeAuthzModule.class);
    smsGlobalAuthzModuleBinder.addBinding(resourcePath("authentication/modules/*")).to(PrivilegeWriteAndAnyPrivilegeReadOnlyAuthzModule.class);
    smsGlobalAuthzModuleBinder.addBinding(resourcePath("services/scripting")).to(PrivilegeWriteAndAnyPrivilegeReadOnlyAuthzModule.class);
    smsGlobalAuthzModuleBinder.addBinding(resourcePath("services/scripting/contexts")).to(PrivilegeWriteAndAnyPrivilegeReadOnlyAuthzModule.class);
}
Also used : FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) ConsoleConfigHandler(org.forgerock.openam.sm.config.ConsoleConfigHandler) SmsRequestHandler(org.forgerock.openam.core.rest.sms.SmsRequestHandler) Handler(org.forgerock.http.Handler) CrestAuthorizationModule(org.forgerock.authz.filter.crest.api.CrestAuthorizationModule) SmsGlobalSingletonProviderFactory(org.forgerock.openam.core.rest.sms.SmsGlobalSingletonProviderFactory) SmsRequestHandlerFactory(org.forgerock.openam.core.rest.sms.SmsRequestHandlerFactory) SmsCollectionProviderFactory(org.forgerock.openam.core.rest.sms.SmsCollectionProviderFactory) DebugRecorder(org.forgerock.openam.core.rest.record.DebugRecorder) DefaultDebugRecorder(org.forgerock.openam.core.rest.record.DefaultDebugRecorder) RouteMatcher(org.forgerock.services.routing.RouteMatcher) Component(org.forgerock.openam.audit.AuditConstants.Component) MatchingResourcePath(org.forgerock.openam.forgerockrest.utils.MatchingResourcePath) SmsSingletonProviderFactory(org.forgerock.openam.core.rest.sms.SmsSingletonProviderFactory) AbstractHttpAccessAuditFilter(org.forgerock.openam.audit.AbstractHttpAccessAuditFilter)

Example 2 with RouteMatcher

use of org.forgerock.services.routing.RouteMatcher in project OpenAM by OpenRock.

the class SmsRequestHandler method addServersRoutes.

private void addServersRoutes(ServiceManager sm, Map<String, Map<SmsRouteTree, Set<RouteMatcher<Request>>>> serviceRoutes) throws SSOException, SMSException {
    ServiceSchemaManager ssm = sm.getSchemaManager(ISAuthConstants.PLATFORM_SERVICE_NAME, DEFAULT_VERSION);
    Set<RouteMatcher<Request>> rootRoutes = new HashSet<>();
    serviceRoutes.get(ISAuthConstants.PLATFORM_SERVICE_NAME).put(routeTree, rootRoutes);
    addServersRoutes(ssm, rootRoutes, ConfigurationBase.CONFIG_SERVERS, ConfigurationBase.SUBSCHEMA_SERVER);
}
Also used : RouteMatcher(org.forgerock.services.routing.RouteMatcher) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) HashSet(java.util.HashSet)

Example 3 with RouteMatcher

use of org.forgerock.services.routing.RouteMatcher in project OpenAM by OpenRock.

the class SmsRequestHandler method createServices.

/**
     * Creates a {@link Router} for all the registered services, and then assigns that router to the instance so that
     * it will be used for all future requests.
     * @throws SMSException From downstream service manager layer.
     * @throws SSOException From downstream service manager layer.
     */
private synchronized void createServices() throws SSOException, SMSException {
    Map<String, Map<SmsRouteTree, Set<RouteMatcher<Request>>>> serviceRoutes = new HashMap<>();
    ServiceManager sm = getServiceManager();
    Set<String> serviceNames = sm.getServiceNames();
    for (String serviceName : serviceNames) {
        Map<SmsRouteTree, Set<RouteMatcher<Request>>> routes = addService(sm, serviceName, DEFAULT_VERSION);
        if (routes != null) {
            serviceRoutes.put(serviceName, routes);
        }
    }
    if (schemaType == SchemaType.GLOBAL) {
        addServersRoutes(sm, serviceRoutes);
    }
    this.serviceRoutes = serviceRoutes;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) CollectionUtils.asSet(org.forgerock.openam.utils.CollectionUtils.asSet) HashMap(java.util.HashMap) ServiceManager(com.sun.identity.sm.ServiceManager) RouteMatcher(org.forgerock.services.routing.RouteMatcher) SmsRouteTree(org.forgerock.openam.core.rest.sms.SmsRouteTree) CreateRequest(org.forgerock.json.resource.CreateRequest) DeleteRequest(org.forgerock.json.resource.DeleteRequest) QueryRequest(org.forgerock.json.resource.QueryRequest) ActionRequest(org.forgerock.json.resource.ActionRequest) ReadRequest(org.forgerock.json.resource.ReadRequest) UpdateRequest(org.forgerock.json.resource.UpdateRequest) Request(org.forgerock.json.resource.Request) PatchRequest(org.forgerock.json.resource.PatchRequest) Map(java.util.Map) HashMap(java.util.HashMap) Collections.emptyMap(java.util.Collections.emptyMap)

Aggregations

RouteMatcher (org.forgerock.services.routing.RouteMatcher)3 HashSet (java.util.HashSet)2 FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)1 ServiceManager (com.sun.identity.sm.ServiceManager)1 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)1 Collections.emptyMap (java.util.Collections.emptyMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 CrestAuthorizationModule (org.forgerock.authz.filter.crest.api.CrestAuthorizationModule)1 Handler (org.forgerock.http.Handler)1 ActionRequest (org.forgerock.json.resource.ActionRequest)1 CreateRequest (org.forgerock.json.resource.CreateRequest)1 DeleteRequest (org.forgerock.json.resource.DeleteRequest)1 PatchRequest (org.forgerock.json.resource.PatchRequest)1 QueryRequest (org.forgerock.json.resource.QueryRequest)1 ReadRequest (org.forgerock.json.resource.ReadRequest)1 Request (org.forgerock.json.resource.Request)1 UpdateRequest (org.forgerock.json.resource.UpdateRequest)1 AbstractHttpAccessAuditFilter (org.forgerock.openam.audit.AbstractHttpAccessAuditFilter)1