Log in to container registry in Azure cloud.
If login succeeded, docker obtains authentication to pull images from this registry.
@return
762528
@Override
    protected boolean loginToRemoteRegistry() {
        Pair<Integer, InputStream> result;

        try {
            // Check if user already logged in to azure
            isUserLoggedIn();

            // If user isn't logged in, then login to azure via az cli.
            if(!loggedInToAzure) {
                Process process = Runtime.getRuntime().exec(azureCli.getLoginCommand(config.getAzureUserName(), config.getAzureUserPassword()));
                int resultValue = process.waitFor();
                if (resultValue == 0) {
                    logger.info("Log in to Azure account {} - Succeeded", config.getAzureUserName());
                } else {
                    logger.info("Log in to Azure account {} - Failed", config.getAzureUserName());
                    String errorMessage = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8.name());
                    logger.error("Failed to log in to Azure account {} - {}", config.getAzureUserName(), errorMessage);
                    return false;
                }
            }

            // Log in to registry via azure cli, Run azure command: "az acr login -n <RegistryName>"
            // Once azure login command to registry succeeded - docker obtains authentication to pull images from registry.
            for (String registryName : config.getAzureRegistryNames()) {
                if (registryName != null && !registryName.trim().equals(Constants.EMPTY_STRING)) {
                    logger.info("Log in to Azure container registry {}", registryName);
                    result = executeCommand(azureCli.getLoginContainerRegistryCommand(registryName));
                    if (result.getKey() == 0) {
                        logger.info("Login to registry : {} - Succeeded", registryName);
                        loggedInRegistries.add(registryName);
                    } else {
                        logger.info("Login to registry {} - Failed", registryName);
                        logger.error("Failed to login registry {} - {}", registryName, IOUtils.toString(result.getValue(), StandardCharsets.UTF_8.name()));
                    }
                }
            }
            return true;

        } catch (InterruptedException interruptedException) {
            logger.debug("Failed to login to Azure account, Exception: {}", interruptedException.getMessage());
        } catch (IOException ioException) { // this exception occurred when parsing inputStream to String
            logger.debug("Failed to parse command error result, Exception: {}", ioException.getMessage());
        }

        return false;
    }
597739
protected RegistryAuth registryAuth() throws MojoExecutionException {
    if (settings != null && serverId != null) {
      final Server server = settings.getServer(serverId);
      if (server != null) {
        final RegistryAuth.Builder registryAuthBuilder = RegistryAuth.builder();

        final String username = server.getUsername();
        String password = server.getPassword();
        if (secDispatcher != null) {
          try {
            password = secDispatcher.decrypt(password);
          } catch (SecDispatcherException ex) {
            throw new MojoExecutionException("Cannot decrypt password from settings", ex);
          }
        }
        final String email = getEmail(server);

        if (!isNullOrEmpty(username)) {
          registryAuthBuilder.username(username);
        }
        if (!isNullOrEmpty(email)) {
          registryAuthBuilder.email(email);
        }
        if (!isNullOrEmpty(password)) {
          registryAuthBuilder.password(password);
        }
        if (!isNullOrEmpty(registryUrl)) {
          registryAuthBuilder.serverAddress(registryUrl);
        }

        return registryAuthBuilder.build();
      } else {
        // settings.xml has no entry for the configured serverId, warn the user
        getLog().warn("No entry found in settings.xml for serverId=" + serverId
                      + ", cannot configure authentication for that registry");
      }
    }
    return null;
  }
1032393
public com.google.cloud.audit.AuthenticationInfo getAuthenticationInfo() {
    return authenticationInfo_ == null ? com.google.cloud.audit.AuthenticationInfo.getDefaultInstance() : authenticationInfo_;
  }
