?? helloclient.java
字號:
package examples.security;
import java.util.*;
import javax.security.auth.*;
import javax.security.auth.login.*;
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
/**
* A client program that uses JAAS to authenticate
*/
public class HelloClient
{
public static void main(String[] args)
{
try
{
/* Authenticate via JAAS */
LoginContext loginContext =
new LoginContext("HelloClient", new CallbackHandler());
loginContext.login();
/* Get a bean */
Context ctx = new InitialContext(System.getProperties());
Object obj = ctx.lookup("JAASHelloHome");
HelloHome home =
(HelloHome)PortableRemoteObject.narrow(obj, HelloHome.class);
Hello hello = home.create();
/* Call a business method, propagating the security context */
String result = hello.hello();
/* Print the return result from the business logic */
System.out.println(result);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -