package oracle.sample.dbloginmodule.interfaces;

/*
 * @(#)DBProcLM.java  1.0 March 2005
 *
 * Copyright (c) 2001-2005 by Oracle. All Rights Reserved.
 * 
 * Oracle grants you ("Licensee") a non-exclusive, royalty free, license to use,
 * modify and redistribute this software in source and binary code form,
 * provided that i) this copyright notice and license appear on all copies of
 * the software; and ii) Licensee does not utilize the software in a manner
 * which is disparaging to Oracle.
 * 
 * This software is provided "AS IS," without a warranty of any kind. ALL
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
 * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
 * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. ORACLE AND ITS LICENSORS SHALL NOT BE
 * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
 * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL ORACLE OR ITS
 * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
 * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
 * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
 * OR INABILITY TO USE SOFTWARE, EVEN IF ORACLE HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES.
 * 
 * This software is not designed or intended for use in on-line control of
 * aircraft, air traffic, aircraft navigation or aircraft communications; or in
 * the design, construction, operation or maintenance of any nuclear
 * facility. Licensee represents and warrants that it will not use or
 * redistribute the Software for such purposes.
 */

import java.security.Principal;
import java.util.Map;
import javax.security.auth.Subject; 
import javax.security.auth.spi.LoginModule;

/**
* @author   Frank Nimphius
* @version  1.0
*/ 
public interface DBLoginModule extends LoginModule 
{
  
  // prefix to be used when writing log messages. Can be overridden
  // in LM implementation
  static final String LOGGING_PREFIX="[DBLoginModule]";
  
  // callback handler settings
  static final int NUM_CALLBACKS = 2;
  static final int USERNAME_CALLBACK_INDEX = 0;
  static final int PASSWORD_CALLBACK_INDEX = 1;
  
  // logging levels
  public final static int LOG_ALL =  0;
  public final static int LOG_AUTH = 1;
  
  // the message keys

  public final String MESSAGE_KEY_NO_CALLBACK_HANDLER									    = "Missing CallbackHandler";

  /**
   * 
   * @return javax.security.auth.Subject
   */
  Subject getSubject();
  /**
   * 
   * @return java.util.Map
   */
  Map getOptions();
  /**
   * 
   * @return java.util.Map
   */
  Map getSharedState();
  /**
   * 
   * @return String
   */
  String getUsername();
  /**
   * 
   * @return String
   */
  String getConnectInformation();
  /**
   * 
   * @return boolean Method that instatiates the logger class that is provided 
   * in the option of the LoginModule configuration. All logger classes must 
   * implement the LMLogger interface. The configuration is performed via the 
   * "logger_class" option in the LM configurations
   */
  boolean setLogger();
  
  /**
   * Method that is called within a program to perform the logging action. Having 
   * this method being separate from the setLogger() method allows to add application
   * (LM) specific actions to be performed if required. The log method also evaluates
   * the log level for printing.
   * 
   * @param prt message that should be logged
   * @param level DBLoginModuleConstants.LOG_AUTH or LOG_ALL
   */
  void log(String prt, int level);
}