예제 #1
0
  /**
   * Retrieves all server info set on the server.
   *
   * @param context Current Server Context.
   * @param realm realm in whose security context we use.
   */
  private Promise<ResourceResponse, ResourceException> getAllServerInfo(
      Context context, String realm) {
    JsonValue result = new JsonValue(new LinkedHashMap<String, Object>(1));
    Set<String> cookieDomains;
    ResourceResponse resource;

    // added for the XUI to be able to understand its locale to request the appropriate translations
    // to cache
    ISLocaleContext localeContext = new ISLocaleContext();
    HttpContext httpContext = context.asContext(HttpContext.class);
    localeContext.setLocale(
        httpContext); // we have nothing else to go on at this point other than their request

    SelfServiceInfo selfServiceInfo = configHandler.getConfig(realm, SelfServiceInfoBuilder.class);
    RestSecurity restSecurity = restSecurityProvider.get(realm);
    Set<String> protectedUserAttributes = new HashSet<>();
    protectedUserAttributes.addAll(selfServiceInfo.getProtectedUserAttributes());
    protectedUserAttributes.addAll(restSecurity.getProtectedUserAttributes());

    try {
      cookieDomains = AuthClientUtils.getCookieDomains();
      result.put("domains", cookieDomains);
      result.put("protectedUserAttributes", protectedUserAttributes);
      result.put(
          "cookieName", SystemProperties.get(Constants.AM_COOKIE_NAME, "iPlanetDirectoryPro"));
      result.put("secureCookie", CookieUtils.isCookieSecure());
      result.put("forgotPassword", String.valueOf(selfServiceInfo.isForgottenPasswordEnabled()));
      result.put("forgotUsername", String.valueOf(selfServiceInfo.isForgottenUsernameEnabled()));
      result.put("kbaEnabled", String.valueOf(selfServiceInfo.isKbaEnabled()));
      result.put("selfRegistration", String.valueOf(selfServiceInfo.isUserRegistrationEnabled()));
      result.put("lang", getJsLocale(localeContext.getLocale()));
      result.put("successfulUserRegistrationDestination", "default");
      result.put("socialImplementations", getSocialAuthnImplementations(realm));
      result.put("referralsEnabled", Boolean.FALSE.toString());
      result.put("zeroPageLogin", AuthUtils.getZeroPageLoginConfig(realm));
      result.put("realm", realm);
      result.put(
          "xuiUserSessionValidationEnabled",
          SystemProperties.getAsBoolean(Constants.XUI_USER_SESSION_VALIDATION_ENABLED, true));

      if (debug.messageEnabled()) {
        debug.message(
            "ServerInfoResource.getAllServerInfo ::"
                + " Added resource to response: "
                + ALL_SERVER_INFO);
      }

      resource =
          newResourceResponse(ALL_SERVER_INFO, Integer.toString(result.asMap().hashCode()), result);

      return newResultPromise(resource);
    } catch (Exception e) {
      debug.error(
          "ServerInfoResource.getAllServerInfo : Cannot retrieve all server info domains.", e);
      return new NotFoundException(e.getMessage()).asPromise();
    }
  }
예제 #2
0
 /** Retrieves the cookie domains set on the server. */
 private Promise<ResourceResponse, ResourceException> getCookieDomains() {
   JsonValue result = new JsonValue(new LinkedHashMap<String, Object>(1));
   Set<String> cookieDomains;
   ResourceResponse resource;
   int rev;
   try {
     cookieDomains = AuthClientUtils.getCookieDomains();
     rev = cookieDomains.hashCode();
     result.put("domains", cookieDomains);
     resource = newResourceResponse(COOKIE_DOMAINS, Integer.toString(rev), result);
     if (debug.messageEnabled()) {
       debug.message(
           "ServerInfoResource.getCookieDomains ::"
               + " Added resource to response: "
               + COOKIE_DOMAINS);
     }
     return newResultPromise(resource);
   } catch (Exception e) {
     debug.error("ServerInfoResource.getCookieDomains : Cannot retrieve cookie domains.", e);
     return new NotFoundException(e.getMessage()).asPromise();
   }
 }
예제 #3
0
 // Returns environment Map based on input environment List values
 // each value takes following format:
 // env-name|value1|value2|....
 private Map toEnvMap(List envList) {
   if (envList == null) {
     return null;
   }
   Map map = new HashMap();
   int size = envList.size();
   for (int i = 0; i < size; i++) {
     String value = (String) envList.get(i);
     StringTokenizer tokens = new StringTokenizer(value, ISAuthConstants.PIPE_SEPARATOR);
     String envName = null;
     if (tokens.hasMoreTokens()) {
       envName = (String) tokens.nextToken();
     }
     Set envValues = new HashSet();
     while (tokens.hasMoreTokens()) {
       envValues.add(AuthClientUtils.unescapePipe(tokens.nextToken()));
     }
     if ((envName != null) && !envValues.isEmpty()) {
       map.put(envName, envValues);
     }
   }
   return map;
 }