views:

28

answers:

1

I'm building a JEE6-application that runs on Glassfish v3.0.1. It's a web-application with EJBs, deployed as a WAR (EJB 3.1).

Currently i'm trying to configure a login by using a JDBC-based security realm. Now i don't know how to configure my WAR-application to not use the default Glassfish Security Realm (file) and instead use my newly created JDBC-realm. I know how to do it in a EAR-application, there you can deploy a sun-application.xml together with the application with a content like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-application PUBLIC '-//Sun Microsystems, Inc.//DTD 
Application Server 9.0 Java EE Application 5.0//EN' 
'http://www.sun.com/software/appserver/dtds/sun-application_5_0-0.dtd'&gt;
<sun-application>
   <realm>jdbc</realm>
</sun-application>

But as i have a web-application, i can't use it, at least not when deploying the app (i get an error because my app isn't configured for EAR-deployment) Can i declare the default security realm within the sun-web.xml? I also couldn't find an option within the Glassfish-admin-interface, or did i miss it?

A: 

Just found out that i have to add the following lines to my web.xml to change the realm:

<login-config>
  <auth-method>BASIC</auth-method>
  <realm-name>jdbc</realm-name>
</login-config>

<security-role>
  <description />
  <role-name>STUDENT</role-name>
</security-role>

The default realm can also be set in the admin menu, directly in the section "Security" (how could i oversee that...)

ifischer