Credential provider for repositories that require access.

@param username the username
@param password the password
@return the git repository builder
493453
public GitRepositoryBuilder credentialProvider(final String username, final String password) {
        if (StringUtils.hasText(username)) {
            this.credentialsProviders.add(new UsernamePasswordCredentialsProvider(username, password));
        }
        return this;
    }
295993
public RequestBuilder basicAuth(String user, String password) {
        this.basicAuth = new BasicAuth(user, password);
        return this;
    }
315271
public void setUser(String userName, String password){
        if(userName != null && ! userName.isEmpty()){
            connection.setDirectoryUser(userName, password);
        }
    }
1314067
@Override
    public User createUser(String username, String password)
            throws AuthenticationException {
        String user = file_store.getProperty(username);
        if (user != null) {
            throw new AuthenticationException("User '" + username
                    + "' already exists.");
        }
        // Encrypt the new password
        String ePwd = encryptPassword(password);
        file_store.put(username, ePwd);
        try {
            saveUsers();
        } catch (IOException e) {
            throw new AuthenticationException("Error changing password: ", e);
        }

        return getUser(username);
    }
1191107
public static Authentication build(String crypt) throws IllegalArgumentException {
        if(crypt == null) {
            return new PlainAuth(null);
        }
        String[] value = crypt.split(":");
        
        if(value.length == 2 ) {
            String type = value[0].trim();
            String password = value[1].trim();
            if(password!=null&&password.length()>0) {
                if("plain".equals(type)) {
                    return new PlainAuth(password);
                }
                if("md5".equals(type)) {
                    return new Md5Auth(password);
                }
                if("crc32".equals(type)) {
                    return new Crc32Auth(Long.parseLong(password));
                }
            }
        }
        throw new IllegalArgumentException("error password: "+crypt);
    }
1313443
protected Session login(String repositoryId) {
        LOGGER.debug("--- login: " + repositoryId);

        if (context == null) {
            throw new CmisRuntimeException("No user context!");
        }

        Session session = sessions.get(repositoryId);
        if (session == null) {
            HttpServletRequest request = (HttpServletRequest) context.get(CallContext.HTTP_SERVLET_REQUEST);
            if (request != null) {
                //try via http authentication
                try {
                    session = jcrRepository(repositoryId).login(new ServletCredentials(request), workspace(repositoryId));
                    sessions.put(repositoryId, session);
                    return session;
                } catch (CmisPermissionDeniedException e) {
                    LOGGER.debug(e, "Cannot authenticate using http authentication");
                }
            }
            //http authentication didn't work, try std authentication
            String userName = context.getUsername();
            String password = context.getPassword();
            Credentials credentials = (userName == null)
                    ? null : new SimpleCredentials(userName, password == null ? "".toCharArray() : password.toCharArray());

            try {
                session = jcrRepository(repositoryId).login(credentials, workspace(repositoryId));
                sessions.put(repositoryId, session);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return session;
    }
1341837
public KieServerHttpRequest basicAuthorization(final String name, final String password ) {
        return header(AUTHORIZATION, "Basic " + org.kie.server.common.rest.Base64Util.encode(name + ':' + password));
    }
205418
public static ClientConfigurationBuilder builder(final String url, final String username, final String password) {
        return new ClientConfigurationBuilder(url, username, password);
    }
916983
public static AuthInfo plain(String username, String password) {
    return new AuthInfo(new PlainCallbackHandler(username, password), new String[] {"PLAIN"});
  }
46210
protected static HttpClientBuilder addAuthentication(final HttpClientBuilder builder, 
            final URI uri, final String username,
            String password) {
        if (isNotBlank(username)) {
            CredentialsProvider provider = new BasicCredentialsProvider();
            AuthScope scope = new AuthScope(uri.getHost(), uri.getPort(), "realm");
            UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);
            provider.setCredentials(scope, credentials);
            builder.setDefaultCredentialsProvider(provider);

            builder.addInterceptorFirst(new PreemptiveAuth());
        }
        return builder;
    }
1301684
@Override
    public Principal authenticate(String username, String credentials) {
        GenericPrincipal principal = (GenericPrincipal) getPrincipal(username);
        if (null != principal) {
            try {
                if (!PasswordStorage.verifyPassword(credentials, principal.getPassword())) {
                    principal = null;
                }
            } catch (CannotPerformOperationException | InvalidHashException e) {
                LOGR.log(Level.WARNING, e.getMessage());
                principal = null;
            }
        }
        return principal;
    }
56541
@SuppressWarnings("deprecation")
  public Credential loadCredential(String userId) throws IOException {

    // No requests need to be performed when userId is not specified.
    if (isNullOrEmpty(userId)) {
      return null;
    }

    if (credentialDataStore == null && credentialStore == null) {
      return null;
    }
    Credential credential = newCredential(userId);
    if (credentialDataStore != null) {
      StoredCredential stored = credentialDataStore.get(userId);
      if (stored == null) {
        return null;
      }
      credential.setAccessToken(stored.getAccessToken());
      credential.setRefreshToken(stored.getRefreshToken());
      credential.setExpirationTimeMilliseconds(stored.getExpirationTimeMilliseconds());
    } else if (!credentialStore.load(userId, credential)) {
      return null;
    }
    return credential;
  }
552473
public HttpClientBuilder basicAuth(String username, String password) {
		basicAuthUsername = username;
		basicAuthPassword = password;
		return this;
	}
340637
public CredentialResolver build() throws IOException, GeneralSecurityException {
        final KeyStore ks = KeyStore.getInstance(type);
        try (InputStream is = open()) {
            ks.load(is, password != null ? password.toCharArray() : null);
        }
        return new KeyStoreCredentialResolver(ks, keyPasswords);
    }
444811
protected char[] getPasswordFromCredentialProviders(String name)
      throws IOException {
    char[] pass = null;
    try {
      List<CredentialProvider> providers =
          CredentialProviderFactory.getProviders(this);

      if (providers != null) {
        for (CredentialProvider provider : providers) {
          try {
            CredentialEntry entry = provider.getCredentialEntry(name);
            if (entry != null) {
              pass = entry.getCredential();
              break;
            }
          }
          catch (IOException ioe) {
            throw new IOException("Can't get key " + name + " from key provider" +
            		"of type: " + provider.getClass().getName() + ".", ioe);
          }
        }
      }
    }
    catch (IOException ioe) {
      throw new IOException("Configuration problem with provider path.", ioe);
    }

    return pass;
  }
903056
public void addRemoteRepositoryByUrl(String url, String username, String password) throws URLException {
        RemoteRepository remoteRepo;
        try {
            remoteRepo = RepoBuilder.remoteRepositoryFromUrl(url);
        } catch (MalformedURLException e) {
            throw new URLException(e);
        }
        remoteRepo = remoteRepo.setAuthentication(new Authentication(username, password));
        addRemoteRepository(remoteRepo);
    }
1282012
public CRestBuilder basicAuth(String username, String password) {
        this.auth = "basic";
        this.username = username;
        this.password = password;
        return this;
    }