private Credential createCredential(Map<String, Object> properties) throws IllegalArgumentException {
    String principal;
    String key;

    if (properties.get(CREDENTIAL_PRINCIPAL_PROPERTY_ID) == null) {
      throw new IllegalArgumentException("Property " + CREDENTIAL_PRINCIPAL_PROPERTY_ID + " must be provided");
    } else {
      principal = String.valueOf(properties.get(CREDENTIAL_PRINCIPAL_PROPERTY_ID));
    }

    if (properties.get(CREDENTIAL_KEY_PROPERTY_ID) == null) {
      LOG.warn("The credential is being added without a key");
      key = null;
    } else {
      key = String.valueOf(properties.get(CREDENTIAL_KEY_PROPERTY_ID));
    }

    return new PrincipalKeyCredential(principal, key);
  }
Give a map of credential-related properties attempts to create a Credential (PrincipalKeyCredential)
after validating that the required properties are present.
<p/>
The credential's principal is required, however a warning will be logged if a value for the key
is not supplied.

@param properties a map of properties
@return a new Credential
@throws IllegalArgumentException if the map of properties does not contain enough information to create
                                 a new PrincipalKeyCredential instance
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CredentialResourceProvider.java