passwordconfig.java

来自「java编程最好的书籍,感觉对初学者或者中级java人员帮助很大」· Java 代码 · 共 55 行

JAVA
55
字号
package examples;

import java.util.Hashtable;
import javax.security.auth.login.*;

/**
 * Sample configuration class for JAAS user authentication.
 * This class is useful because it can be rewritten to use
 * different login modules without affecting client code.
 *
 * For example, we could have a login module that did
 * username/password authentication, and another that did
 * public/private key certificate authentication.
 */
public class PasswordConfig extends Configuration {

 /**
  * A configuration class must have a no-argument constructor
  */
 public PasswordConfig() {}

 /**
  * This method chooses the proper login module.
  */
 public AppConfigurationEntry[]
   getAppConfigurationEntry(String applicationName)
 {
  /*
   * Return the one login module we've written, which uses
   * username/password authentication.
   *
   * - The "REQUIRED" flag says that we require that this
   *   login module succeed for authentication.
   * - The new hashtable is a hashtable of options that
   *   our login module will receive.  For example, we might
   *   define an option that turns debugging on.  Our login
   *   module would inspect this hashtable and start logging
   *   output.
   */
  AppConfigurationEntry[] loginModules
   = new AppConfigurationEntry[1];
  loginModules[0] = new AppConfigurationEntry(
   "examples.PasswordLoginModule",
   AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
   new Hashtable());
  return loginModules;
 }

 /**
  * Refresh and reload the Configuration object by reading
  * all of the login configurations again.
  */
 public void refresh() {}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?