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

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

?? sampleazn.java

?? 本書以大量精簡的實例介紹了Java安全性編程方面的概念和技術
?? JAVA
字號:
/*
 * @(#)SampleAzn.java
 *
 * Copyright 2001-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;

import java.io.*;
import java.util.*;
import java.security.Principal;
import java.security.PrivilegedAction;
import javax.security.auth.*;
import javax.security.auth.callback.*;
import javax.security.auth.login.*;
import javax.security.auth.spi.*;
import com.sun.security.auth.*;

/**
 * <p> This Sample application attempts to authenticate a user
 * and executes a SampleAction as that user.
 *
 * <p> If the user successfully authenticates itself,
 * the username and number of Credentials is displayed.
 */
public class SampleAzn {

    /**
     * Attempt to authenticate the user.
     *
     * <p>
     * 
     * @param args input arguments for this application.  These are ignored.
     */
     public static void main(String[] args) {

	// Obtain a LoginContext, needed for authentication. Tell it 
	// to use the LoginModule implementation specified by the 
	// entry named "Sample" in the JAAS login configuration 
	// file and to also use the specified CallbackHandler.
	LoginContext lc = null;
	try {
	    lc = new LoginContext("Sample", new MyCallbackHandler());
	} catch (LoginException le) {
	    System.err.println("Cannot create LoginContext. "
	        + le.getMessage());
	    System.exit(-1);
	} catch (SecurityException se) {
	    System.err.println("Cannot create LoginContext. "
	        + se.getMessage());
	    System.exit(-1);
	} 

	// the user has 3 attempts to authenticate successfully
	int i;
	for (i = 0; i < 3; i++) {
	    try {

		// attempt authentication
		lc.login();

		// if we return with no exception, authentication succeeded
		break;

	    } catch (LoginException le) {

		  System.err.println("Authentication failed:");
		  System.err.println("  " + le.getMessage());
		  try {
		      Thread.currentThread().sleep(3000);
		  } catch (Exception e) {
		      // ignore
		  } 
	
	    }
	}

	// did they fail three times?
	if (i == 3) {
	    System.out.println("Sorry");
	    System.exit(-1);
	}

	System.out.println("Authentication succeeded!");

	Subject mySubject = lc.getSubject();

	// let's see what Principals we have
	Iterator principalIterator = mySubject.getPrincipals().iterator();
	System.out.println("Authenticated user has the following Principals:");
	while (principalIterator.hasNext()) {
	    Principal p = (Principal)principalIterator.next();
	    System.out.println("\t" + p.toString());
	}

	System.out.println("User has " +
			mySubject.getPublicCredentials().size() +
			" Public Credential(s)");

	// now try to execute the SampleAction as the authenticated Subject
	PrivilegedAction action = new SampleAction();
	Subject.doAsPrivileged(mySubject, action, null);

	System.exit(0);
    }
}

/**
 * A CallbackHandler implemented by the application.
 *
 * <p> This application is text-based.  Therefore it displays information
 * to the user using the OutputStreams System.out and System.err,
 * and gathers input from the user using the InputStream System.in.
 */
class MyCallbackHandler implements CallbackHandler {

    /**
     * Invoke an array of Callbacks.
     *
     * <p>
     *
     * @param callbacks an array of <code>Callback</code> objects which contain
     *			the information requested by an underlying security
     *			service to be retrieved or displayed.
     *
     * @exception java.io.IOException if an input or output error occurs. <p>
     *
     * @exception UnsupportedCallbackException if the implementation of this
     *			method does not support one or more of the Callbacks
     *			specified in the <code>callbacks</code> parameter.
     */
    public void handle(Callback[] callbacks)
    throws IOException, UnsupportedCallbackException {
      
	for (int i = 0; i < callbacks.length; i++) {
	    if (callbacks[i] instanceof TextOutputCallback) {
      
		// display the message according to the specified type
		TextOutputCallback toc = (TextOutputCallback)callbacks[i];
		switch (toc.getMessageType()) {
		case TextOutputCallback.INFORMATION:
 		    System.out.println(toc.getMessage());
 		    break;
 		case TextOutputCallback.ERROR:
 		    System.out.println("ERROR: " + toc.getMessage());
 		    break;
 		case TextOutputCallback.WARNING:
 		    System.out.println("WARNING: " + toc.getMessage());
 		    break;
 		default:
 		    throw new IOException("Unsupported message type: " +
 					toc.getMessageType());
 		}
 
 	    } else if (callbacks[i] instanceof NameCallback) {
  
 		// prompt the user for a username
 		NameCallback nc = (NameCallback)callbacks[i];
  
 		System.err.print(nc.getPrompt());
 		System.err.flush();
 		nc.setName((new BufferedReader
			(new InputStreamReader(System.in))).readLine());
 
 	    } else if (callbacks[i] instanceof PasswordCallback) {
  
 		// prompt the user for sensitive information
 		PasswordCallback pc = (PasswordCallback)callbacks[i];
 		System.err.print(pc.getPrompt());
 		System.err.flush();
 		pc.setPassword(readPassword(System.in));
  
 	    } else {
 		throw new UnsupportedCallbackException
 			(callbacks[i], "Unrecognized Callback");
 	    }
	}
    }
   
