亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? usermanager.java

?? 一個java方面的消息訂閱發送的源碼
?? JAVA
字號:
/**
 * Redistribution and use of this software and associated documentation
 * ("Software"), with or without modification, are permitted provided
 * that the following conditions are met:
 *
 * 1. Redistributions of source code must retain copyright
 *    statements and notices.  Redistributions must also contain a
 *    copy of this document.
 *
 * 2. Redistributions in binary form must reproduce the
 *    above copyright notice, this list of conditions and the
 *    following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. The name "Exolab" must not be used to endorse or promote
 *    products derived from this Software without prior written
 *    permission of Exoffice Technologies.  For written permission,
 *    please contact info@exolab.org.
 *
 * 4. Products derived from this Software may not be called "Exolab"
 *    nor may "Exolab" appear in their names without prior written
 *    permission of Exoffice Technologies. Exolab is a registered
 *    trademark of Exoffice Technologies.
 *
 * 5. Due credit should be given to the Exolab Project
 *    (http://www.exolab.org/).
 *
 * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
 * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * Copyright 2003-2004 (C) Exoffice Technologies Inc. All Rights Reserved.
 *
 * $Id: UserManager.java,v 1.1 2004/11/26 01:50:39 tanderson Exp $
 */
package org.exolab.jms.authentication;

import java.sql.Connection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;

import javax.transaction.TransactionManager;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.exolab.jms.service.ServiceException;
import org.exolab.jms.config.Configuration;
import org.exolab.jms.config.ConfigurationManager;
import org.exolab.jms.config.SecurityConfiguration;
import org.exolab.jms.persistence.DatabaseService;
import org.exolab.jms.persistence.PersistenceAdapter;
import org.exolab.jms.persistence.SQLHelper;


/**
 * The user manager is responsible for creating and managing users.
 *
 * @version     $Revision: 1.1 $ $Date: 2004/11/26 01:50:39 $
 * @author      <a href="mailto:knut@lerpold.no">Knut Lerpold</a>
 */
public class UserManager {

    /**
     * A list of all users are maintained
     * in this data structure.
     */
    private HashMap _userCache = new HashMap();

    /**
     * The logger
     */
    private static final Log _log = LogFactory.getLog(UserManager.class);


    /**
     * Construct a new <code>UserManager</code>
     *
     * @throws ServiceException if the service cannot be initialised
     */
    protected UserManager() throws ServiceException {
        init();
    }

    /**
     * Create a new user
     *
     * @param user the userobject containing username and password
     * @return <code>true</code> if the user is created
     * otherwise <code>false</code>
     */
    public synchronized boolean createUser(User user) {
        boolean success = false;
        PersistenceAdapter adapter = DatabaseService.getAdapter();

        if (_userCache.get(user.getUsername()) == null) {
            Connection connection = null;
            try {
                connection = DatabaseService.getConnection();
                adapter.addUser(connection, user);
                addToUserCache(user);
                connection.commit();
                success = true;
            } catch (Exception exception) {
                _log.error("Failed to create user", exception);
                SQLHelper.rollback(connection);
            } finally {
                SQLHelper.close(connection);
            }
        }

        return success;
    }

    /**
     * Update user.
     * Only possible update is password.
     *
     * @param user the userobject containing the username
     * @return <code>true</code> if password is updated
     * otherwise <code>false</code>
     */
    public synchronized boolean updateUser(User user) {
        boolean success = false;
        PersistenceAdapter adapter = DatabaseService.getAdapter();

        if (_userCache.get(user.getUsername()) != null) {
            Connection connection = null;
            try {
                connection = DatabaseService.getConnection();
                adapter.updateUser(connection, user);
                connection.commit();
                addToUserCache(user);
                success = true;
            } catch (Exception exception) {
                _log.error("Failed to update user", exception);
                SQLHelper.rollback(connection);
            } finally {
                SQLHelper.close(connection);
            }
        }

        return success;
    }

    /**
     * Delete a users
     *
     * @param user the userobject containing the username
     * @return <code>true</code> if the is removed
     * otherwise <code>false</code>
     */
    public synchronized boolean deleteUser(User user) {
        boolean success = false;
        PersistenceAdapter adapter = DatabaseService.getAdapter();

        if (_userCache.get(user.getUsername()) != null) {
            Connection connection = null;
            try {
                connection = DatabaseService.getConnection();
                adapter.removeUser(connection, user);
                removeFromUserCache(user);
                success = true;
                connection.commit();
            } catch (Exception exception) {
                _log.error("Failed to remove user", exception);
                SQLHelper.rollback(connection);
            } finally {
                SQLHelper.close(connection);
            }
        }
        return success;
    }

