コード例 #1
0
      @Override
      public AuthorizationIdentity getAuthorizationIdentity() throws RealmUnavailableException {

        if (groups.length() > 0) {
          String[] temp = groups.split(COMMA);
          Set<String> groups = new HashSet<>(temp.length);

          for (String current : temp) {
            String cleaned = current.trim();
            if (cleaned.length() > 0) {
              SECURITY_LOGGER.tracef("Adding group '%s' for identity '%s'.", cleaned, name);
              groups.add(cleaned);
            }
          }

          Map<String, Set<String>> groupsAttributeMap = new HashMap<String, Set<String>>();
          groupsAttributeMap.put("GROUPS", Collections.unmodifiableSet(groups));

          return AuthorizationIdentity.basicIdentity(
              new MapAttributes(Collections.unmodifiableMap(groupsAttributeMap)));
        } else {
          SECURITY_LOGGER.tracef("No groups found for identity '%s' in properties file.", name);
          return AuthorizationIdentity.EMPTY;
        }
      }
コード例 #2
0
    @Override
    public AuthorizationIdentity getAuthorizationIdentity() throws RealmUnavailableException {
      if (!exists()) {
        return AuthorizationIdentity.EMPTY;
      }

      return AuthorizationIdentity.basicIdentity(this.identity.attributes);
    }