Search in sources :

Example 1 with RestSTSInstanceModule

use of org.forgerock.openam.sts.rest.config.RestSTSInstanceModule in project OpenAM by OpenRock.

the class RestSTSInstancePublisherImpl method republishExistingInstances.

/**
     * This method is only to be called by the RestSTSSetupListener, which calls it only to re-publish
     * previously-published Rest STS instances during OpenAM startup.
     */
@Override
public void republishExistingInstances() throws STSPublishException {
    /*
        Do not trigger the republish if OpenAM is being installed or upgraded.
         */
    if (AMSetupServlet.isCurrentConfigurationValid()) {
        final List<RestSTSInstanceConfig> publishedInstances = getPublishedInstances();
        for (RestSTSInstanceConfig instanceConfig : publishedInstances) {
            Injector instanceInjector;
            try {
                instanceInjector = Guice.createInjector(new RestSTSInstanceModule(instanceConfig));
            } catch (Exception e) {
                logger.error("Exception caught creating the guice injector in republish corresponding to rest sts " + "instance: " + instanceConfig.toJson() + ". This instance cannot be republished. Exception: " + e);
                continue;
            }
            try {
                publishInstance(instanceConfig, instanceInjector.getInstance(RestSTS.class), true);
                logger.info("Republished Rest STS instance corresponding to config " + instanceConfig.toJson());
            } catch (STSPublishException e) {
                logger.error("Exception caught publishing rest sts " + "instance: " + instanceConfig.toJson() + ". This instance cannot be republished. Exception: " + e);
                continue;
            }
        }
    }
}
Also used : RestSTSInstanceModule(org.forgerock.openam.sts.rest.config.RestSTSInstanceModule) RestSTSInstanceConfig(org.forgerock.openam.sts.rest.config.user.RestSTSInstanceConfig) Injector(com.google.inject.Injector) STSPublishException(org.forgerock.openam.sts.STSPublishException) RestSTS(org.forgerock.openam.sts.rest.RestSTS) STSInitializationException(org.forgerock.openam.sts.STSInitializationException) ResourceException(org.forgerock.json.resource.ResourceException) STSPublishException(org.forgerock.openam.sts.STSPublishException)

Aggregations

Injector (com.google.inject.Injector)1 ResourceException (org.forgerock.json.resource.ResourceException)1 STSInitializationException (org.forgerock.openam.sts.STSInitializationException)1 STSPublishException (org.forgerock.openam.sts.STSPublishException)1 RestSTS (org.forgerock.openam.sts.rest.RestSTS)1 RestSTSInstanceModule (org.forgerock.openam.sts.rest.config.RestSTSInstanceModule)1 RestSTSInstanceConfig (org.forgerock.openam.sts.rest.config.user.RestSTSInstanceConfig)1