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

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

?? sampleloginmodule.java

?? 基于XACML的訪問控制SampleLoginMoudler.java
?? JAVA
字號:
/*
 * @(#)SampleLoginModule.java	1.18 00/01/11
 *
 * Copyright 2000-2002 Sun Microsystems, Inc. All Rights Reserved.
 *
 * Redistribution and use in source and binary forms, with or 
 * without modification, are permitted provided that the following 
 * conditions are met:
 * 
 * -Redistributions of source code must retain the above copyright  
 * notice, this  list of conditions and the following disclaimer.
 * 
 * -Redistribution in binary form must reproduct the above copyright 
 * notice, this list of conditions and the following disclaimer in 
 * the documentation and/or other materials provided with the 
 * distribution.
 * 
 * Neither the name of Sun Microsystems, Inc. or the names of 
 * contributors may be used to endorse or promote products derived 
 * from this software without specific prior written permission.
 * 
 * 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. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY 
 * DAMAGES OR LIABILITIES  SUFFERED BY LICENSEE AS A RESULT OF  OR 
 * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR 
 * ITS DERIVATIVES. IN NO EVENT WILL SUN 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 SUN HAS BEEN 
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
 * 
 * You acknowledge that Software is not designed, licensed or 
 * intended for use in the design, construction, operation or 
 * maintenance of any nuclear facility. 
 */

package sample.module;

import java.util.*;
import java.io.IOException;
import javax.security.auth.*;
import javax.security.auth.callback.*;
import javax.security.auth.login.*;
import javax.security.auth.spi.*;
import sample.principal.SamplePrincipal;

