/*
   * Find the Subject identifier among federated claims
   */
  public static String getFederatedSubjectFromClaims(
      IdentityProvider identityProvider, Map<ClaimMapping, String> claimMappings) {

    String userIdClaimURI = identityProvider.getClaimConfig().getUserClaimURI();
    ClaimMapping claimMapping = new ClaimMapping();
    Claim claim = new Claim();
    claim.setClaimUri(userIdClaimURI);
    claimMapping.setRemoteClaim(claim);
    claimMapping.setLocalClaim(claim);
    return claimMappings.get(claimMapping);
  }
  /** @param identityProvider */
  public ExternalIdPConfig(IdentityProvider identityProvider) {
    this.identityProvider = identityProvider;

    claimConfiguration = identityProvider.getClaimConfig();
    roleConfiguration = identityProvider.getPermissionAndRoleConfig();
    justInTimeProConfig = identityProvider.getJustInTimeProvisioningConfig();

    RoleMapping[] mappings = roleConfiguration.getRoleMappings();

    if (mappings != null && mappings.length > 0) {
      for (RoleMapping roleMapping : mappings) {
        this.roleMappings.put(
            roleMapping.getRemoteRole(), roleMapping.getLocalRole().getLocalRoleName());
      }
    }
  }
 /** @return */
 public String getUserIdClaimUri() {
   if (identityProvider.getClaimConfig() != null) {
     return identityProvider.getClaimConfig().getUserClaimURI();
   }
   return null;
 }