// Path: runAs-common/src/main/java/jetbrains/buildServer/runAs/common/Constants.java
// public class Constants {
//     // Plugin's ids
//     public static final String BUILD_FEATURE_TYPE = "runAs-build-feature";
//     public static final String RUN_AS_TOOL_NAME = "runAs";
// 
//     // Parameter names
//     public static final String USER = "teamcity.runAs.username";
//     public static final String PASSWORD = "secure:teamcity.runAs.password";
//     public static final String CONFIG_PASSWORD = "teamcity.runAs.password";
//     public static final String ADDITIONAL_ARGS = "teamcity.runAs.additionalCommandLine";
//     public static final String RUN_AS_ENABLED = "teamcity.agent.runAs.enabled";
//     public static final String CREDENTIALS_PROFILE_ID = "teamcity.runAs.profileId";
//     public static final String WINDOWS_INTEGRITY_LEVEL = "teamcity.runAs.windowsIntegrityLlevel";
//     public static final String LOGGING_LEVEL = "teamcity.runAs.loggingLevel";
//     public static final String ALLOW_CUSTOM_CREDENTIALS = "teamcity.runAs.allowCustomCredentials";
//     public static final String ALLOW_PROFILE_ID_FROM_SERVER = "teamcity.runAs.allowProfileIdFromServer";
//     public static final String CREDENTIALS_DIRECTORY = "teamcity.runAs.configDir";
//     public static final String RUN_AS_UI_ENABLED = "teamcity.runAs.ui.enabled";
//     public static final String RUN_AS_UI_STEPS_ENABLED = "teamcity.runAs.ui.steps.enabled";
//     public static final String RUN_AS_LOG_ENABLED = "teamcity.runAs.log.enabled";
//     public static final String RUN_AS_ACL = "teamcity.runAs.acl";
//     public static final String RUN_AS_ACL_DEFAULTS_ENABLED = "teamcity.runAs.acl.defaults.enabled";
// }


import com.intellij.openapi.diagnostic.Logger;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import jetbrains.buildServer.dotNet.buildRunner.agent.FileService;
import jetbrains.buildServer.runAs.common.Constants;
import jetbrains.buildServer.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
    if(StringUtil.isEmptyOrSpaces(credentialsDirectoryStr)) {
      LOG.error("Configuration parameter \"" + Constants.CREDENTIALS_DIRECTORY + "\" was not defined");
      return;
    }

    if(LOG.isDebugEnabled()) {
      LOG.debug("Credentials directory value is \"" + credentialsDirectoryStr + "\"");
    }

    File credentialsDirectory = new File(credentialsDirectoryStr);
    if(!myFileService.exists(credentialsDirectory) || !myFileService.isAbsolute(credentialsDirectory))
    {
      credentialsDirectory = new File(myPathsService.getPath(WellKnownPaths.Bin), credentialsDirectoryStr);
    }

    if(LOG.isDebugEnabled()) {
      LOG.debug("Credentials directory is \"" + credentialsDirectory + "\"");
    }

    if(!myFileService.exists(credentialsDirectory) || !myFileService.isDirectory(credentialsDirectory)) {
      LOG.error("Credentials directory \"" + credentialsDirectory + "\" was not found");
      return;
    }

    for(File propertyFiles: myFileService.listFiles(credentialsDirectory)) {
      load(propertyFiles);
    }
  }

  @NotNull
// Path: runAs-common/src/main/java/jetbrains/buildServer/runAs/common/Constants.java
// public class Constants {
//     // Plugin's ids
//     public static final String BUILD_FEATURE_TYPE = "runAs-build-feature";
//     public static final String RUN_AS_TOOL_NAME = "runAs";
// 
//     // Parameter names
//     public static final String USER = "teamcity.runAs.username";
//     public static final String PASSWORD = "secure:teamcity.runAs.password";
//     public static final String CONFIG_PASSWORD = "teamcity.runAs.password";
//     public static final String ADDITIONAL_ARGS = "teamcity.runAs.additionalCommandLine";
//     public static final String RUN_AS_ENABLED = "teamcity.agent.runAs.enabled";
//     public static final String CREDENTIALS_PROFILE_ID = "teamcity.runAs.profileId";
//     public static final String WINDOWS_INTEGRITY_LEVEL = "teamcity.runAs.windowsIntegrityLlevel";
//     public static final String LOGGING_LEVEL = "teamcity.runAs.loggingLevel";
//     public static final String ALLOW_CUSTOM_CREDENTIALS = "teamcity.runAs.allowCustomCredentials";
//     public static final String ALLOW_PROFILE_ID_FROM_SERVER = "teamcity.runAs.allowProfileIdFromServer";
//     public static final String CREDENTIALS_DIRECTORY = "teamcity.runAs.configDir";
//     public static final String RUN_AS_UI_ENABLED = "teamcity.runAs.ui.enabled";
//     public static final String RUN_AS_UI_STEPS_ENABLED = "teamcity.runAs.ui.steps.enabled";
//     public static final String RUN_AS_LOG_ENABLED = "teamcity.runAs.log.enabled";
//     public static final String RUN_AS_ACL = "teamcity.runAs.acl";
//     public static final String RUN_AS_ACL_DEFAULTS_ENABLED = "teamcity.runAs.acl.defaults.enabled";
// }


// Path: runAs-agent/src/main/java/jetbrains/buildServer/runAs/agent/ProfileParametersServiceImpl.java
import com.intellij.openapi.diagnostic.Logger;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import jetbrains.buildServer.dotNet.buildRunner.agent.FileService;
import jetbrains.buildServer.runAs.common.Constants;
import jetbrains.buildServer.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

    if(StringUtil.isEmptyOrSpaces(credentialsDirectoryStr)) {
      LOG.error("Configuration parameter \"" + Constants.CREDENTIALS_DIRECTORY + "\" was not defined");
      return;
    }

    if(LOG.isDebugEnabled()) {
      LOG.debug("Credentials directory value is \"" + credentialsDirectoryStr + "\"");
    }

    File credentialsDirectory = new File(credentialsDirectoryStr);
    if(!myFileService.exists(credentialsDirectory) || !myFileService.isAbsolute(credentialsDirectory))
    {
      credentialsDirectory = new File(myPathsService.getPath(WellKnownPaths.Bin), credentialsDirectoryStr);
    }

    if(LOG.isDebugEnabled()) {
      LOG.debug("Credentials directory is \"" + credentialsDirectory + "\"");
    }

    if(!myFileService.exists(credentialsDirectory) || !myFileService.isDirectory(credentialsDirectory)) {
      LOG.error("Credentials directory \"" + credentialsDirectory + "\" was not found");
      return;
    }

    for(File propertyFiles: myFileService.listFiles(credentialsDirectory)) {
      load(propertyFiles);
    }
  }

  @NotNull
  @Override