code: @Nonnull
    public static AuthIdentificationResult validateLoginCredentialsAndCreateToken (@Nonnull final IAuthCredentials aCredentials)
    {
      ValueEnforcer.notNull (aCredentials, "Credentials");
  
      // validate credentials
      final ICredentialValidationResult aValidationResult = AuthCredentialValidatorManager.validateCredentials (aCredentials);
      if (aValidationResult.isFailure ())
      {
        if (LOGGER.isWarnEnabled ())
          LOGGER.warn ("Credentials have been rejected: " + aCredentials);
        return AuthIdentificationResult.createFailure (aValidationResult);
      }
  
      if (LOGGER.isDebugEnabled ())
        LOGGER.debug ("Credentials have been accepted: " + aCredentials);
  
      // try to get AuthSubject from passed credentials
      final IAuthSubject aSubject = AuthCredentialToSubjectResolverManager.getSubjectFromCredentials (aCredentials);
      if (aSubject != null)
      {
        if (LOGGER.isDebugEnabled ())
          LOGGER.debug ("Credentials " + aCredentials + " correspond to subject " + aSubject);
      }
      else
      {
        if (LOGGER.isErrorEnabled ())
          LOGGER.error ("Failed to resolve credentials " + aCredentials + " to an auth subject!");
      }
  
      // Create the identification element
      final AuthIdentification aIdentification = new AuthIdentification (aSubject);
  
      // create the token (without expiration seconds)
      final IAuthToken aNewAuthToken = AuthTokenRegistry.createToken (aIdentification,
                                                                      IAuthToken.EXPIRATION_SECONDS_INFINITE);
      return AuthIdentificationResult.createSuccess (aNewAuthToken);
    }
docs: Validate the login credentials, try to resolve the subject and create a
  token upon success.
  
  @param aCredentials
  The credentials to validate. If <code>null</code> it is treated as
  error.
  @return Never <code>null</code>.