2

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'>
<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?

4

1 回答 1

4

刚刚发现我必须将以下行添加到我的 web.xml 以更改领域:

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

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

默认领域也可以在管理菜单中设置,直接在“安全”部分(我怎么能监督...)

于 2010-07-08T12:42:37.970 回答