Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2014 Philip Helger ( philip[at]helger[dot]com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package com.helger.appbasics.auth.identify;
This is the main class for creating an com.helger.appbasics.auth.token.IAuthToken from credentials.

Philip Helger
public final class AuthIdentificationManager
  private static final Logger s_aLogger = LoggerFactory.getLogger (AuthIdentificationManager.class);

Validate the login credentials, try to resolve the subject and create a token upon success.

aDisplayLocale Display locale.
aCredentials The credentials to validate. If null it is treated as error.
Never null.
  public static AuthIdentificationResult validateLoginCredentialsAndCreateToken (@Nonnull final Locale aDisplayLocale,
                                                                                 @Nonnull final IAuthCredentials aCredentials)
    ValueEnforcer.notNull (aCredentials"Credentials");
    // validate credentials
    final CredentialValidationResult aValidationResult = AuthCredentialValidatorManager.validateCredentials (aDisplayLocale,
    if (aValidationResult.isFailure ())
      .warn ("Credentials have been rejected: " + aCredentials);
      return new AuthIdentificationResult (aValidationResult);
    if (.isDebugEnabled ())
      .debug ("Credentials have been accepted: " + aCredentials);
    // try to get AuthSubject from passed credentials
    final IAuthSubject aSubject = AuthCredentialToSubjectResolverManager.getSubjectFromCredentials (aCredentials);
    if (aSubject != null)
      .info ("Credentials " + aCredentials + " correspond to subject " + aSubject);
    // create the token (without expiration seconds)
    final IAuthToken aNewAuthToken = AuthTokenRegistry.createToken (new AuthIdentification (aSubject),
    return new AuthIdentificationResult (aNewAuthToken);
New to GrepCode? Check out our FAQ X