14 Replies Latest reply on Apr 9, 2004 1:20 AM by liuhf

    DatabaseLoginModule example project

    Alessandro Lombardi Newbie

       

      "jalex" wrote:
      To avoid you to spend a lot of time around JAAS with JBoss, you maybe can take a look to our example with a standard DatabaseLoginModule on JBoss 3.x.
      This is also to thanks all the people out there that helped us so many times!
      We hope this will help!
      (see README.txt in README folder...)
      Alessandro Lombardi, Fabrizio Gambelunghe


        • 1. Re: DatabaseLoginModule example project
          Juha Lindfors Master

          This will better survive if you post it to the FAQ forum.

          • 2. Re: DatabaseLoginModule example project
            Alessandro Lombardi Newbie

            Thanks for the advice! I have posted this sample-topic here since (imho) many questions that i have found in this forum could be cleared (hopefully!) with this example. Anyway, i'm going to post it in the FAQ forum..

            • 3. Re: DatabaseLoginModule example project
              Vincent B Fischer Newbie

              Thanks. This is a great resource.

              One quick question as I've just started browsing the code. Why did you decide to use SecurityAssociationHandler instead of UsernamePasswordHandler

              Unfortunately, I cannot seem to find any documentation on either of these classes.

              Thanks.

              • 5. Re: DatabaseLoginModule example project
                Alessandro Lombardi Newbie

                We have tried both, but there's no big difference, indeed: the Handler must only manage the user data, and you can write your own CallbackHandler.
                Bye!

                • 6. Re: DatabaseLoginModule example project
                  comefromottawa Newbie

                  Thanks for your providing this valuable demo sample on the DatabaseLoginModule together with JBoss.

                  I tried to do a test on the attached stuff.I am getting stuck there....

                  Here are the console I had:
                  --------------------START of console---------------------****
                  C:\Downloads\JAASTester\JAASTester>ant
                  Buildfile: build.xml

                  ejbdoclet:
                  [ejbdoclet] log4j:WARN No appenders could be found for logger (xdoclet.util.Tran
                  slator.getString).
                  [ejbdoclet] log4j:WARN Please initialize the log4j system properly.
                  [ejbdoclet] Generating Javadoc
                  [ejbdoclet] Javadoc execution
                  [ejbdoclet] Loading source file C:\Downloads\JAASTester\JAASTester\src\client\Te
                  stMain.java...
                  [ejbdoclet] Loading source file C:\Downloads\JAASTester\JAASTester\src\ejb\AuthE
                  JB.java...
                  [ejbdoclet] Loading source file C:\Downloads\JAASTester\JAASTester\src\ejb\AuthE
                  JBHome.java...
                  [ejbdoclet] Loading source file C:\Downloads\JAASTester\JAASTester\src\ejb\AuthE
                  JBRemote.java...
                  [ejbdoclet] Constructing Javadoc information...
                  [ejbdoclet] Running
                  [ejbdoclet] Generating Home interface for 'ejb.AuthEJB'.
                  [ejbdoclet] Running
                  [ejbdoclet] Running
                  [ejbdoclet] Generating Remote interface for 'ejb.AuthEJB'.
                  [ejbdoclet] Running
                  [ejbdoclet] Running
                  [ejbdoclet] Running
                  [ejbdoclet] Running
                  [ejbdoclet] Generating EJB deployment descriptor.
                  [ejbdoclet] Running
                  [ejbdoclet] Generating jboss.xml.

                  compile:
                  [javac] Compiling 4 source files to C:\Downloads\JAASTester\JAASTester\bin

                  ejb-jar:
                  [jar] Building jar: C:\Downloads\JAASTester\JAASTester\ejb-auth.jar

                  deploy:
                  [copy] Copying 1 file to C:\jboss-3.2.1_tomcat-4.1.24\jboss-3.2.1_tomcat-4.
                  1.24\server\default\deploy

                  BUILD SUCCESSFUL
                  Total time: 5 seconds
                  C:\Downloads\JAASTester\JAASTester>ant run
                  Buildfile: build.xml

                  ejbdoclet:
                  [ejbdoclet] log4j:WARN No appenders could be found for logger (xdoclet.util.Tran
                  slator.getString).
                  [ejbdoclet] log4j:WARN Please initialize the log4j system properly.
                  [ejbdoclet] Generating Javadoc
                  [ejbdoclet] Javadoc execution
                  [ejbdoclet] Loading source file C:\Downloads\JAASTester\JAASTester\src\client\Te
                  stMain.java...
                  [ejbdoclet] Loading source file C:\Downloads\JAASTester\JAASTester\src\ejb\AuthE
                  JB.java...
                  [ejbdoclet] Loading source file C:\Downloads\JAASTester\JAASTester\src\ejb\AuthE
                  JBHome.java...
                  [ejbdoclet] Loading source file C:\Downloads\JAASTester\JAASTester\src\ejb\AuthE
                  JBRemote.java...
                  [ejbdoclet] Constructing Javadoc information...
                  [ejbdoclet] Running
                  [ejbdoclet] Generating Home interface for 'ejb.AuthEJB'.
                  [ejbdoclet] Running
                  [ejbdoclet] Running
                  [ejbdoclet] Generating Remote interface for 'ejb.AuthEJB'.
                  [ejbdoclet] Running
                  [ejbdoclet] Running
                  [ejbdoclet] Running
                  [ejbdoclet] Running
                  [ejbdoclet] Generating EJB deployment descriptor.
                  [ejbdoclet] Running
                  [ejbdoclet] Generating jboss.xml.

                  compile:
                  [javac] Compiling 2 source files to C:\Downloads\JAASTester\JAASTester\bin

                  run:
                  [java] java.lang.NoClassDefFoundError: org/jboss/security/auth/callback/Sec
                  urityAssociationHandler


                  BUILD SUCCESSFUL
                  Total time: 5 seconds
                  C:\Downloads\JAASTester\JAASTester>
                  -----------------END of CONSOLE---------------------*****

                  Why did I get this error( I highlighted there!) although I passed the compile and the deploy?
                  I checked the classpath,org.jboss.security.auth.callback.SecurityAssociationHandler from jbosssx.jar.....

                  And,this is the build.xml I had:

                  #########START of build.xml###########







































                  <!-- Compile EJBs -->





                  <!-- Create EJB-JAR file -->






























































                  ##########END of build.xml############

                  Thanks in advance!

                  • 7. Re: DatabaseLoginModule example project
                    Peter Doornbosch Apprentice

                    > Why did I get this error( I highlighted there!)
                    > although I passed the compile and the deploy?

                    What do you mean 'although'? Are you suggesting that because compile and deploy succeeded, run should succeed also???? Obviously, this is not the case, because (1) you're using different classpaths for these targets and (2) run and compile might need different classpaths (because compile-time dependencies is not the same as run-time dependencies).

                    From the error message, it is quite clear that run classpath is not ok. You checked that the required class is in the jbosssx.jar, so the error must be in the classpath definition in your build file.
                    Check this:

                    >
                    >
                    >
                    >
                    >
                    >
                    >
                    >

                    It's unlikely that the pathelement will automatically convert its value to a ref-id, don't you think?
                    Shouldn't this be
                    or ?

                    Hth
                    Peter

                    • 8. Re: DatabaseLoginModule example project
                      comefromottawa Newbie

                      Peter,Thanks for the reply.

                      I fixed the classpath for running the testing package,and the classpath errors are gone finally.

                      however while I try to run,it keep telling me " Unable to locate a login configuration "

                      Here is the console:

                      ###########START of CONSOLE#########

                      C:\Downloads\JAASTester\JAASTester>ant run
                      Buildfile: build.xml

                      ejbdoclet:
                      [ejbdoclet] log4j:WARN No appenders could be found for logger (xdoclet.util.Tran
                      slator.getString).
                      [ejbdoclet] log4j:WARN Please initialize the log4j system properly.
                      [ejbdoclet] Generating Javadoc
                      [ejbdoclet] Javadoc execution
                      [ejbdoclet] Loading source file C:\Downloads\JAASTester\JAASTester\src\client\Te
                      stMain.java...
                      [ejbdoclet] Loading source file C:\Downloads\JAASTester\JAASTester\src\ejb\AuthE
                      JB.java...
                      [ejbdoclet] Loading source file C:\Downloads\JAASTester\JAASTester\src\ejb\AuthE
                      JBHome.java...
                      [ejbdoclet] Loading source file C:\Downloads\JAASTester\JAASTester\src\ejb\AuthE
                      JBRemote.java...
                      [ejbdoclet] Constructing Javadoc information...
                      [ejbdoclet] Running
                      [ejbdoclet] Generating Home interface for 'ejb.AuthEJB'.
                      [ejbdoclet] Running
                      [ejbdoclet] Running
                      [ejbdoclet] Generating Remote interface for 'ejb.AuthEJB'.
                      [ejbdoclet] Running
                      [ejbdoclet] Running
                      [ejbdoclet] Running
                      [ejbdoclet] Running
                      [ejbdoclet] Generating EJB deployment descriptor.
                      [ejbdoclet] Running
                      [ejbdoclet] Generating jboss.xml.

                      compile:
                      [javac] Compiling 2 source files to C:\Downloads\JAASTester\JAASTester\bin

                      run:
                      [java] Unable to locate a login configuration

                      BUILD SUCCESSFUL
                      Total time: 5 seconds
                      C:\Downloads\JAASTester\JAASTester>

                      ###########END of CONSOLE#########

                      I tried to put auth.conf and users.properties,roles.properties different places,no luck!

                      Thanks very much!

                      • 9. Re: DatabaseLoginModule example project
                        Peter Doornbosch Apprentice

                        -Djava.security.auth.login.config=file:///home/ottawa/auth.conf

                        • 10. Re: DatabaseLoginModule example project
                          comefromottawa Newbie

                          Peter,thanks.

                          The login_file_can't_find error is gone finally.

                          While I run the JAASTester,other error come out::

                          *************START of Console*********
                          C:\Downloads\JAASTester\JAASTester>ant run
                          Buildfile: build.xml

                          ejbdoclet:
                          [ejbdoclet] log4j:WARN No appenders could be found for logger (xdoclet.util.Tran
                          slator.getString).
                          [ejbdoclet] log4j:WARN Please initialize the log4j system properly.
                          [ejbdoclet] Generating Javadoc
                          [ejbdoclet] Javadoc execution
                          [ejbdoclet] Loading source file C:\Downloads\JAASTester\JAASTester\src\client\Te
                          stMain.java...
                          [ejbdoclet] Loading source file C:\Downloads\JAASTester\JAASTester\src\ejb\AuthE
                          JB.java...
                          [ejbdoclet] Loading source file C:\Downloads\JAASTester\JAASTester\src\ejb\AuthE
                          JBHome.java...
                          [ejbdoclet] Loading source file C:\Downloads\JAASTester\JAASTester\src\ejb\AuthE
                          JBRemote.java...
                          [ejbdoclet] Constructing Javadoc information...
                          [ejbdoclet] Running
                          [ejbdoclet] C:\Downloads\JAASTester\JAASTester\src\client\TestMain.java:21: warn
                          ing - @author tag has no arguments.
                          [ejbdoclet] Generating Home interface for 'ejb.AuthEJB'.
                          [ejbdoclet] Running
                          [ejbdoclet] Running
                          [ejbdoclet] Generating Remote interface for 'ejb.AuthEJB'.
                          [ejbdoclet] Running
                          [ejbdoclet] Running
                          [ejbdoclet] Running
                          [ejbdoclet] Running
                          [ejbdoclet] Generating EJB deployment descriptor.
                          [ejbdoclet] Running
                          [ejbdoclet] Generating jboss.xml.
                          [ejbdoclet] 1 warning

                          compile:
                          [javac] Compiling 2 source files to C:\Downloads\JAASTester\JAASTester\bin

                          run:
                          [java] LOGIN DONE.
                          [java] java.rmi.ServerException: RemoteException occurred in server thread;
                          nested exception is:
                          [java] java.rmi.ServerException: EJBException:; nested exception is:
                          [java] javax.ejb.EJBException: checkSecurityAssociation; CausedByExcept
                          ion is:
                          [java] Authentication exception, principal=fab
                          [java] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.jav
                          a:292)
                          [java] at sun.rmi.transport.Transport$1.run(Transport.java:148)
                          [java] at java.security.AccessController.doPrivileged(Native Method)
                          [java] at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
                          [java] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTranspor
                          t.java:460)
                          [java] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPT
                          ransport.java:701)
                          [java] at java.lang.Thread.run(Thread.java:536)
                          [java] at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServe
                          r(StreamRemoteCall.java:247)
                          [java] at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCa
                          ll.java:223)
                          [java] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
                          [java] at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unkn
                          own Source)
                          [java] at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(
                          JRMPInvokerProxy.java:135)
                          [java] at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterce
                          ptor.java:87)
                          [java] at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInte
                          rceptor.java:46)
                          [java] at org.jboss.proxy.SecurityInterceptor.invoke(SecurityIntercepto
                          r.java:45)
                          [java] at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.ja
                          va:173)
                          [java] at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:8
                          5)
                          [java] at $Proxy0.create(Unknown Source)
                          [java] at client.TestMain.main(Unknown Source)
                          [java] Caused by: java.rmi.ServerException: EJBException:; nested exception
                          is:
                          [java] javax.ejb.EJBException: checkSecurityAssociation; CausedByExcept
                          ion is:
                          [java] Authentication exception, principal=fab
                          [java] at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInter
                          ceptor.java:346)
                          [java] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogIntercepto
                          r.java:124)
                          [java] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHom
                          e(ProxyFactoryFinderInterceptor.java:93)
                          [java] at org.jboss.ejb.StatelessSessionContainer.internalInvokeHome(St
                          atelessSessionContainer.java:310)
                          [java] at org.jboss.ejb.Container.invoke(Container.java:694)
                          [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                          [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
                          sorImpl.java:39)
                          [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
                          hodAccessorImpl.java:25)
                          [java] at java.lang.reflect.Method.invoke(Method.java:324)
                          [java] at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(Refle
                          ctedMBeanDispatcher.java:284)
                          [java] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.ja
                          va:549)
                          [java] at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvok
                          er.java:359)
                          [java] at sun.reflect.GeneratedMethodAccessor104.invoke(Unknown Source)

                          [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
                          hodAccessorImpl.java:25)
                          [java] at java.lang.reflect.Method.invoke(Method.java:324)
                          [java] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.jav
                          a:261)
                          [java] at sun.rmi.transport.Transport$1.run(Transport.java:148)
                          [java] at java.security.AccessController.doPrivileged(Native Method)
                          [java] at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
                          [java] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTranspor
                          t.java:460)
                          [java] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPT
                          ransport.java:701)
                          [java] at java.lang.Thread.run(Thread.java:536)
                          [java] Caused by: javax.ejb.EJBException: checkSecurityAssociation; CausedB
                          yException is:
                          [java] Authentication exception, principal=fab
                          [java] at org.jboss.ejb.plugins.SecurityInterceptor.checkSecurityAssoci
                          ation(SecurityInterceptor.java:163)
                          [java] at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(Security
                          Interceptor.java:81)
                          [java] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogIntercepto
                          r.java:120)
                          [java] ... 20 more
                          [java] Exception in thread "main"
                          [java] Java Result: 1

                          BUILD SUCCESSFUL
                          Total time: 7 seconds
                          C:\Downloads\JAASTester\JAASTester>

                          ****************END of Console************

                          btw,I changed some configuration accordingly myself,I setup the database as it should be......

                          Thanks in advance

                          • 11. Re: DatabaseLoginModule example project
                            Peter Doornbosch Apprentice

                            What is the log on the server telling you?

                            • 12. Re: DatabaseLoginModule example project
                              liuhf Newbie

                              can anyone give me the 'databaseLoginModule example project' ?
                              here is my e_mail:

                              liuhf3000@hotmail.com

                              thanks.
                              liuhf.

                              • 13. Re: DatabaseLoginModule example project
                                antoine Newbie

                                excuse me

                                but where did you find databaseServerloginmodule project example ?

                                thanks

                                • 14. Re: DatabaseLoginModule example project
                                  liuhf Newbie

                                  i know the 'databaseLoginModule example project'
                                  from jalex's topic.