站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Java 专题JAAS 实现in Struts Web App,使用XMLPolicy文件,不改变VM安全配置(1)

JAAS 实现in Struts Web App,使用XMLPolicy文件,不改变VM安全配置(1)

摘要: JAAS 实现in Struts Web App,使用XMLPolicy文件,不改变VM安全配置(1)
内容: JAAS参考资料中流行的文章是扩展JAAS实现类实例级授权

但它是基于JDK1.3,与目前的JDK1.4,JDK1.5不兼容,例如其中的配置如下:

The following assumes you are using JDK 1.3 and the files were extracted to
the d:\JaasExample directory. You will save some work by extracting the files
to this directory otherwise you will have to modify the policy and the ResourceSecurity.xml
policy files with the correct path names.

1) Copy the jaas.jar and the jaasmod.jar to your JDK jre\lib\ext directory
(i.e. D:\JDK1.3\jre\lib\ext).

2) Add the following to the end of the java.security file located in JDK's
jre\lib\security directory (i.e. D:\JDK1.3\jre\lib\security):
auth.policy.provider=com.ibm.resource.security.auth.XMLPolicyFile

3) Execute the run.bat file.

1.4以后为policy.provider=PolicyFile。而且需要修改java.security文件
我经过2天的呕血奋战实现了不改变java VM环境和Web server环境,在struts下实现JAAS。
步骤如下:

1. welcome.jsp, index.jsp, struts-config.xml

<%@ taglib uri="/tags/struts-logic" prefix="logic" %>

<%-- welcome.jsp
Redirect default requests to Welcome global ActionForward.
By using a redirect, the user-agent will change address to match the path of our Welcome ActionForward.
--%>


index.jsp

<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>


Logon
<body>

User ID: <input type="text" name="userID" value="tyrone" />

Passord: <input type="password" name="password" value="password"/>



</body>


struts-config.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>

struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">


Java, java, J2SE, j2se, J2EE, j2ee, J2ME, j2me, ejb, ejb3, JBOSS, jboss, spring, hibernate, jdo, struts, webwork, ajax, AJAX, mysql, MySQL, Oracle, Weblogic, Websphere, scjp, scjd
↑返回目录
前一篇: JAAS 实现in Struts Web App,使用XMLPolicy文件,不改变VM安全文件(2)
后一篇: 用MVC写的扫雷