class Environment {

    public static Environment getEnvironment() {
        final BackendNodePrincipal principal = JaasUtils.getPrincipal(BackendNodePrincipal.class);

        final String environmentName = principal.getEnvironmentName();
        if (environmentName == null) {
            throw new NullPointerException("Environment name cannot be null.");
        }

        if (StringUtils.isBlank(environmentName)) {
            throw new IllegalArgumentException("Environment name cannot be blank.");
        }

        final String normalizedName = environmentName.toLowerCase(Locale.getDefault());
        if (CACHE.containsKey(normalizedName)) {
            return CACHE.get(normalizedName);
        }

        final Environment env = new Environment(environmentName);
        CACHE.put(normalizedName, env);
        return env;
    }

      Environment(final String environmentName);

}