protected void buildClaimMappings(
      Map<ClaimMapping, String> claims, Map.Entry<String, Object> entry, String separator) {
    String claimValue = null;
    if (StringUtils.isBlank(separator)) {
      separator = IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR_DEFAULT;
    }
    try {
      JSONArray jsonArray = (JSONArray) JSONValue.parseWithException(entry.getValue().toString());
      if (jsonArray != null && jsonArray.size() > 0) {
        Iterator attributeIterator = jsonArray.iterator();
        while (attributeIterator.hasNext()) {
          if (claimValue == null) {
            claimValue = attributeIterator.next().toString();
          } else {
            claimValue = claimValue + separator + attributeIterator.next().toString();
          }
        }
      }
    } catch (Exception e) {
      claimValue = entry.getValue().toString();
    }

    claims.put(ClaimMapping.build(entry.getKey(), entry.getKey(), null, false), claimValue);
    if (log.isDebugEnabled()
        && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.USER_CLAIMS)) {
      log.debug(
          "Adding claim mapping : "
              + entry.getKey()
              + " <> "
              + entry.getKey()
              + " : "
              + claimValue);
    }
  }
예제 #2
0
 /**
  * Get all city crime reports
  *
  * @return List<CityCrime>
  */
 public List<CityCrime> getAllCityCrime() {
   List<CityCrime> cityCrimeList = new ArrayList<CityCrime>();
   for (int i = 0; i < rawData.size(); i++) {
     try {
       cityCrimeList.add(new CityCrime((JSONObject) rawData.get(i)));
     } catch (NullPointerException e) {
       e.printStackTrace();
     }
   }
   return cityCrimeList;
 }