    /**
     * Return a user
     *
     * @param user the userobject containing the username
     * @return a User
     */
    public synchronized User getUser(User user) {
        return (User) _userCache.get(user.getUsername());
    }

    /**
     * Return a list of user names currently supported by the user
     * manager. This includes all types of users.
     *
     * @return an enumeration of the user names
     */
    public Iterator userNames() {
        return _userCache.keySet().iterator();
    }

    /**
     * Destroy this manager. This is brutal and final
     */
    public synchronized void destroy() {
        _userCache.clear();
        _userCache = null;
    }

    /**
     * Determines if a user's name and password are valid
     *
     * @param username the user's name
     * @param password the user's password
     * @return <code>true</code> if the name and password are valid,
     * otherwise <code>false</code>
     */
    public synchronized boolean validateUser(String username,
                                             String password) {
        boolean result = false;

        SecurityConfiguration config =
            ConfigurationManager.getConfig().getSecurityConfiguration();
        if (!config.getSecurityEnabled()) {
            // security disabled
            result = true;
        }

        User user = (User) _userCache.get(username);
        if (user != null && user.getPassword().equals(password)) {
            result = true;
        }

        return result;
    }

    /**
     * Initialise user manager.
     *
     * @throws ServiceException if the user manager cannot be initialised
     */
    protected void init() throws ServiceException {
        Connection connection = null;
        TransactionManager tm = null;
        try {
            connection = DatabaseService.getConnection();

            Enumeration iter =
                DatabaseService.getAdapter().getAllUsers(connection);
            connection.commit();

            while (iter.hasMoreElements()) {
                // add each user to the cache
                User user = (User) iter.nextElement();
                addToUserCache(user);
            }
        } catch (Exception exception) {
            SQLHelper.rollback(connection);
            _log.error("Failed to initialise UserManager", exception);
            throw new ServiceException(exception);
        } finally {
            SQLHelper.close(connection);
        }

        registerConfiguredUsers();
    }

    /**
     * Add the specified entry to the user cache, if it doesn't
     * already exist.
     *
     * @param user - user to add
     */
    protected void addToUserCache(User user) {
        if (!_userCache.containsKey(user.getUsername())) {
            _userCache.put(user.getUsername(), user);
        }
    }

    /**
     * Remove the specified user from the cache
     *
     * @param user the user to remove
     */
    protected void removeFromUserCache(User user) {
        _userCache.remove(user.getUsername());
    }

