/**
  * Instantiate a new {@code LoginContext} object with a name and a {@code Subject} object.
  *
  * <p>
  *
  * @param name the name used as the index into the {@code Configuration}.
  *     <p>
  * @param subject the {@code Subject} to authenticate.
  * @exception LoginException if the caller-specified {@code name} does not appear in the {@code
  *     Configuration} and there is no {@code Configuration} entry for "<i>other</i>", if the
  *     caller-specified {@code subject} is {@code null}, or if the
  *     <i>auth.login.defaultCallbackHandler</i> security property was set, but the implementation
  *     class could not be loaded.
  *     <p>
  * @exception SecurityException if a SecurityManager is set and the caller does not have
  *     AuthPermission("createLoginContext.<i>name</i>"), or if a configuration entry for
  *     <i>name</i> does not exist and the caller does not additionally have
  *     AuthPermission("createLoginContext.other")
  */
 public LoginContext(String name, Subject subject) throws LoginException {
   init(name);
   if (subject == null)
     throw new LoginException(ResourcesMgr.getString("invalid.null.Subject.provided"));
   this.subject = subject;
   subjectProvided = true;
   loadDefaultCallbackHandler();
 }
  /**
   * Instantiate a new {@code LoginContext} object with a name, a {@code Subject} to be
   * authenticated, a {@code CallbackHandler} object, and a login {@code Configuration}.
   *
   * <p>
   *
   * @param name the name used as the index into the caller-specified {@code Configuration}.
   *     <p>
   * @param subject the {@code Subject} to authenticate, or {@code null}.
   *     <p>
   * @param callbackHandler the {@code CallbackHandler} object used by LoginModules to communicate
   *     with the user, or {@code null}.
   *     <p>
   * @param config the {@code Configuration} that lists the login modules to be called to perform
   *     the authentication, or {@code null}.
   * @exception LoginException if the caller-specified {@code name} does not appear in the {@code
   *     Configuration} and there is no {@code Configuration} entry for "<i>other</i>".
   *     <p>
   * @exception SecurityException if a SecurityManager is set, <i>config</i> is {@code null}, and
   *     either the caller does not have AuthPermission("createLoginContext.<i>name</i>"), or if a
   *     configuration entry for <i>name</i> does not exist and the caller does not additionally
   *     have AuthPermission("createLoginContext.other")
   * @since 1.5
   */
  public LoginContext(
      String name, Subject subject, CallbackHandler callbackHandler, Configuration config)
      throws LoginException {
    this.config = config;
    if (config != null) {
      creatorAcc = java.security.AccessController.getContext();
    }

    init(name);
    if (subject != null) {
      this.subject = subject;
      subjectProvided = true;
    }
    if (callbackHandler == null) {
      loadDefaultCallbackHandler();
    } else if (creatorAcc == null) {
      this.callbackHandler =
          new SecureCallbackHandler(java.security.AccessController.getContext(), callbackHandler);
    } else {
      this.callbackHandler = callbackHandler;
    }
  }
 /**
  * Instantiate a new {@code LoginContext} object with a name.
  *
  * @param name the name used as the index into the {@code Configuration}.
  * @exception LoginException if the caller-specified {@code name} does not appear in the {@code
  *     Configuration} and there is no {@code Configuration} entry for "<i>other</i>", or if the
  *     <i>auth.login.defaultCallbackHandler</i> security property was set, but the implementation
  *     class could not be loaded.
  *     <p>
  * @exception SecurityException if a SecurityManager is set and the caller does not have
  *     AuthPermission("createLoginContext.<i>name</i>"), or if a configuration entry for
  *     <i>name</i> does not exist and the caller does not additionally have
  *     AuthPermission("createLoginContext.other")
  */
 public LoginContext(String name) throws LoginException {
   init(name);
   loadDefaultCallbackHandler();
 }