JiveJdon Community Forums
在线112人   首页   主题表   培训咨询   标签   精华   查搜   注册    登陆 RSS
首页 » 论坛 » 设计模式、框架和架构
???en_US.forumThreadPrev.name??? 上一主题
google yahoo 365Key网摘 CSDN网摘 添加到百度搜藏 POCO网摘 新浪ViVi 天极网摘
???en_US.forumThreadNext.name??? 下一主题
Go 共有 4 回复 / 1
 发表新帖子   回复该主题贴
ajoke

悄悄话
发表文章: 4
注册时间: 2003年07月17日 18:43
请问在web.xml设置的role-name怎么和数据库里面的值对应? 2003年07月24日 19:58 到本帖网址 加入本帖到收藏夹 回复该主题
标签
我现在看Service-to-Worker模式,看到里面有role-name在web.xml里面,我想弄个字段表示相应id的人所在的role属性,但是怎么和web.xml的配置对照起来?
另外petstore里面的j_security_check是怎么处理的?
Fish

悄悄话
发表文章: 16
注册时间: 2003年07月24日 19:18
Re: 请问在web.xml设置的role-name怎么和数据库里面的值对应? 2003年07月25日 09:18 到本帖网址 加入本帖到收藏夹 回复该主题
我给你写了一个,你看看吧,在resin下正常使用。如果其它的服务器不好用可以做相应的更改

<web-app>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

<!--直接把用户和角色配置在xml里
<authenticator>
<class-name>com.caucho.http.security.XmlAuthenticator</class-name>
<init-param user='Harry Potter:quidditch:user,gryffindor'/>
<init-param user='Draco Malfoy:pureblood:user,slytherin'/>
<init-param user='Fish:pwd:admin_user'/>
</authenticator>
-->
<!-- 从数据库里取用户和角色 -->
<authenticator id='com.caucho.http.security.JdbcAuthenticator'>
<pool-name>cncworkdb</pool-name>
<password-query>
SELECT password FROM userInfo WHERE userName=?
</password-query>
<cookie-auth-query>
SELECT cookie FROM userInfo WHERE userName=?
</cookie-auth-query>
<cookie-auth-update>
UPDATE userInfo SET cookie=? WHERE userName=?
</cookie-auth-update>
<role-query>
SELECT userRole FROM userInfo WHERE userName=?
</role-query>
</authenticator>

<!-- 设置被保护的资源 -->
<security-constraint>
<web-resource-collection>
<url-pattern>/FishTest/*.jsp</url-pattern>
<url-pattern>/FishTest/*.htm</url-pattern>
<url-pattern>/FishTest/*.html</url-pattern>
</web-resource-collection>
<auth-constraint role-name='admin'/>
</security-constraint>

<!-- 设置登录页面及登录失败页面 -->
<login-config>
<auth-method>FORM</auth-method>
<realm-name>default</realm-name>
<form-login-config>
<form-login-page>/FishTest/Login.jsp</form-login-page>
<form-error-page>/FishTest/LoginError.html</form-error-page>

<internal-forward>false</internal-forward>
<form-uri-priority>true</form-uri-priority>

</form-login-config>
</login-config>



</web-app>
Fish

悄悄话
发表文章: 16
注册时间: 2003年07月24日 19:18
Re: 请问在web.xml设置的role-name怎么和数据库里面的值对应? 2003年07月25日 09:19 到本帖网址 加入本帖到收藏夹 回复该主题


我给你写了一个,你看看吧,在resin下正常使用。如果其它的服务器不好用可以做相应的更改

<web-app>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

<!--直接把用户和角色配置在xml里
<authenticator>
<class-name>com.caucho.http.security.XmlAuthenticator</class-name>
<init-param user='Harry Potter:quidditch:user,gryffindor'/>
<init-param user='Draco Malfoy:pureblood:user,slytherin'/>
<init-param user='Fish:pwd:admin_user'/>
</authenticator>
-->
<!-- 从数据库里取用户和角色 -->
<authenticator id='com.caucho.http.security.JdbcAuthenticator'>
<pool-name>cncworkdb</pool-name>
<password-query>
SELECT password FROM userInfo WHERE userName=?
</password-query>
<cookie-auth-query>
SELECT cookie FROM userInfo WHERE userName=?
</cookie-auth-query>
<cookie-auth-update>
UPDATE userInfo SET cookie=? WHERE userName=?
</cookie-auth-update>
<role-query>
SELECT userRole FROM userInfo WHERE userName=?
</role-query>
</authenticator>

<!-- 设置被保护的资源 -->
<security-constraint>
<web-resource-collection>
<url-pattern>/FishTest/*.jsp</url-pattern>
<url-pattern>/FishTest/*.htm</url-pattern>
<url-pattern>/FishTest/*.html</url-pattern>
</web-resource-collection>
<auth-constraint role-name='admin'/>
</security-constraint>

<!-- 设置登录页面及登录失败页面 -->
<login-config>
<auth-method>FORM</auth-method>
<realm-name>default</realm-name>
<form-login-config>
<form-login-page>/FishTest/Login.jsp</form-login-page>
<form-error-page>/FishTest/LoginError.html</form-error-page>

<internal-forward>false</internal-forward>
<form-uri-priority>true</form-uri-priority>

</form-login-config>
</login-config>



</web-app>

ajoke

悄悄话
发表文章: 4
注册时间: 2003年07月17日 18:43
Re: 请问在web.xml设置的role-name怎么和数据库里面的值对应? 2003年07月25日 18:55 到本帖网址 加入本帖到收藏夹 回复该主题
Fish:
在web.xml这样写能够把数据库里面的信息和role-name对照起来?能不能给一个在登陆处理(.jsp或servlet)中怎么用的代码吗?
Fish

悄悄话
发表文章: 16
注册时间: 2003年07月24日 19:18
Re: 请问在web.xml设置的role-name怎么和数据库里面的值对应? 2003年07月26日 14:46 到本帖网址 加入本帖到收藏夹 回复该主题


这是登录页的代码
<form action='j_security_check' method='POST'>
<table>
<tr><td>User:<td><input name='j_username'>
<tr><td>Password:<td><input name='j_password'>
<tr><td colspan=2>hint: the password is 'quidditch'
<tr><td><input type=submit>
</table>
</form>
标签
共有 4 回复 / 1Go
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表    返回页首返回页首
???en_US.forumThreadNext.name??? 下一主题
热点TAG:
正在读取,请等待...
查询本论坛内 回复超过的热门帖子
标题
 
粗体: [b]文本[/b] 斜体: [i]文本[/i] 下划线 [u]文本[/u] 插入图片 [img]http://wwww.xxxx.com/img.ext[/img] 插入代码 [code]程序代码[/code]  插入url链接 [url]http://url[/url] / [url=http://url]URL加下滑线[/url] 插入附件 插入word文档 Txt等文件
内容
  提交时自动拷贝以上内容到剪贴板 Ctrl-V可取出;提问题前先查询标签列表

RSS 手机阅读 add to google add to yahoo
解惑之道在J道 ,打造中国最具影响力的的企业软件社区 推荐Chrome快速浏览本站
OpenSource JIVEJDON v3.5 Powered by JdonFramework Code © 2002-09 jdon.com

anti spam