[jboss-user] [EJB/JBoss] - Authentication Problem

Usul do-not-reply at jboss.com
Tue May 27 05:29:47 EDT 2008


Hi,

My Client throws an Exception at this line:

LoginContext lc = new LoginContext("steffendom", handler);

Exception:


anonymous wrote : 
  | Exception in thread "main" java.lang.SecurityException: Anmeldekonfiguration kann nicht gefunden werden.
  | 	at com.sun.security.auth.login.ConfigFile.(Unknown Source)
  | 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  | 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  | 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  | 	at java.lang.reflect.Constructor.newInstance(Unknown Source)
  | 	at java.lang.Class.newInstance0(Unknown Source)
  | 	at java.lang.Class.newInstance(Unknown Source)
  | 	at javax.security.auth.login.Configuration$3.run(Unknown Source)
  | 	at java.security.AccessController.doPrivileged(Native Method)
  | 	at javax.security.auth.login.Configuration.getConfiguration(Unknown Source)
  | 	at javax.security.auth.login.LoginContext$1.run(Unknown Source)
  | 	at java.security.AccessController.doPrivileged(Native Method)
  | 	at javax.security.auth.login.LoginContext.init(Unknown Source)
  | 	at javax.security.auth.login.LoginContext.(Unknown Source)
  | 	at myclient.MyClient.main(MyClient.java:36)
  | Caused by: java.io.IOException: Anmeldekonfiguration kann nicht gefunden werden.
  | 	at com.sun.security.auth.login.ConfigFile.init(Unknown Source)
  | 	... 15 more
  | 

My complete Client code:

  | package myclient;
  | 
  | import java.rmi.RMISecurityManager;
  | import java.util.Properties;
  | 
  | import javax.naming.InitialContext;
  | import javax.security.auth.Subject;
  | import javax.security.auth.callback.CallbackHandler;
  | import javax.security.auth.login.LoginContext;
  | import javax.security.auth.login.LoginException;
  | 
  | import myserv.CalculatorBeanRemote;
  | 
  | public class MyClient
  | {
  | 
  | 	   public static void main(String[] args) throws Exception
  | 	   {	
  | 		   System.setProperty("java.security.policy", "F:\\rmi.policy");
  | 		   if (System.getSecurityManager() == null) {
  | 			   System.setSecurityManager(new RMISecurityManager());
  | 			 }
  | 
  | 
  | 
  | 		   Properties properties = new Properties();		
  | 		   properties.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");		
  | 		   properties.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");		
  | 		   properties.put("java.naming.provider.url","localhost:1099");
  | 		   
  | 		   CallbackHandler handler = new MyHandler();      
  | 		   
  | 		   LoginContext lc = new LoginContext("steffendom", handler);
  | 
  | 		   try {
  | 		       lc.login();
  | 		       Subject subject = lc.getSubject();
  | 		   } catch(LoginException e) {
  | 		       System.out.println("authentication failed");
  | 		       e.printStackTrace();
  | 		   }
  | 		   
  | 		   
  | 	      InitialContext ctx = new InitialContext(properties);
  | 	      CalculatorBeanRemote calculator = (CalculatorBeanRemote) ctx.lookup("CalculatorBean/remote");
  | 
  | 	      System.out.println("4 + 7 = " + calculator.add(7, 4));
  | 	      System.out.println("9 - 5 = " + calculator.subtract(9, 5));
  | 	      
  | 	   // Scope of work complete, logout to remove authentication info
  | 	      try {
  | 	          lc.logout();
  | 	      } catch(LoginException e) {
  | 	          System.out.println("logout failed");
  | 	          e.printStackTrace();
  | 	      }
  | 
  | 	   }
  | }
  | 

I have added to the login-config.xml:
anonymous wrote : 
  |     <application-policy name = "steffendom">
  |        
  |           <login-module code = "org.jboss.security.auth.spi.UsersRolesLoginModule"
  |              flag = "required" />
  |        
  |     </application-policy>
  | 

And I have deployed my EJB in a *.jar containing a folder META-INF containing jboss.xml:
anonymous wrote : 
  |     <security-domain>java:/jaas/steffendom</security-domain>
  |                 
  |     <enterprise-beans>
  |         
  |             <ejb-name>CalculatorBean</ejb-name>
  |         
  |     </enterprise-beans>
  |  
  | 


What am I missing?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4153525#4153525

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4153525



More information about the jboss-user mailing list