code: public Future<AuthenticationResult> acquireToken(final String resource,
              final String clientId, final String username,
              final String password, final AuthenticationCallback callback) {
          if (StringHelper.isBlank(resource)) {
              throw new IllegalArgumentException("resource is null or empty");
          }
  
          if (StringHelper.isBlank(clientId)) {
              throw new IllegalArgumentException("clientId is null or empty");
          }
  
          if (StringHelper.isBlank(username)) {
              throw new IllegalArgumentException("username is null or empty");
          }
  
          ClientAuthenticationPost clientAuth = new ClientAuthenticationPost(ClientAuthenticationMethod.NONE, new ClientID(clientId));
  
          if (password != null) {
              return this.acquireToken(new AdalOAuthAuthorizationGrant(
                      new ResourceOwnerPasswordCredentialsGrant(username, new Secret(
                              password)), resource), clientAuth, callback);
          } else {
              return this.acquireToken(new AdalIntegratedAuthorizationGrant(username, resource), clientAuth, callback);
          }
      }
docs: Acquires a security token from the authority using a username/password flow.
  
  @param clientId
  Name or ID of the client requesting the token.
  @param resource
  Identifier of the target resource that is the recipient of the
  requested token.
  @param username
  Username of the managed or federated user.
  @param password
  Password of the managed or federated user.
  If null, integrated authentication will be used.
  @param callback
  optional callback object for non-blocking execution.
  @return A {@link Future} object representing the
  {@link AuthenticationResult} of the call. It contains Access
  Token, Refresh Token and the Access Token's expiration time.