    /**
     * Registers users specified in the configuration
     */
    protected void registerConfiguredUsers() {
        Configuration config = ConfigurationManager.getConfig();
        if (config.getUsers() != null) {
            org.exolab.jms.config.User[] users = config.getUsers().getUser();
            for (int i = 0; i < users.length; ++i) {
                User user = new User(users[i].getName(),
                    users[i].getPassword());
                createUser(user);
            }
        }
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 亚洲一区在线电影| 奇米色一区二区三区四区| 国产成人精品一区二区三区四区| 日本丶国产丶欧美色综合| 欧美成人一区二区三区| 亚洲一区二区三区国产| 国产成人av资源| 日韩一区二区在线观看视频| 亚洲桃色在线一区| 国产盗摄一区二区| 欧美一区二区在线免费播放 | 国内精品免费**视频| 色猫猫国产区一区二在线视频| 一区二区三区在线观看网站| 久久精品国产99| 欧美无砖砖区免费| 亚洲视频每日更新| 成人一级片在线观看| 欧美成人三级在线| 青青草视频一区| 777久久久精品| 亚洲福利视频三区| 日本精品裸体写真集在线观看| 久久久av毛片精品| 国产一区欧美日韩| 精品剧情在线观看| 久久国产尿小便嘘嘘| 91精品国产91综合久久蜜臀| 亚洲成人免费观看| 欧美少妇xxx| 一区二区三区四区国产精品| 97久久精品人人做人人爽| 中文字幕精品综合| 91网址在线看| 亚洲裸体在线观看| 一本色道久久综合亚洲精品按摩 | www.欧美日韩国产在线| 久久久久久97三级| 国产精品系列在线播放| 中文乱码免费一区二区| www.亚洲人| 亚洲一区二区av电影| 欧美日本在线一区| 捆绑调教美女网站视频一区| 日韩你懂的在线播放| 国产在线视视频有精品| 国产女主播视频一区二区| 成人av在线资源网| 亚洲综合精品久久| 日韩一区二区三区四区五区六区| 狠狠色狠狠色合久久伊人| 国产精品激情偷乱一区二区∴| 成人av一区二区三区| 亚洲综合在线免费观看| 欧美区视频在线观看| 国内精品国产三级国产a久久| 国产欧美精品一区二区色综合| 成人av手机在线观看| 亚洲一区二区三区四区五区中文| 91精品婷婷国产综合久久竹菊| 国产一区 二区| 亚洲欧洲综合另类在线| 91精品国产福利在线观看| 丁香婷婷综合网| 亚洲444eee在线观看| 欧美v亚洲v综合ⅴ国产v| 成人一区二区三区中文字幕| 成人性生交大合| 亚洲午夜一区二区| 久久蜜臀中文字幕| 色婷婷综合久久久中文一区二区 | 成人国产精品视频| 午夜伊人狠狠久久| 国产精品视频你懂的| 欧美三级中文字幕在线观看| 国产乱子轮精品视频| 一区二区日韩av| 久久久久国产精品人| 欧美日韩精品一区二区天天拍小说| 久久99久久99精品免视看婷婷 | 色呦呦一区二区三区| 久久99精品久久久久久动态图| 亚洲视频免费在线观看| 久久综合久久鬼色中文字| 欧美探花视频资源| 成人黄色片在线观看| 免费av成人在线| 亚洲精品国产视频| 中文字幕第一页久久| 精品国产一区二区三区久久久蜜月| 色一情一乱一乱一91av| 国产精品99久| 久久99久久99精品免视看婷婷 | 欧美精品在线视频| 色综合久久中文综合久久97| 国产曰批免费观看久久久| 亚洲一区二区三区小说| 亚洲人成精品久久久久久| 久久精品亚洲乱码伦伦中文| 日韩欧美成人一区| 欧美精品免费视频| 欧美撒尿777hd撒尿| 91免费视频观看| 成人激情小说网站| 国产99久久久精品| 韩国中文字幕2020精品| 免费成人你懂的| 日韩av在线免费观看不卡| 亚洲国产日韩综合久久精品| 亚洲码国产岛国毛片在线| 中文字幕字幕中文在线中不卡视频| 国产欧美一区二区精品久导航 | 欧美第一区第二区| 欧美一级久久久久久久大片| 4438成人网| 91麻豆精品国产91久久久久久久久 | 欧美在线三级电影| 欧美在线小视频| 精品视频一区二区不卡| 欧美亚洲国产一区在线观看网站| 色噜噜狠狠成人网p站| 99精品欧美一区二区蜜桃免费| 99re成人精品视频| 欧美成人a视频| 久久蜜桃av一区精品变态类天堂 | 亚洲日韩欧美一区二区在线| 中文字幕色av一区二区三区| 国产精品久久一卡二卡| 亚洲欧洲精品一区二区三区不卡| 亚洲视频网在线直播| 亚洲一区二区三区精品在线| 日韩激情视频在线观看| 久久精品久久综合| 国产精品羞羞答答xxdd| 91免费版在线| 欧美理论电影在线| 久久综合国产精品| 综合精品久久久| 婷婷久久综合九色综合绿巨人| 天天综合天天综合色| 九九国产精品视频| 成人手机在线视频| 在线免费观看日韩欧美| 欧美精品777| 国产性做久久久久久| 亚洲女同一区二区| 日本欧美加勒比视频| 国产成人自拍在线| 在线一区二区三区| 欧美r级电影在线观看| 国产精品丝袜久久久久久app| 一区二区三区中文免费| 美女在线一区二区| 成年人网站91| 欧美高清激情brazzers| 国产亚洲一本大道中文在线| 亚洲国产日韩综合久久精品| 久久91精品久久久久久秒播| 成人av电影免费在线播放| 欧美日韩美女一区二区| 久久精品亚洲乱码伦伦中文| 亚洲国产成人porn| 懂色av一区二区夜夜嗨| 欧美精品一级二级三级| 中文字幕国产一区| 蜜臀av性久久久久蜜臀aⅴ四虎| 高清免费成人av| 制服.丝袜.亚洲.中文.综合| 国产精品情趣视频| 日韩不卡一二三区| 91精品办公室少妇高潮对白| 久久亚洲一级片| 首页欧美精品中文字幕| 成人av资源站| 精品91自产拍在线观看一区| 亚洲国产美女搞黄色| va亚洲va日韩不卡在线观看| 精品欧美乱码久久久久久1区2区| 亚洲伊人色欲综合网| k8久久久一区二区三区| 精品日韩一区二区三区| 亚洲国产欧美在线| 91丨九色丨黑人外教| 国产丝袜在线精品| 国产一区欧美一区| 精品国产自在久精品国产| 强制捆绑调教一区二区| 欧美精品 国产精品| 亚洲国产成人精品视频| 在线日韩一区二区| 亚洲精品综合在线| 99久久精品免费观看| 国产精品区一区二区三区| 成人一区在线看| 国产欧美日韩精品一区| 国产999精品久久久久久| 久久亚洲捆绑美女| 国产麻豆91精品| 国产色综合久久|