use of org.forgerock.util.Function in project OpenAM by OpenRock.
the class SchemaResourceNamesStep method perform.
@Override
public void perform() throws UpgradeException {
for (Map.Entry<String, Function<Document, Boolean, XPathExpressionException>> service : serviceModifications.entrySet()) {
try {
long startTime = System.currentTimeMillis();
UpgradeProgress.reportStart(PROGRESS, service.getKey());
DEBUG.message("Found resource names for {}. Applying now.", service.getKey());
new ServiceSchemaManager(service.getKey(), getAdminToken()).modifySchema(service.getValue());
DEBUG.message("Completed ({}ms)", System.currentTimeMillis() - startTime);
UpgradeProgress.reportEnd("upgrade.success");
} catch (XPathExpressionException | SMSException | SSOException e) {
throw new UpgradeException(e);
}
}
}
use of org.forgerock.util.Function in project OpenAM by OpenRock.
the class CoreGuiceModule method configure.
@Override
protected void configure() {
bind(new AdminTokenType()).toProvider(new AdminTokenProvider()).in(Singleton.class);
bind(ServiceManagementDAO.class).to(ServiceManagementDAOWrapper.class).in(Singleton.class);
bind(DNWrapper.class).in(Singleton.class);
bind(URLValidator.class).toInstance(URLValidator.getInstance());
bind(new TypeLiteral<TokenAdapter<JsonValue>>() {
}).annotatedWith(Names.named(OAuth2Constants.CoreTokenParams.OAUTH_TOKEN_ADAPTER)).to(OAuthAdapter.class);
bind(DSConfigMgr.class).toProvider(new Provider<DSConfigMgr>() {
public DSConfigMgr get() {
try {
return DSConfigMgr.getDSConfigMgr();
} catch (LDAPServiceException e) {
throw new IllegalStateException(e);
}
}
}).in(Singleton.class);
bind(SSOTokenManager.class).toProvider(new Provider<SSOTokenManager>() {
public SSOTokenManager get() {
try {
return SSOTokenManager.getInstance();
} catch (SSOException e) {
throw new IllegalStateException(e);
}
}
}).in(Singleton.class);
/**
* Core Token Service bindings are divided into a number of logical groups.
*/
// CTS General
bind(CTSPersistentStore.class).to(CTSPersistentStoreImpl.class);
bind(Debug.class).annotatedWith(Names.named(CoreTokenConstants.CTS_DEBUG)).toInstance(Debug.getInstance(CoreTokenConstants.CTS_DEBUG));
bind(Debug.class).annotatedWith(Names.named(CoreTokenConstants.CTS_REAPER_DEBUG)).toInstance(Debug.getInstance(CoreTokenConstants.CTS_REAPER_DEBUG));
bind(Debug.class).annotatedWith(Names.named(CoreTokenConstants.CTS_ASYNC_DEBUG)).toInstance(Debug.getInstance(CoreTokenConstants.CTS_ASYNC_DEBUG));
bind(Debug.class).annotatedWith(Names.named(CoreTokenConstants.CTS_MONITOR_DEBUG)).toInstance(Debug.getInstance(CoreTokenConstants.CTS_MONITOR_DEBUG));
bind(Debug.class).annotatedWith(Names.named(DataLayerConstants.DATA_LAYER_DEBUG)).toInstance(Debug.getInstance(DataLayerConstants.DATA_LAYER_DEBUG));
bind(Debug.class).annotatedWith(Names.named("amSMS")).toInstance(Debug.getInstance("amSMS"));
bind(Debug.class).annotatedWith(Names.named(PolicyMonitor.POLICY_MONITOR_DEBUG)).toInstance(Debug.getInstance(PolicyMonitor.POLICY_MONITOR_DEBUG));
bind(Debug.class).annotatedWith(Names.named(OAuth2Constants.DEBUG_LOG_NAME)).toInstance(Debug.getInstance(OAuth2Constants.DEBUG_LOG_NAME));
bind(CoreTokenConstants.class).in(Singleton.class);
bind(CoreTokenConfig.class).in(Singleton.class);
// CTS Connection Management
bind(String.class).annotatedWith(Names.named(DataLayerConstants.ROOT_DN_SUFFIX)).toProvider(new Provider<String>() {
public String get() {
return SMSEntry.getRootSuffix();
}
}).in(Singleton.class);
bind(ConfigurationObserver.class).toProvider(new Provider<ConfigurationObserver>() {
public ConfigurationObserver get() {
return ConfigurationObserver.getInstance();
}
}).in(Singleton.class);
// CTS Monitoring
bind(CTSOperationsMonitoringStore.class).to(CTSMonitoringStoreImpl.class);
bind(CTSReaperMonitoringStore.class).to(CTSMonitoringStoreImpl.class);
bind(CTSConnectionMonitoringStore.class).to(CTSMonitoringStoreImpl.class);
// Enable monitoring of all CTS operations
bind(ResultHandlerFactory.class).to(MonitoredResultHandlerFactory.class);
// CTS Reaper configuration
bind(ReaperQuery.class).to(ReaperConnection.class);
// Policy Monitoring
bind(PolicyMonitor.class).to(PolicyMonitorImpl.class);
// SAML2 token repository dependencies
bind(new TypeLiteral<TokenAdapter<SAMLToken>>() {
}).to(SAMLAdapter.class);
/**
* Session related dependencies.
*/
bind(SessionOperationStrategy.class).to(ServerSessionOperationStrategy.class);
// TODO: Investigate whether or not this lazy-loading "Config<SessionService>" wrapper is still needed
bind(new TypeLiteral<Config<SessionService>>() {
}).toInstance(new Config<SessionService>() {
@Override
public boolean isReady() {
return true;
}
@Override
public SessionService get() {
return InjectorHolder.getInstance(SessionService.class);
}
});
bind(Debug.class).annotatedWith(Names.named(SessionConstants.SESSION_DEBUG)).toInstance(Debug.getInstance(SessionConstants.SESSION_DEBUG));
bind(new TypeLiteral<Function<String, String, NeverThrowsException>>() {
}).annotatedWith(Names.named("tagSwapFunc")).toInstance(new Function<String, String, NeverThrowsException>() {
@Override
public String apply(String text) {
return ServicesDefaultValues.tagSwap(text, true);
}
});
install(new FactoryModuleBuilder().implement(AMIdentityRepository.class, AMIdentityRepository.class).build(AMIdentityRepositoryFactory.class));
install(new FactoryModuleBuilder().implement(SMSAuditor.class, SMSAuditor.class).build(ConfigAuditorFactory.class));
Multibinder.newSetBinder(binder(), SMSAuditFilter.class);
Multibinder.newSetBinder(binder(), IdRepoCreationListener.class);
bind(Stats.class).annotatedWith(Names.named(SessionConstants.STATS_MASTER_TABLE)).toInstance(Stats.getInstance(SessionConstants.STATS_MASTER_TABLE));
bind(SessionCache.class).toInstance(SessionCache.getInstance());
bind(SessionPollerPool.class).toInstance(SessionPollerPool.getInstance());
/*
* Must use a provider to ensure initialisation happens after SystemProperties have been set.
*/
bind(SessionCookies.class).toProvider(new Provider<SessionCookies>() {
@Override
public SessionCookies get() {
return SessionCookies.getInstance();
}
});
/*
* Must use a provider to ensure initialisation happens after SystemProperties have been set.
*/
bind(SessionURL.class).toProvider(new Provider<SessionURL>() {
@Override
public SessionURL get() {
return SessionURL.getInstance();
}
});
bind(SessionServiceURLService.class).toInstance(SessionServiceURLService.getInstance());
bind(ConsoleConfigHandler.class).to(ConsoleConfigHandlerImpl.class);
}
use of org.forgerock.util.Function in project OpenAM by OpenRock.
the class AnnotatedMethod method checkMethod.
static AnnotatedMethod checkMethod(Class<?> annotation, Object requestHandler, Method method) {
List<ContextParameter> contextParams = new ArrayList<>();
int requestParam = -1;
for (int i = 0; i < method.getParameterTypes().length; i++) {
Class<?> type = method.getParameterTypes()[i];
for (Annotation paramAnnotation : method.getParameterAnnotations()[i]) {
if (paramAnnotation instanceof Contextual) {
if (Context.class.isAssignableFrom(type)) {
contextParams.add(new ContextParameter(i, (Class<? extends Context>) type));
} else if (Request.class.isAssignableFrom(type)) {
requestParam = i;
}
}
}
}
Function<Object, Promise<Response, NeverThrowsException>, NeverThrowsException> resourceCreator;
if (Promise.class.equals(method.getReturnType())) {
resourceCreator = new PromisedResponseCreator();
} else if (Response.class.equals(method.getReturnType())) {
resourceCreator = new Function<Object, Promise<Response, NeverThrowsException>, NeverThrowsException>() {
@Override
public Promise<Response, NeverThrowsException> apply(Object o) {
return newResultPromise((Response) o);
}
};
} else {
resourceCreator = ResponseCreator.forType(method.getReturnType());
}
return new AnnotatedMethod(annotation.getSimpleName(), requestHandler, method, contextParams, requestParam, method.getParameterTypes().length, resourceCreator);
}
Aggregations