4 Replies Latest reply on Jun 18, 2004 9:11 PM by Dave Smith

    Custom Princpal Class

    Dave Smith Newbie

      This was discussed many moons ago and now I am upgrading to 3.2 from 3.0 I thought I would ask again. If you are using your own Custom Server Side Login module can sessionContext.getPrincipal() return a custom Principal class not a SimplePrincipal?

        • 1. Re: Custom Princpal Class
          Scott Stark Master

          3.2.4+ supports this.

          • 2. Re: Custom Princpal Class
            Dave Smith Newbie

            Excellent! So does JAAS now keep the Principal class the the server login module returns or do I have to ytell JASS which Principal class to use?

            • 3. Re: Custom Princpal Class
              Dave Smith Newbie

              OK. I have looked at AbstractServerLoginModule whcih my custom Server Login Module. Now instead of useing the property I am overiding createIdentity with my own custom implementation. the problem is that it is never getting called. Therefore ctx.getCallerPrincipal is still returning a class of SimplePrincipal.

              • 4. Re: Custom Princpal Class
                Dave Smith Newbie

                OK, after reading the updated javaworld anser I found my answer. I'll put it here for others.

                In your getRoleSets() method you need to add another group called CallerPrincipal. The member of this class should be what you want returned when you call EJBContext.getCallerPrincipal

                so a sample code snippit ...

                protected Group[] getRoleSets()
                throws LoginException
                Group[] roleSets = new Group[2];
                roleSets[0] = new SimpleGroup("Roles");
                roleSets[1] = new SimpleGroup("CallerPrincipal");

                roleSets[0].addMember(new SimplePrincipal("user"));
                return roleSets;

                Where identity is a class that you want returned that implements Principal...