⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s7turnappservrealm.java.netbeans-base

📁 JSF with Maven, Auth module
💻 NETBEANS-BASE
字号:
/* * OBAppservRealm.java * * Created on August 1, 2007, 10:21 AM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */package com.s7turn.security;import com.sun.appserv.security.AppservRealm;import com.sun.enterprise.connectors.ConnectorRuntime;import com.sun.logging.LogDomains;import com.sun.enterprise.security.auth.realm.BadRealmException;import com.sun.enterprise.security.auth.realm.NoSuchRealmException;import com.sun.enterprise.security.auth.realm.NoSuchUserException;import java.util.logging.Level;import java.util.logging.Logger;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.text.NumberFormat;import java.util.Enumeration;import java.util.Properties;import java.util.Vector;import java.util.logging.Level;import java.util.logging.Logger;import javax.sql.DataSource;/** * Realm class for Glassfish security * @author ansonau */public class S7TurnAppservRealm extends com.sun.appserv.security.AppservRealm{        private static Logger logger = LogDomains.getLogger (LogDomains.SECURITY_LOGGER);    /**     * Default AUTH TYPE     */    private static String defaultAuthtype = "simplecustom";    /**     * Default Authe Type para     */    private static String defaultAuthtypeparam = "auth-type";    /**     * Runtime Auth type     */    private String authType = null;    /**     * JNDI for cobrand     */    private String dsJndi = "jndi/cobrandpsDS";            /**     * Logger     */        /**     * This method is invoked during server startup when the realm is     * initially loaded.     * The props argument contains the properties defined     * for this realm in domain.xml.     * The realm can do any initialization it needs in this method.     * If the method returns without throwing an exception,     * J2EE Application Server assumes the realm is ready     * to service authentication requests.     * If an exception is thrown, the realm is disabled,     * check the server.log for messages.     * @param props Properties for this realm     * @throws com.sun.enterprise.security.auth.realm.BadRealmException Throw when the realm config has error     * @throws com.sun.enterprise.security.auth.realm.NoSuchRealmException Throw when realm not found     */    public void init (Properties props) throws BadRealmException, NoSuchRealmException    {                super.init (props);        log ("init()...");                               /*        * Set the jaas context, otherwise server doesn't indentify the login module.        * jaas-context is the property specified in domain.xml and        * is the name corresponding to LoginModule        * config/login.conf        */        String jaasCtx = props.getProperty (AppservRealm.JAAS_CONTEXT_PARAM);        this.setProperty (AppservRealm.JAAS_CONTEXT_PARAM, jaasCtx);               /*        * Get any other interested properties from configuration file - domain.xml        * say auth-type defined in domain.xml.        */        String authTypeProp = props.getProperty (defaultAuthtypeparam);        if (authTypeProp!=null)        {            this.authType = authTypeProp;        }        else        {            this.authType = defaultAuthtype;        }            }                /**     * Return a short description supported authentication by this realm.     *     * @return Description of the kind of authentication that is directly     *     supported by this realm.     */    public String getAuthType ()    {        return this.authType;    }            /**     * Returns enumeration of groups that a particular user belongs to.     * @param user User name     * @exception NoSuchUserException Throw when user not found     * @return Return the groups that the user belong to     */    public Enumeration getGroupNames (String user) throws NoSuchUserException    {        return null;    }            /**     * Helper methods.     *      * Simple message print method used throught the program     * @param mesg Message to print     */    public static void log (String fmt, Object... param)    {        //logger.log (Level.INFO, "SimpleCustomRealm:"+mesg );        String mesg = String.format(fmt, param);        //System.out.println(mesg);        logger.info(mesg);            }        }

⌨️ 快捷键说明

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