2012-04-30 53 views
5

我想配置GlassFish的3.1一個簡單的文件境界下面這個tutorial如何使用Netbeans 7.1配置glassfish 3.1安全文件領域?

我所做的一切,因爲它說,但不工作,當我出差到管理頁面不,我不看彈出消息詢問憑據。 這是我做過什麼:

1 - 創建一個文件境界: enter image description here

2 - 然後我使用管理用戶按鈕 enter image description here

3我創建了一個用戶創建使用圖形界面代替編輯的一個的glassfish-web.xml文件 enter image description here

4然後以同樣的方式我配置了web.xml enter image description here 很抱歉,如果這最後的圖像是一個有點難以看到的,你可以放大或縮小。

當我使用URL前往/admin.xhtml沒有什麼可以阻止我從查看的頁面的內容,這意味着什麼沒有配置正確。 我不知道我錯過了什麼。 有人能幫幫我試圖找到我不能讓這個簡單的安保任務的工作的原因嗎?

更新

這裏我的web.xml源

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> 
    <context-param> 
     <param-name>javax.faces.PROJECT_STAGE</param-name> 
     <param-value>Development</param-value> 
    </context-param> 
    <servlet> 
     <servlet-name>Faces Servlet</servlet-name> 
     <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> 
     <load-on-startup>1</load-on-startup> 
    </servlet> 
    <servlet-mapping> 
     <servlet-name>Faces Servlet</servlet-name> 
     <url-pattern>/faces/*</url-pattern> 
    </servlet-mapping> 
    <session-config> 
     <session-timeout> 
      30 
     </session-timeout> 
    </session-config> 
    <welcome-file-list> 
     <welcome-file>faces/index.xhtml</welcome-file> 
    </welcome-file-list> 
    <security-constraint> 
     <display-name>Constraint1</display-name> 
     <web-resource-collection> 
      <web-resource-name>allowed</web-resource-name> 
      <description/> 
      <url-pattern>/admin.xhtml</url-pattern> 
     </web-resource-collection> 
     <auth-constraint> 
      <description/> 
      <role-name>administrator</role-name> 
     </auth-constraint> 
    </security-constraint> 
    <login-config> 
     <auth-method>BASIC</auth-method> 
     <realm-name>file</realm-name> 
    </login-config> 
    <security-role> 
     <description/> 
     <role-name>administrator</role-name> 
    </security-role> 
</web-app> 

,並與GlassFish的web.xml源

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd"> 
<glassfish-web-app error-url=""> 
    <security-role-mapping> 
    <role-name>administrator</role-name> 
    <group-name>admin</group-name> 
    </security-role-mapping> 
    <class-loader delegate="true"/> 
    <jsp-config> 
    <property name="keepgenerated" value="true"> 
     <description>Keep a copy of the generated servlet class' java code.</description> 
    </property> 
    </jsp-config> 
</glassfish-web-app> 

基本上就是我想要做的是有2種用戶。客人誰只是瀏覽的index.xhtml和他們根本沒有憑據,誰擁有存儲在文件中的憑據,去admin.xhtml

我不明白什麼是缺少當被要求對他們的管理員。我是否需要爲訪客用戶創建特殊權限,表示他們可以查看index.xhtml?

+0

你不可能被使用NetBeans 3.1可以嗎?優步過時的Netbeans 5在6年前問世。 – jahroy

+1

@jahroy呵呵... UPS我的問題的標題犯了一個錯誤:)當然我使用NetBeans 7.1 – sfrj

+0

你嘗試重新啓動GlassFish和取消部署/部署應用程序?如果不仔細幫助通過了GlassFish啓動日誌對於關係到你的境界任何消息看(如果不是GlassFish是不拿起它,它至少應該被提及)。如果您發佈web.xml的源代碼可能會有所幫助。 – Eelke

回答

6

假設你的admin.xhtml是一個JSF頁面,那麼因爲你的JSF映射是/ faces/*,你可以通過像http:// localhost:8080/[Project /] faces/admin.xhtml這樣的URL來打開它。這種不匹配/admin.xhtml

替換:

<url-pattern>/admin.xhtml</url-pattern> 

<url-pattern>/faces/admin.xhtml</url-pattern> 
+0

是的,這是錯誤的。 非常感謝。 – sfrj

相關問題