Thanks Chris for your Input. Can you please give me an idea how can I get
Principal object which I am calling "identity" in my login() function of
CustomServerLoginModule.
I have created a CustomCallbackHandler on client side
public class CustomCallbackHandler
| implements javax.security.auth.callback.CallbackHandler
| {
| private String username = null;
| private char[] password = null;
|
| public CustomCallbackHandler(String uname, char[] pass)
| {
| username=uname;
| password=pass;
| }
|
| public void handle(Callback[] callbacks)
| throws IOException, UnsupportedCallbackException
| {
| for ( int i = 0; i < callbacks.length; i++ )
| {
| Callback callback = callbacks;
|
| if ( callback instanceof NameCallback )
| {
| NameCallback ncb = (NameCallback) callback;
| ncb.setName( username );
| }
| else if ( callback instanceof PasswordCallback )
| {
| PasswordCallback pcb = (PasswordCallback)
callback;
| pcb.setPassword( password );
| }
| else
| {
| System.out.println(
| "Unsupported callback: " +
| callback.getClass().getName() );
| throw new UnsupportedCallbackException(
callback );
| }
| }
| }
| }
This is How my Client Looks:
public class AdviceClient
| {
| public static void main(String[] args)
| {
| String securityDomain= "adviceDomain";
| String username="advisor";
| char[] password="password".toCharArray();
|
| try{
| CallbackHandler callbackHandler = new
CustomCallbackHandler(username,password);
| LoginContext lc=new LoginContext(securityDomain,
callbackHandler);
| System.out.println("Created Login Context");
| lc.login();
| }catch(LoginException le){
| System.out.println("Login Failed");
| le.printStackTrace();
| }
|
| try
| {
|
| // Get a naming context
| InitialContext jndiContext = new InitialContext();
| System.out.println("Got context");
|
| // Get a reference to the Interest Bean
| Object ref = jndiContext.lookup("ejb/AdviceBean");
| System.out.println("Got reference");
|
| // Get a reference from this to the Bean's Home
interface
| AdviceHome home = (AdviceHome)
| PortableRemoteObject.narrow(ref, AdviceHome.class);
| System.out.println("Got reference to Bean's Home
Interface");
|
| // Create an Advice object from the Home interface
| Advice advisor = home.create();
| System.out.println("Got reference to Bean's Componenet
Interface");
| // call the getMessage() method to get an Advice
| for(int i=0; i<4;i++){
| System.out.println("Advice is:");
| System.out.println(advisor.getMessage());
| }
| advisor.remove();
| }
| catch(Exception e)
| {
| System.out.println(e.toString());
| }
| }
| }
|
I will be very thankful to you for your help....
Thanks a lot......
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3944717#3944717
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3944717
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user