开发者

Glassfish: How to change the security realm for a WAR-app

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 th开发者_运维技巧e 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?


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...)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