public void main(){

/**
 * <p> This sample LoginModule authenticates users with a password.
 * 登陸示范模塊:用口令來認證用戶,并且只識別一個用戶testUser,口令testPassword
 * <p> This LoginModule only recognizes one user:	testUser
 * <p> testUser's password is:	testPassword
 *
 * <p> If testUser successfully authenticates itself,
 * a <code>SamplePrincipal</code> with the testUser's user name
 * is added to the Subject.
 *
 * <p> This LoginModule recognizes the debug option.
 * If set to true in the login Configuration,
 * debug messages will be output to the output stream, System.out.
 *
 * @version 1.18
 */
public class SampleLoginModule implements LoginModule {

    // initial state 初始化狀態(tài)
    private Subject subject;
    private CallbackHandler callbackHandler;
    private Map sharedState;
    private Map options;

    // configurable option配置選項
    private boolean debug = false;

    // the authentication status 認證情況
    private boolean succeeded = false;
    private boolean commitSucceeded = false;

    // username and password  用戶名和密碼
    private String username;
    private char[] password;

    // testUser's SamplePrincipal 測試者的樣本身份
    private SamplePrincipal userPrincipal;

    /**
     * Initialize this <code>LoginModule</code>.
     *
     * <p>參數(shù)
     *
     * @param subject the <code>Subject</code> to be authenticated. <p>
     *
     * @param callbackHandler a <code>CallbackHandler</code> for communicating
     *			with the end user (prompting for user names and
     *			passwords, for example). <p>
     *
     * @param sharedState shared <code>LoginModule</code> state. <p>
     *
     * @param options options specified in the login
     *			<code>Configuration</code> for this particular
     *			<code>LoginModule</code>.
     */
    public void initialize(Subject subject, CallbackHandler callbackHandler,
			Map sharedState, Map options) {
 
	this.subject = subject;
	this.callbackHandler = callbackHandler;
	this.sharedState = sharedState;
	this.options = options;

	// initialize any configured options
	debug = "true".equalsIgnoreCase((String)options.get("debug"));
    }

    /**
     * Authenticate the user by prompting for a user name and password.
     *
     * <p>
     *
     * @return true in all cases since this <code>LoginModule</code>
     *		should not be ignored.
     *
     * @exception FailedLoginException if the authentication fails. <p>
     *
     * @exception LoginException if this <code>LoginModule</code>
     *		is unable to perform the authentication.
     */
    public boolean login() throws LoginException {

	// prompt for a user name and password
	if (callbackHandler == null)
	    throw new LoginException("Error: no CallbackHandler available " +
			"to garner authentication information from the user");

	Callback[] callbacks = new Callback[2];
	callbacks[0] = new NameCallback("user name: ");
	callbacks[1] = new PasswordCallback("password: ", false);
 
	try {
	    callbackHandler.handle(callbacks);
	    username = ((NameCallback)callbacks[0]).getName();
	    char[] tmpPassword = ((PasswordCallback)callbacks[1]).getPassword();
	    if (tmpPassword == null) {
		// treat a NULL password as an empty password
		tmpPassword = new char[0];
	    }
	    password = new char[tmpPassword.length];
	    System.arraycopy(tmpPassword, 0,
			password, 0, tmpPassword.length);
	    ((PasswordCallback)callbacks[1]).clearPassword();
 
	} catch (java.io.IOException ioe) {
	    throw new LoginException(ioe.toString());
	} catch (UnsupportedCallbackException uce) {
	    throw new LoginException("Error: " + uce.getCallback().toString() +
		" not available to garner authentication information " +
		"from the user");
	}

	// print debugging information
	if (debug) {
	    System.out.println("\t\t[SampleLoginModule] " +
				"user entered user name: " +
				username);
	    System.out.print("\t\t[SampleLoginModule] " +
				"user entered password: ");
	    for (int i = 0; i < password.length; i++)
		System.out.print(password[i]);
	    System.out.println();
	}

	// verify the username/password
	boolean usernameCorrect = false;
	boolean passwordCorrect = false;
	if (username.equals("testUser"))
	    usernameCorrect = true;
	if (usernameCorrect &&
	    password.length == 12 &&
	    password[0] == 't' &&
	    password[1] == 'e' &&
	    password[2] == 's' &&
	    password[3] == 't' &&
	    password[4] == 'P' &&
	    password[5] == 'a' &&
	    password[6] == 's' &&
	    password[7] == 's' &&
	    password[8] == 'w' &&
	    password[9] == 'o' &&
	    password[10] == 'r' &&
	    password[11] == 'd') {

	    // authentication succeeded!!!
	    passwordCorrect = true;
	    if (debug)
		System.out.println("\t\t[SampleLoginModule] " +
				"authentication succeeded");
	    succeeded = true;
	    return true;
	} else {

	    // authentication failed -- clean out state
	    if (debug)
		System.out.println("\t\t[SampleLoginModule] " +
				"authentication failed");
	    succeeded = false;
	    username = null;
	    for (int i = 0; i < password.length; i++)
		password[i] = ' ';
	    password = null;
	    if (!usernameCorrect) {
		throw new FailedLoginException("User Name Incorrect");
	    } else {
		throw new FailedLoginException("Password Incorrect");
	    }
	}
    }

    /**
     * <p> This method is called if the LoginContext's
     * overall authentication succeeded
     * (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules
     * succeeded).
     *
     * <p> If this LoginModule's own authentication attempt
     * succeeded (checked by retrieving the private state saved by the
     * <code>login</code> method), then this method associates a
     * <code>SamplePrincipal</code>
     * with the <code>Subject</code> located in the
     * <code>LoginModule</code>.  If this LoginModule's own
     * authentication attempted failed, then this method removes
     * any state that was originally saved.
     *
     * <p>
     *
     * @exception LoginException if the commit fails.
     *
     * @return true if this LoginModule's own login and commit
     *		attempts succeeded, or false otherwise.
     */
    public boolean commit() throws LoginException {
	if (succeeded == false) {
	    return false;
	} else {
	    // add a Principal (authenticated identity)
	    // to the Subject

	    // assume the user we authenticated is the SamplePrincipal
	    userPrincipal = new SamplePrincipal(username);
	    if (!subject.getPrincipals().contains(userPrincipal))
		subject.getPrincipals().add(userPrincipal);

	    if (debug) {
		System.out.println("\t\t[SampleLoginModule] " +
				"added SamplePrincipal to Subject");
	    }

	    // in any case, clean out state
	    username = null;
	    for (int i = 0; i < password.length; i++)
		password[i] = ' ';
	    password = null;

	    commitSucceeded = true;
	    return true;
	}
    }

    /**
     * <p> This method is called if the LoginContext's
     * overall authentication failed.
     * (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules
     * did not succeed).
     *
     * <p> If this LoginModule's own authentication attempt
     * succeeded (checked by retrieving the private state saved by the
     * <code>login</code> and <code>commit</code> methods),
     * then this method cleans up any state that was originally saved.
     *
     * <p>
     *
     * @exception LoginException if the abort fails.
     *
     * @return false if this LoginModule's own login and/or commit attempts
     *		failed, and true otherwise.
     */
    public boolean abort() throws LoginException {
	if (succeeded == false) {
	    return false;
	} else if (succeeded == true && commitSucceeded == false) {
	    // login succeeded but overall authentication failed
	    succeeded = false;
	    username = null;
	    if (password != null) {
		for (int i = 0; i < password.length; i++)
		    password[i] = ' ';
		password = null;
	    }
	    userPrincipal = null;
	} else {
	    // overall authentication succeeded and commit succeeded,
	    // but someone else's commit failed
	    logout();
	}
	return true;
    }

    /**
     * Logout the user.
     *
     * <p> This method removes the <code>SamplePrincipal</code>
     * that was added by the <code>commit</code> method.
     *
     * <p>
     *
     * @exception LoginException if the logout fails.
     *
     * @return true in all cases since this <code>LoginModule</code>
     *          should not be ignored.
     */
    public boolean logout() throws LoginException {

	subject.getPrincipals().remove(userPrincipal);
	succeeded = false;
	succeeded = commitSucceeded;
	username = null;
	if (password != null) {
	    for (int i = 0; i < password.length; i++)
		password[i] = ' ';
	    password = null;
	}
	userPrincipal = null;
	return true;
    }
}

	System.out.println("Login Sample");
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩你懂得| 亚洲欧美另类久久久精品| 中文字幕精品一区二区精品绿巨人| 亚洲人成在线播放网站岛国| 裸体在线国模精品偷拍| 在线精品视频一区二区| 国产色产综合色产在线视频| 亚洲午夜免费福利视频| 粉嫩av一区二区三区粉嫩 | 香蕉加勒比综合久久| 丁香激情综合五月| 久久综合色鬼综合色| 亚洲成人动漫av| 99国产精品99久久久久久| 精品国产乱码久久久久久久| 亚洲成人av免费| 色综合激情五月| 国产精品美女视频| 国产一区二区三区精品欧美日韩一区二区三区 | 欧美揉bbbbb揉bbbbb| 中文字幕免费观看一区| 久久成人av少妇免费| 日韩天堂在线观看| 日韩国产欧美在线视频| 欧美日韩aaa| 亚洲午夜影视影院在线观看| 91九色最新地址| 伊人婷婷欧美激情| 色噜噜狠狠成人网p站| 综合网在线视频| 99久久婷婷国产精品综合| 国产精品久久久久三级| av中文字幕在线不卡| 国产免费成人在线视频| 国产麻豆精品95视频| 欧美激情一区二区三区四区| 成人丝袜视频网| 亚洲色图一区二区| 在线免费观看一区| 五月天激情小说综合| 日韩欧美精品在线视频| 国模少妇一区二区三区| 欧美韩国日本综合| 91原创在线视频| 亚洲国产一二三| 欧美一级片在线| 国产一区欧美一区| 国产精品久久看| 色狠狠综合天天综合综合| 亚洲成人av中文| 亚洲精品一区在线观看| 成人国产一区二区三区精品| 国产精品久久久久国产精品日日| 99久久777色| 一区二区在线观看视频| 在线视频你懂得一区二区三区| 亚洲美女少妇撒尿| 欧美视频一区二区三区在线观看| 亚洲综合区在线| 99精品国产99久久久久久白柏| 亚洲成人你懂的| 日韩一区二区高清| 国产精品正在播放| 亚洲欧美中日韩| 欧美亚洲图片小说| 蜜芽一区二区三区| 久久久综合精品| 91视频com| 肉色丝袜一区二区| 精品国产乱子伦一区| 国产一区二区三区四区五区入口 | 91精品国产91热久久久做人人| 日韩黄色免费电影| 久久综合九色综合欧美就去吻| 国产精品一二三区| 亚洲精品免费在线播放| 99久久免费视频.com| 亚洲成a人v欧美综合天堂| 欧美成人video| 色婷婷久久99综合精品jk白丝| 亚洲一级在线观看| 日韩欧美一区二区久久婷婷| 国产jizzjizz一区二区| 亚洲一区二区三区四区五区中文| 日韩视频永久免费| 成人高清免费观看| 天堂va蜜桃一区二区三区| 久久久久久影视| 在线亚洲一区二区| 成人激情黄色小说| 奇米色一区二区三区四区| 成人免费在线观看入口| 日韩免费观看2025年上映的电影| 高清成人免费视频| 老司机精品视频一区二区三区| 日韩一区在线免费观看| 欧美mv日韩mv| 欧美日韩免费观看一区二区三区| 国产福利精品一区二区| 天天av天天翘天天综合网色鬼国产| 欧美二区在线观看| 美女一区二区三区在线观看| 丝袜a∨在线一区二区三区不卡| 国产午夜精品一区二区三区嫩草| 91超碰这里只有精品国产| 不卡av在线网| 久久99精品久久久久久国产越南 | 欧美日韩精品一区二区| 国产成人午夜精品5599| 日韩精品一级二级 | 国产一区二区三区综合| 日本成人超碰在线观看| 亚洲黄网站在线观看| 国产精品全国免费观看高清| 欧美xxxxx牲另类人与| 成人免费观看av| 美腿丝袜亚洲一区| 欧美a一区二区| 日韩av电影天堂| 日韩有码一区二区三区| 亚洲精品久久嫩草网站秘色| 国产精品免费人成网站| 久久亚洲精品国产精品紫薇| 精品入口麻豆88视频| 日韩免费高清av| 欧美成人性战久久| 欧美大肚乱孕交hd孕妇| www久久久久| 久久综合久久综合亚洲| 久久精品日产第一区二区三区高清版| 日韩一区二区三区四区五区六区| 欧美日韩在线精品一区二区三区激情| 国产不卡视频一区| 日韩精品欧美精品| 国产老女人精品毛片久久| 国模冰冰炮一区二区| 精品无人码麻豆乱码1区2区| 久久99热这里只有精品| 久久精品国产网站| 激情综合色综合久久| 国产精品一区二区你懂的| 国产精品亚洲人在线观看| 国产一区欧美二区| 国产大陆精品国产| 97久久人人超碰| 色94色欧美sute亚洲线路一久| 欧美午夜影院一区| 日韩写真欧美这视频| 欧美精品一区二区三区在线| 久久久亚洲精品一区二区三区| 国产欧美一区二区精品忘忧草 | 最近日韩中文字幕| 亚洲国产精品久久一线不卡| 免费成人在线网站| 国产精品一区二区在线播放 | 国产精品国产自产拍高清av| 国产精品福利av| 亚洲一区二区三区四区不卡| 蜜臀a∨国产成人精品| 精品制服美女久久| 成人午夜电影小说| 日韩欧美国产系列| 中文av一区特黄| 亚洲bdsm女犯bdsm网站| 韩国精品在线观看| 91丨porny丨户外露出| 欧美一区二区三区在线视频| 欧美v亚洲v综合ⅴ国产v| 国产精品传媒视频| 黑人精品欧美一区二区蜜桃 | 久久99久久精品| 91丝袜美女网| 精品国产1区二区| 亚洲综合视频在线观看| 国产精一品亚洲二区在线视频| 91片在线免费观看| 欧美日韩精品欧美日韩精品一| 国产精品成人免费精品自在线观看| 亚洲国产乱码最新视频| 国产宾馆实践打屁股91| 欧美一级黄色片| 一区二区三区四区不卡在线 | 欧美高清性hdvideosex| 精品国产亚洲一区二区三区在线观看| 国产精品久久久久四虎| 久久91精品久久久久久秒播 | 国产91精品一区二区麻豆网站| 欧美色综合网站| 国产精品伦一区| 国产综合久久久久久久久久久久| 在线观看视频欧美| 国产精品久久久久久久久免费丝袜| 日韩中文字幕麻豆| 99精品在线免费| 亚洲欧美日韩国产一区二区三区 | 亚洲码国产岛国毛片在线| 黄网站免费久久| 7777精品伊人久久久大香线蕉 | 色综合久久九月婷婷色综合| 日韩欧美国产综合一区|