0

我是新來的基本身份驗證。我創建了一個沒有資源的虛擬Web應用程序。下面是安全約束我在網上的xml文件中添加瀏覽器不彈出基本身份驗證的登錄提示

<security-constraint> 
     <web-resource-collection> 
      <web-resource-name>contextRoot</web-resource-name> 
      <url-pattern>/*</url-pattern> 
     </web-resource-collection> 
     <auth-constraint> 
      <role-name>AuthorizedUser</role-name> 
     </auth-constraint> 
     <user-data-constraint> 
      <transport-guarantee>NONE</transport-guarantee> 
     </user-data-constraint> 
    </security-constraint> 

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

我部署我的應用程序在WebSphere 8.5,並試圖打一些隨機資源本應用來檢查瀏覽器挑戰我進行身份驗證。我沒有看到一個。

回答

0

你的web.xml似乎是正確的,應提示基本身份驗證。但似乎你的web項目中沒有任何資源(jsp或servlet)。我在一個web項目中創建了一個simple.jsp,並使用了web.xml的內容,並得到了基本認證挑戰的提示。對於登錄工作,你會需要映射安全角色「AuthorizedUser」有效的用戶在配置用戶註冊表或使用特殊的主題爲「所有經過驗證的用戶」。

Sample.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
<title>Hello JSP</title> 
</head> 
<body> 
<%= "Hello World!" %> 
</body> 
</html> 

如果http://hostname:port/simple.jsp叫你已經在web.xml中的東西,基本的身份驗證質詢應提示。

+0

謝謝你,我啓用了WebSphere Application安全性,使用戶的作用和它的工作 –

+0

我很高興它爲你工作。如果答案解決了您的問題,請將其標記爲已接受。 –

相關問題