users@glassfish.java.net

Authenticating from application client

From: <glassfish_at_javadesktop.org>
Date: Sat, 10 Nov 2007 07:54:12 PST

Hi,

I have successfully managed to write a custom realm to authenticate against a bespoke system.

How do I now get an application client that accesses these ejb's to authenticate against that realm?

I have hunted around for any documentation on this and keep hitting against a brick wall.

sun-ejb-jar.xml excerpt

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
<sun-ejb-jar>
  <enterprise-beans>
        <unique-id>0</unique-id>
        <ejb>
                                          <ejb-name>ContactBean</ejb-name>
            <jndi-name>ejb/ContactBean</jndi-name>
            <pass-by-reference>false</pass-by-reference>
            <ior-security-config>
                <as-context>
                    <auth-method>username_password</auth-method>
                    <realm>IVRealm</realm>
                    <required>true</required>
                </as-context>
                <sas-context>
                    <caller-propagation>supported</caller-propagation>
                </sas-context>
            </ior-security-config>
            <is-read-only-bean>false</is-read-only-bean>
          </ejb>
  </enterprise-beans>
</sun-ejb-jar>


IVRealm is the custom realm. I have checked logs to ensure that it has been setup and initialised correctly, which it has been.

EJB defined as:

@Stateful(name="ContactBean", mappedName="ejb/ContactBean")
@Remote(ContactRemote.class)
@RolesAllowed("admin")
public class ContactBean extends ObjectBean<Contact, ContactRemote> implements ContactRemote {

...

}

I try to acccess the EJB using:

 Properties props = new Properties();
 props.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
 props.setProperty(Context.SECURITY_PRINCIPAL, "testing");
 props.setProperty(Context.SECURITY_CREDENTIALS, "testing");

 InitialContext ctx = new InitialContext(props);
 T ref = (T) ctx.lookup("ejb/ContactBean");

When trying to access it, I get java.rmi.AccessException:

I have sufficient logging enabled in the custom realm but an authentication request is never received.

Am I misunderstanding how the authentication works?

Any help in resolving this would be greatly appreciated.

Best Wishes,


Shri
[Message sent by forum member 'shriram' (shriram)]

http://forums.java.net/jive/thread.jspa?messageID=244881