1347709
function getDockerLogin() {
    return spinner(
        new Promise((resolve, reject) =>
            _getAuthorizationToken().then(authToken =>
                sts
                    .getCallerIdentity({})
                    .promise()
                    .then(data => {
                        const decoded = utils.decodeBase64(authToken.authorizationToken);
                        const splitResult = decoded.split(':');
                        resolve({
                            username: splitResult[0],
                            password: splitResult[1],
                            accountId: data.Account
                        });
                    })
                    .catch(() => reject(new Error("Couldn't retrieve the user informations")))
            )
        )
    );
}
1060001
public java.util.List<ContainerInstance> getContainerInstances() {
        if (containerInstances == null) {
            containerInstances = new com.amazonaws.internal.SdkInternalList<ContainerInstance>();
        }
        return containerInstances;
    }
287249
public Object getCloudantClient(int resAuth, List<? extends ResourceInfo.Property> loginPropertyList) throws Exception {
        AuthData containerAuthData = null;
        if (resAuth == ResourceInfo.AUTH_CONTAINER) {
            containerAuthData = getContainerAuthData(loginPropertyList);
        }

        String userName = containerAuthData == null ? (String) props.get(USERNAME) : containerAuthData.getUserName();
        String password = null;
        if (containerAuthData == null) {
            SerializableProtectedString protectedPwd = (SerializableProtectedString) props.get(PASSWORD);
            if (protectedPwd != null) {
                password = String.valueOf(protectedPwd.getChars());
                password = PasswordUtil.getCryptoAlgorithm(password) == null ? password : PasswordUtil.decode(password);
            }
        } else
            password = String.valueOf(containerAuthData.getPassword());

        final ClientKey key = new ClientKey(null, userName, password);
        return clients.get(key);
    }
68650
public function acquireAccessToken() {

        switch ($this->_credentials->getCredentialType()) {
            case AzureAdTokenCredentialType::USER_SECRET_CREDENTIAL:
                return $this->_azureAdClient->acquireTokenWithUserCredentials(
                        $this->_credentials->getAzureEnvironment()->getMediaServicesResource(),
                        $this->_credentials->getAzureEnvironment()->getMediaServicesSdkClientId(),
                        $this->_credentials->getCredential()->getUsername(),
                        $this->_credentials->getCredential()->getPassword());

            case AzureAdTokenCredentialType::SERVICE_PRINCIPAL_WITH_CLIENT_SYMMETRIC_KEY:
                return $this->_azureAdClient->acquireTokenWithSymmetricKey(
                    $this->_credentials->getAzureEnvironment()->getMediaServicesResource(),
                    $this->_credentials->getCredential()->getClientId(),
                    $this->_credentials->getCredential()->getClientSecret());

            case AzureAdTokenCredentialType::SERVICE_PRINCIPAL_WITH_CERTIFICATE:
                return $this->_azureAdClient->acquireTokenWithAsymmetricKey(
                    $this->_credentials->getAzureEnvironment()->getMediaServicesResource(),
                    $this->_credentials->getCredential());

            case AzureAdTokenCredentialType::USER_CREDENTIAL:
                throw new \Symfony\Component\DependencyInjection\Exception\RuntimeException(
                    "Interactive user credential is currently not supported by the php sdk");

            default:
                throw new \Symfony\Component\DependencyInjection\Exception\RuntimeException(
                        "Unknown token credential type");
        }
    }
1035314
public String login(String token, Authentication authentication) {
		if (null == token) {
			return login(authentication);
		}
		tokens.put(token, new TokenContainer(authentication));
		return token;
	}
95713
def get_dockercfg_credentials(self, docker_registry):
        
        if not self.registry_secret_path:
            return {}

        dockercfg = Dockercfg(self.registry_secret_path)
        registry_creds = dockercfg.get_credentials(docker_registry)
        if 'username' not in registry_creds:
            return {}

        return {
            'basic_auth_username': registry_creds['username'],
            'basic_auth_password': registry_creds['password'],
        }
381252
public OvhRegistryCredentials serviceName_registry_credentials_credentialsId_GET(String serviceName, String credentialsId) throws IOException {
		String qPath = "/caas/containers/{serviceName}/registry/credentials/{credentialsId}";
		StringBuilder sb = path(qPath, serviceName, credentialsId);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhRegistryCredentials.class);
	}
