public static FederatedAuthenticatorConfig build(OMElement federatedAuthenticatorConfigOM) {

    if (federatedAuthenticatorConfigOM == null) {
      return null;
    }

    FederatedAuthenticatorConfig federatedAuthenticatorConfig = new FederatedAuthenticatorConfig();

    Iterator<?> iter = federatedAuthenticatorConfigOM.getChildElements();

    while (iter.hasNext()) {
      OMElement element = (OMElement) (iter.next());
      String elementName = element.getLocalName();

      if ("Name".equals(elementName)) {
        federatedAuthenticatorConfig.setName(element.getText());
      } else if ("DisplayName".equals(elementName)) {
        federatedAuthenticatorConfig.setDisplayName(element.getText());
      } else if ("IsEnabled".equals(elementName)) {
        federatedAuthenticatorConfig.setEnabled(Boolean.parseBoolean(element.getText()));
      } else if ("Properties".equals(elementName)) {
        Iterator<?> propertiesIter = element.getChildElements();
        List<Property> propertiesArrList = new ArrayList<Property>();

        if (propertiesIter != null) {
          while (propertiesIter.hasNext()) {
            OMElement propertiesElement = (OMElement) (propertiesIter.next());
            propertiesArrList.add(Property.build(propertiesElement));
          }
        }

        if (CollectionUtils.isNotEmpty(propertiesArrList)) {
          Property[] propertiesArr = propertiesArrList.toArray(new Property[0]);
          federatedAuthenticatorConfig.setProperties(propertiesArr);
        }
      }
    }

    return federatedAuthenticatorConfig;
  }
  /**
   * @param externalIdPConfig
   * @param name
   * @return
   */
  public static Map<String, String> getAuthenticatorPropertyMapFromIdP(
      ExternalIdPConfig externalIdPConfig, String name) {

    Map<String, String> propertyMap = new HashMap<String, String>();

    if (externalIdPConfig != null) {
      FederatedAuthenticatorConfig[] authenticatorConfigs =
          externalIdPConfig.getIdentityProvider().getFederatedAuthenticatorConfigs();

      for (FederatedAuthenticatorConfig authenticatorConfig : authenticatorConfigs) {

        if (authenticatorConfig.getName().equals(name)) {

          for (Property property : authenticatorConfig.getProperties()) {
            propertyMap.put(property.getName(), property.getValue());
          }
          break;
        }
      }
    }

    return propertyMap;
  }