/**
   * This returns the user supported claims.
   *
   * @param dialect
   * @return
   * @throws IdentityException
   */
  public UserIdentityClaimDTO[] getUserIdentitySupportedClaims(String dialect)
      throws IdentityException {
    IdentityClaimManager claimManager = null;
    Claim[] claims = null;
    UserRealm realm = null;

    claimManager = IdentityClaimManager.getInstance();
    realm = IdentityTenantUtil.getRealm(null, null);
    claims = claimManager.getAllSupportedClaims(dialect, realm);

    if (claims == null || claims.length == 0) {
      log.warn("Could not find any matching claims for requested dialect : " + dialect);
      return new UserIdentityClaimDTO[0];
    }

    List<UserIdentityClaimDTO> claimList = new ArrayList<UserIdentityClaimDTO>();

    for (int i = 0; i < claims.length; i++) {
      if (claims[i].getDisplayTag() != null
          && !IdentityConstants.PPID_DISPLAY_VALUE.equals(claims[i].getDisplayTag())) {
        if (UserCoreConstants.ClaimTypeURIs.ACCOUNT_STATUS.equals(claims[i].getClaimUri())) {
          continue;
        }
        if (claims[i].isSupportedByDefault() && (!claims[i].isReadOnly())) {

          UserIdentityClaimDTO claimDto = new UserIdentityClaimDTO();
          claimDto.setClaimUri(claims[i].getClaimUri());
          claimDto.setClaimValue(claims[i].getValue());
          claimList.add(claimDto);
        }
      }
    }

    return claimList.toArray(new UserIdentityClaimDTO[claimList.size()]);
  }
  public UserFieldDTO[] readUserFieldsForUserRegistration(String dialect) throws IdentityException {

    IdentityClaimManager claimManager = null;
    Claim[] claims = null;
    List<UserFieldDTO> claimList = null;
    UserRealm realm = null;

    claimManager = IdentityClaimManager.getInstance();
    realm = IdentityTenantUtil.getRealm(null, null);
    claims = claimManager.getAllSupportedClaims(dialect, realm);

    if (claims == null || claims.length == 0) {
      return new UserFieldDTO[0];
    }

    claimList = new ArrayList<UserFieldDTO>();

    for (Claim claim : claims) {
      if (claim.getDisplayTag() != null
          && !IdentityConstants.PPID_DISPLAY_VALUE.equals(claim.getDisplayTag())) {
        if (UserCoreConstants.ClaimTypeURIs.ACCOUNT_STATUS.equals(claim.getClaimUri())) {
          continue;
        }
        if (!claim.isReadOnly()) {
          claimList.add(
              getUserFieldDTO(
                  claim.getClaimUri(),
                  claim.getDisplayTag(),
                  claim.isRequired(),
                  claim.getDisplayOrder(),
                  claim.getRegEx(),
                  claim.isSupportedByDefault()));
        }
      }
    }

    return claimList.toArray(new UserFieldDTO[claimList.size()]);
  }