public static Map<ConfigKey<String>, String> finalAndOriginalSpecs(
      String finalSpec, Object... sourcesForOriginalSpec) {
    // yuck!: TODO should clean up how these things get passed around
    Map<ConfigKey<String>, String> result = MutableMap.of();
    if (finalSpec != null) result.put(LocationInternal.FINAL_SPEC, finalSpec);

    String originalSpec = null;
    for (Object source : sourcesForOriginalSpec) {
      if (source instanceof CharSequence) originalSpec = source.toString();
      else if (source instanceof Map) {
        if (originalSpec == null)
          originalSpec = Strings.toString(((Map<?, ?>) source).get(LocationInternal.ORIGINAL_SPEC));
        if (originalSpec == null)
          originalSpec =
              Strings.toString(((Map<?, ?>) source).get(LocationInternal.ORIGINAL_SPEC.getName()));
      }
      if (originalSpec != null) break;
    }
    if (originalSpec == null) originalSpec = finalSpec;
    if (originalSpec != null) result.put(LocationInternal.ORIGINAL_SPEC, originalSpec);

    return result;
  }
예제 #2
0
 @Override
 public boolean isAuthenticated(HttpSession session) {
   if (session == null) return false;
   Object value = session.getAttribute(getAuthenticationKey());
   return Strings.isNonBlank(Strings.toString(value));
 }