Search in sources :

Example 1 with SecretManager

use of org.wso2.securevault.secret.SecretManager in project wso2-synapse by wso2.

the class ServerStateDetectionStrategy method currentState.

/**
 * Determine the next possible server state based on current states and other facts
 *
 * @param contextInformation ServerContextInformation instance
 * @param information        ServerConfigurationInformation instance
 * @return The actual current state possible states for the server
 */
public static ServerState currentState(ServerContextInformation contextInformation, ServerConfigurationInformation information) {
    ServerState previousState = contextInformation.getServerState();
    String deploymentMode = information.getDeploymentMode();
    // if the previous state is ServerState.UNDETERMINED it should be ServerState.INITIALIZABLE
    if (previousState == ServerState.UNDETERMINED) {
        // before the server state to be ServerState.INITIALIZABLE
        if (deploymentMode != null && PRODUCTION_MODE.equals(deploymentMode.trim())) {
            SecretManager secretManager = SecretManager.getInstance();
            if (secretManager.isInitialized()) {
                return ServerState.INITIALIZABLE;
            } else {
                secretManager.init(SynapsePropertiesLoader.loadSynapseProperties());
                if (secretManager.isInitialized()) {
                    return ServerState.INITIALIZABLE;
                }
            }
        } else {
            return ServerState.INITIALIZABLE;
        }
    }
    // if the previous state is deterministic then the current state is the previous state
    return previousState;
}
Also used : SecretManager(org.wso2.securevault.secret.SecretManager)

Aggregations

SecretManager (org.wso2.securevault.secret.SecretManager)1