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

📄 activedirectoryuser.java

📁 这是linux下ssl vpn的实现程序
💻 JAVA
字号:
/*
 *  SSL-Explorer
 *
 *  Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2 of
 *  the License, or (at your option) any later version.
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public
 *  License along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
			
package com.sslexplorer.activedirectory;

import java.util.Date;
import java.util.Properties;

import javax.security.auth.login.LoginContext;

import com.sslexplorer.security.DefaultUser;
import com.sslexplorer.security.User;

/**
 * Implementation of {@link User} that uses an Active Directory Account for
 * its attributes.
 * 
 * @author Lee Painter <a href="mailto:lee@3sp.com">&lt;lee@3sp.com&gt;</a>
 * @author Brett Smith <a href="mailto:brett@3sp.com">&lt;brett@3sp.com&gt;</a>
 * @version $Revision: 1.16 $
 */

public class ActiveDirectoryUser extends DefaultUser {

    //	Private instance variables

    private String DN;
    private LoginContext loginContext;
    
    /**
     * Constructor
     * 
     * @param username username
     * @param email email address
     * @param fullname full name
     * @param lastPasswordChange date of last password change
     * @param attributes additional attributes
     */
    public ActiveDirectoryUser(String username, String email, String fullname, Date lastPasswordChange, Properties attributes) {
        super(username, email, fullname, lastPasswordChange, attributes);
    }

    /**
     * Constructor. Only the username is set, all other attributes are null
     * or empty.
     * 
     * @param username userna
     */
    public ActiveDirectoryUser(String username) {
        this(username, null, null, null, new Properties());
    }

    /* (non-Javadoc)
     * @see com.sslexplorer.security.User#getHomeNetworkPlaceUri()
     */
    public String getHomeNetworkPlaceUri() {
        String dir = (String)getAttributes().getProperty(User.USER_ATTR_HOME_DIRECTORY);
        if (dir != null) {
            // translate from a UNC path to SSL Explorer's network place URI
            try {
                return "/fs/cifs/" + dir.substring(2).replace('\\', '/') + "/";
            } catch (Throwable t) {
            }
        }
        return null;
    }
    
    /**
     * Get if the user is part of the specified role.
     * 
     * @param rolename role
     * @return <code>true<code> if the user is part of the specified role.
     */
    boolean containsRole(String rolename) {
        for (int i = 0; i < roles.length; i++) {
            if (roles[i].getPrincipalName().equals(rolename))
                return true;
        }

        return false;
    }

    /**
     * Set the LoginContext for this user.
     * 
     * @param loginContext login context
     */
    void setLoginContext(LoginContext loginContext) {
        this.loginContext = loginContext;
    }

    /**
     * Get the LoginContext for this user.
     * 
     * @return login context
     */
    LoginContext setLoginContext() {
        return loginContext;
    }

    /**
     * Set the DN
     * @param DN DN
     */
    void setDN(String DN) {
        this.DN = DN;        
    }

    /**
     * Get the DN
     * 
     * @return DN
     */
    String getDN() {
        return DN;
    }


}

⌨️ 快捷键说明

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