public SecurityConfiguration createSecurityConfigurationFromRequest(Map<String, Object> properties, boolean
    persistEmbeddedDescriptor) {

    SecurityConfiguration securityConfiguration;

    LOGGER.debug("Creating security configuration from properties: {}", properties);
    Map<?, ?> securityProperties = (Map<?, ?>) properties.get(SECURITY_PROPERTY_ID);

    if (securityProperties == null) {
      LOGGER.debug("No security information properties provided, returning null");
      return null;
    }

    String securityTypeString = Strings.emptyToNull((String) securityProperties.get(TYPE_PROPERTY_ID));
    if (securityTypeString == null) {
      LOGGER.error("Type is missing from security block.");
      throw new IllegalArgumentException("Type missing from security block.");
    }

    SecurityType securityType = Enums.getIfPresent(SecurityType.class, securityTypeString).orNull();
    if (securityType == null) {
      LOGGER.error("Unsupported security type specified: {}", securityType);
      throw new IllegalArgumentException("Invalid security type specified: " + securityTypeString);
    }

    if (securityType == SecurityType.KERBEROS) {

      // get security information from the request propertie if any
      String descriptorReference = Strings.emptyToNull((String)
          securityProperties.get(KERBEROS_DESCRIPTOR_REFERENCE_PROPERTY_ID));

      Object descriptorJsonMap = securityProperties.get(KERBEROS_DESCRIPTOR_PROPERTY_ID);

      if (descriptorReference != null && descriptorJsonMap != null) {
        LOGGER.error("Both kerberos descriptor and kerberos descriptor reference are set in the security configuration!");
        throw new IllegalArgumentException("Usage of properties : " + KERBEROS_DESCRIPTOR_PROPERTY_ID + " and "
            + KERBEROS_DESCRIPTOR_REFERENCE_PROPERTY_ID + " at the same time, is not allowed.");
      }

      if (descriptorJsonMap != null) { // this means the reference is null
        LOGGER.debug("Found embedded descriptor: {}", descriptorJsonMap);
        String descriptorText = jsonSerializer.toJson(descriptorJsonMap, Map.class);
        if (persistEmbeddedDescriptor) {
          descriptorReference = persistKerberosDescriptor(descriptorText);
        }
        Map<?, ?> descriptorMap = (Map<?, ?>) descriptorJsonMap;
        securityConfiguration = persistEmbeddedDescriptor
          ? SecurityConfiguration.withReference(descriptorReference)
          : SecurityConfiguration.withDescriptor(descriptorMap);
      } else if (descriptorReference != null) { // this means the reference is not null
        LOGGER.debug("Found descriptor reference: {}", descriptorReference);
        securityConfiguration = loadSecurityConfigurationByReference(descriptorReference);
      } else {
        LOGGER.debug("There is no security descriptor found in the request");
        securityConfiguration = SecurityConfiguration.KERBEROS;
      }
    } else {
      LOGGER.debug("There is no security configuration found in the request");
      securityConfiguration = SecurityConfiguration.NONE;
    }
    return securityConfiguration;
  }
Creates and also validates SecurityConfiguration based on properties parsed from request Json.

@param properties Security properties from Json parsed into a Map
@param persistEmbeddedDescriptor whether to save embedded descriptor or not
ambari-server/src/main/java/org/apache/ambari/server/topology/SecurityConfigurationFactory.java