1180285
public java.lang.String getContainer() {
    java.lang.Object ref = container_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = 
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      container_ = s;
      return s;
    }
  }
208762
private void isUserLoggedIn() {
        String accountListCmd = azureCli.getLoggedInAccountList();
        Pair<Integer, InputStream> result = executeCommand(accountListCmd);
        if (result.getKey() == 0) {
            try {
                String accountList = IOUtils.toString(result.getValue(), StandardCharsets.UTF_8.name());

                JSONArray jsonArray = new JSONArray(accountList);
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject jsonObject = jsonArray.getJSONObject(i);
                    String loggedInUserName = jsonObject.getJSONObject("user").getString("name");
                    if (loggedInUserName.equalsIgnoreCase(config.getAzureUserName())) {
                        loggedInToAzure = true;
                        break;
                    }
                }
            } catch (IOException e) {
                logger.warn("Failed to parse command {} result. Exception: {}", accountListCmd, e.getMessage());
                logger.debug("Failed to parse command {} result. Exception: {}", accountListCmd, e.getStackTrace());
            }
        } else {
            logger.warn("Failed to get Azure logged in account list, command: {}.", accountListCmd);
        }
    }
378554
public synchronized AuthStorage getStorage(){
        if(storage==null){
            String cls = Objects.get(config,"storageClass",LogStorage.class.getName());
            try{
                storage = (AuthStorage)Class.forName(cls).newInstance();
            }catch (Exception e){
                throw S1SystemError.wrap(e);
            }
        }
        return storage;
    }
813219
public static synchronized LoadBalancerRegistry getDefaultRegistry() {
    if (instance == null) {
      List<LoadBalancerProvider> providerList = ServiceProviders.loadAll(
          LoadBalancerProvider.class,
          HARDCODED_CLASSES,
          LoadBalancerProvider.class.getClassLoader(),
          new LoadBalancerPriorityAccessor());
      instance = new LoadBalancerRegistry();
      for (LoadBalancerProvider provider : providerList) {
        logger.fine("Service loader found " + provider);
        if (provider.isAvailable()) {
          instance.addProvider(provider);
        }
      }
      instance.refreshProviderMap();
    }
    return instance;
  }
851600
public static Authentication getInProgressAuthentication() {
        val context = RequestContextHolder.getRequestContext();
        val authentication = context != null ? WebUtils.getAuthentication(context) : null;
        if (authentication == null) {
            return AuthenticationCredentialsThreadLocalBinder.getInProgressAuthentication();
        }
        return authentication;
    }
687889
@Override
   public Credential getPrefillCredential()
   {
      if (this.prefillCredential == null)
      {
         if (cm.getSubjectFactory() == null || cm.getConnectionManagerConfiguration().getSecurityDomain() == null)
         {
            prefillCredential = new Credential(null, null);
         }
         else
         {
            prefillCredential =
               new Credential(SecurityActions.createSubject(cm.getSubjectFactory(),
                                                            cm.getConnectionManagerConfiguration().getSecurityDomain(),
                                                            cm.getManagedConnectionFactory()),
                              null);
         }
      }
      return this.prefillCredential;
   }
583403
public String getContainerAuthDataID() {
        String authDataID = null;
        lock.readLock().lock();
        try {
            if (containerAuthDataRef != null) {
                authDataID = (String) containerAuthDataRef.getProperty(ID);
                if (authDataID == null ||
                    DEFAULT_PATTERN.matcher(authDataID).matches() ||
                    DEFAULT_NESTED_PATTERN.matcher(authDataID).matches()) {
                    authDataID = (String) containerAuthDataRef.getProperty("config.displayId");
                }
            }
        } finally {
            lock.readLock().unlock();
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(this, tc, "default container auth data", authDataID);
        return authDataID;
    }