    // Reads user password from given input stream.
    private char[] readPassword(InputStream in) throws IOException {
	
	char[] lineBuffer;
	char[] buf;
	int i;

	buf = lineBuffer = new char[128];

	int room = buf.length;
	int offset = 0;
	int c;

loop:	while (true) {
 	    switch (c = in.read()) {
 	    case -1:
 	    case '\n':
		break loop;

 	    case '\r':
 		int c2 = in.read();
 		if ((c2 != '\n') && (c2 != -1)) {
 		    if (!(in instanceof PushbackInputStream)) {
 			in = new PushbackInputStream(in);
 		    }
 		    ((PushbackInputStream)in).unread(c2);
 		} else
 		    break loop;

 	    default:
 		if (--room < 0) {
 		    buf = new char[offset + 128];
 		    room = buf.length - offset - 1;
 		    System.arraycopy(lineBuffer, 0, buf, 0, offset);
 		    Arrays.fill(lineBuffer, ' ');
 		    lineBuffer = buf;
 		}
 		buf[offset++] = (char) c;
 		break;
 	    }
 	}

 	if (offset == 0) {
 	    return null;
 	}

 	char[] ret = new char[offset];
 	System.arraycopy(buf, 0, ret, 0, offset);
 	Arrays.fill(buf, ' ');

 	return ret;
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国内外成人在线视频| 欧美视频中文字幕| 欧美三级中文字幕| 视频在线观看国产精品| 666欧美在线视频| 精品一区二区三区在线观看| 26uuu色噜噜精品一区| 成人在线视频一区| 亚洲精品欧美二区三区中文字幕| 在线免费观看成人短视频| 一区二区三区中文字幕在线观看| 欧美三级电影一区| 国内精品免费**视频| 国产精品传媒入口麻豆| 欧美色网站导航| 激情欧美一区二区| 中文字幕中文在线不卡住| 欧美日韩一区二区三区免费看| 日本vs亚洲vs韩国一区三区| 国产午夜久久久久| 欧美性感一区二区三区| 国内精品视频一区二区三区八戒| 亚洲欧美日韩综合aⅴ视频| 欧美电影一区二区| 成人激情视频网站| 天天综合网天天综合色| 国产精品私房写真福利视频| 欧美精品三级日韩久久| 成人午夜短视频| 免费美女久久99| 亚洲另类在线视频| 欧美精品一区二区三区蜜桃 | 国产一区欧美一区| 自拍av一区二区三区| 日韩欧美一区中文| 91污在线观看| 国产精品一区二区久久精品爱涩| 亚洲日本中文字幕区| 亚洲精品一区二区在线观看| 91激情在线视频| 国产成人免费视频精品含羞草妖精 | 国产高清久久久| 日韩精品三区四区| 一区二区三区在线看| 中文欧美字幕免费| 欧美zozozo| 欧美日韩亚洲综合| 91最新地址在线播放| 国产精品资源在线看| 日韩精品一级中文字幕精品视频免费观看| 国产精品日韩精品欧美在线| 日韩欧美国产综合| 欧美色综合久久| 99re成人精品视频| 丁香天五香天堂综合| 国产在线观看免费一区| 日本视频中文字幕一区二区三区| 亚洲午夜久久久| 中文字幕一区二区不卡| 亚洲国产激情av| 国产女主播在线一区二区| 久久蜜桃av一区二区天堂| 日韩一级完整毛片| 日韩一区二区三区av| 日韩午夜激情av| 日韩一区二区在线观看| 91精品婷婷国产综合久久竹菊| 欧美日韩在线直播| 欧美妇女性影城| 欧美日韩国产在线观看| 欧美日韩亚洲高清一区二区| 在线免费观看一区| 欧美日韩激情一区二区三区| 欧美三级在线看| 欧美人狂配大交3d怪物一区 | 99精品在线观看视频| 成人毛片在线观看| 91免费国产视频网站| 91视频在线观看| 在线精品视频一区二区三四| 色av综合在线| 欧美精品自拍偷拍动漫精品| 7799精品视频| 精品国产一区二区三区四区四| 欧美大尺度电影在线| 国产日韩精品一区二区浪潮av| 国产日韩欧美亚洲| 亚洲精品ww久久久久久p站| 亚洲国产精品麻豆| 秋霞午夜鲁丝一区二区老狼| 激情综合色综合久久| 粉嫩av一区二区三区在线播放| www.66久久| 欧美情侣在线播放| 久久午夜老司机| 亚洲欧洲成人自拍| 亚洲福利视频三区| 国产一区欧美日韩| 91黄色免费看| 精品国产1区2区3区| 亚洲欧洲精品天堂一级| 午夜私人影院久久久久| 久久成人久久爱| 99久久国产综合精品色伊| 欧美老女人第四色| 国产偷国产偷精品高清尤物| 亚洲三级免费观看| 麻豆精品视频在线观看| 99久久综合精品| 日韩一卡二卡三卡国产欧美| 国产精品福利电影一区二区三区四区| 亚洲一区二区欧美日韩| 国产乱一区二区| 欧美日韩国产精品成人| 欧美国产一区视频在线观看| 午夜激情久久久| 国产**成人网毛片九色| 777xxx欧美| 综合欧美一区二区三区| 久久99精品国产.久久久久 | 不卡的av中国片| 8v天堂国产在线一区二区| 日本一区二区成人在线| 日韩激情av在线| 91小视频在线| 久久久久久久久伊人| 天堂蜜桃91精品| 99久久婷婷国产综合精品| 日韩女优毛片在线| 亚洲国产日韩一级| 不卡电影一区二区三区| 久久综合色一综合色88| 亚洲成av人影院| 色婷婷综合视频在线观看| 国产欧美日韩视频一区二区| 青青国产91久久久久久| 91国内精品野花午夜精品| 国产欧美日韩精品一区| 久久不见久久见免费视频7| 欧美嫩在线观看| 亚洲美女在线一区| av在线不卡免费看| 国产农村妇女精品| 国产精品一色哟哟哟| 欧美一区二区视频网站| 性欧美大战久久久久久久久| 91福利在线看| 一区二区三区中文在线| 91美女精品福利| 一区二区中文视频| 成人av一区二区三区| 国产清纯在线一区二区www| 狠狠色综合日日| 日韩欧美电影在线| 免费看黄色91| 日韩一卡二卡三卡四卡| 日本系列欧美系列| 欧美一级免费观看| 蜜臀久久99精品久久久画质超高清 | 国产一区二区在线影院| 精品少妇一区二区三区视频免付费 | 国产成人精品www牛牛影视| 久久先锋影音av鲁色资源| 黄网站免费久久| 日韩欧美第一区| 国产主播一区二区| 久久久久青草大香线综合精品| 韩国三级电影一区二区| 久久九九99视频| 风流少妇一区二区| 国产精品美女久久久久久2018| 国产99久久久精品| 中文字幕中文字幕中文字幕亚洲无线| 成人动漫av在线| 日韩毛片在线免费观看| 欧洲视频一区二区| 天天综合色天天| 精品国产自在久精品国产| 国产自产v一区二区三区c| 日本一区二区三区dvd视频在线| 国产成人在线视频网址| 亚洲欧洲www| 欧美肥妇free| 韩国成人在线视频| 国产精品久久免费看| 91麻豆精品在线观看| 午夜激情久久久| 国产亚洲精品aa| 色老头久久综合| 精品一区二区三区免费| 中文字幕高清一区| 欧美在线观看视频在线| 久久综合综合久久综合| 国产精品久久国产精麻豆99网站| 欧美在线free| 国产一区久久久| 亚洲成a天堂v人片| 国产色婷婷亚洲99精品小说| 色噜噜狠狠成人中文综合| 毛片av一区二区三区|