如何实现这种登陆框?有兴趣的请进!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

xixuemao 2004-09-15 10:20:56
有时我们输入网址进入页面前会弹出一个身份验证框,ftp的访问几乎都有这种验证框,这个好像不是自己写的吧,是不是通过什么设置就可以实现呢?
我想别人在进入我的jsp网页时也出现这个验证框?
有知道怎么设置的吗?谢谢
...全文
504 36 打赏 收藏 转发到动态 举报
写回复
用AI写文章
36 条回复
切换为时间正序
请发表友善的回复…
发表回复
xixuemao 2004-09-20
  • 打赏
  • 举报
回复
我知道哪里出问题了,已经搞定了,结帖喽。
不太喜欢散分。
xixuemao 2004-09-20
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="ISO-8859-1"?>

<security-constraint>
<display-name>Example Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<!-- Define the context-relative URL(s) to be protected -->
<url-pattern>/test/*</url-pattern>
<!-- If you list http methods, only those methods are protected -->
</web-resource-collection>
<auth-constraint>
<!-- Anyone with one of the listed roles may access this area -->
<role-name>manager</role-name>
</auth-constraint>
</security-constraint>

<!-- Default login configuration uses form-based authentication -->
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Example Form-Based Authentication Area</realm-name>
<form-login-config>
<form-login-page>/test/login.jsp</form-login-page>
</form-login-config>
</login-config>

<!-- Security roles referenced by this web application -->
<security-role>
<role-name>manager</role-name>
</security-role>

</web-app>
是啊,可我配的这个哪里有问题啊?为什么不行啊,晕哦~~
shaopin 2004-09-17
  • 打赏
  • 举报
回复
这个web.xml应该是你这个应用下面的,只对你的这个应用起作用。
xixuemao 2004-09-16
  • 打赏
  • 举报
回复
Drate(小虫) 快来挖!!!!!!!!!!!111
xixuemao 2004-09-16
  • 打赏
  • 举报
回复
你的web。xml文件放在哪啊?新建一个web.xml文件吗?还是直接配置conf目录下的那个web.xml呢?多谢执教。
Drate 2004-09-16
  • 打赏
  • 举报
回复
呵呵,这个东东的话在TOMCAT中就可以配置的,如果我们在TOMCAT中进入管理员页面的话,这个就是需要进行配置的:
<!-- Define a Security Constraint on this Application -->
<security-constraint>
<web-resource-collection>
<web-resource-name>HTMLManger and Manager command</web-resource-name>
<url-pattern>/threeparam</url-pattern>
<url-pattern>/hello</url-pattern>
</web-resource-collection>
<auth-constraint>
<!-- NOTE: This role is not present in the default users file -->
<role-name>manager</role-name>
</auth-constraint>
</security-constraint>

上面的就是我在WEB.XML中配置的对于/hello,/threeparam这两个servlet进行访问的时候需要有manager权限的,而manager权限呢,则是在:
conf/tomcat-users.xml中进行配置的,下面是我配置的内容:
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="standard"/>
<role rolename="manager"/>
<user username="Drate" password="Drate" roles="standard,manager"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>

xixuemao 2004-09-16
  • 打赏
  • 举报
回复
to:zyb1235(翟)
那个用户名和密码在那里配置呢?还有就是,为什么我点了取消后还是进入了页面。汗~~
sw47 2004-09-16
  • 打赏
  • 举报
回复
我有个折中的办法,iis建一个验证目录,然后这个目录的默认文件转向到jsp的地址
挖哈哈
xixuemao 2004-09-16
  • 打赏
  • 举报
回复
我到想用呢?看半天也没看懂怎么配置。
可楼上的意思是在程序里写,我试试哈。谢谢
zyb1235 2004-09-16
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/3115/3115461.xml?temp=.9703485
zyb1235 2004-09-16
  • 打赏
  • 举报
回复
这种验证保密性不是很好,因为采用的是64位编码的对称方法,所以尽量不要用。
xixuemao 2004-09-16
  • 打赏
  • 举报
回复
jsp可以用IIS做服务器吗?不懂挖。。晕
fanged 2004-09-16
  • 打赏
  • 举报
回复
或者通过Apache设置也可以的。
fanged 2004-09-16
  • 打赏
  • 举报
回复
javascript
xixuemao 2004-09-16
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="ISO-8859-1"?>

<security-constraint>
<display-name>Example Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<!-- Define the context-relative URL(s) to be protected -->
<url-pattern>/test/*</url-pattern>
<!-- If you list http methods, only those methods are protected -->
</web-resource-collection>
<auth-constraint>
<!-- Anyone with one of the listed roles may access this area -->
<role-name>manager</role-name>
</auth-constraint>
</security-constraint>

<!-- Default login configuration uses form-based authentication -->
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Example Form-Based Authentication Area</realm-name>
<form-login-config>
<form-login-page>/test/login.jsp</form-login-page>
</form-login-config>
</login-config>

<!-- Security roles referenced by this web application -->
<security-role>
<role-name>manager</role-name>
</security-role>

</web-app>
这是我新建的一个web.xml文件,全部内容就这些了,有错误吗???为什么还是没有出现验证框挖??????!!!!!!!!
xixuemao 2004-09-16
  • 打赏
  • 举报
回复
我按照你说的配置了web.xml文件,可为什么不行啊?
是不是应该配置conf目录下的那个web.xml,还是写一个新的web.xml文件放到
我自己那个应用程序的web-inf目录下呢???
shaopin 2004-09-16
  • 打赏
  • 举报
回复
越搞越复杂了,
如果是为了新颖而去做基础验证,建议不要去做,这种方案安全性性得不到保障.难道做基于表单的验证不好吗?再加上CA认证,安全性应用够可以了.

首先确定你的服务器,而不是为了出这种效果再去确定服务器.况且一般你做jsp可能就是用tomcat做服务,可以做基础验证.用其他应用服务也可以,只不过web.xml的配置不同而已.
我说的都假定你在做jsp.

如果你想用iis做服务器,还要去装插件,多此一举.


xixuemao 2004-09-16
  • 打赏
  • 举报
回复
那jsp页面怎么用iis做服务器挖?
sw47 2004-09-16
  • 打赏
  • 举报
回复
把iis的匿名访问去掉,可以实现,别的web服务器就不知道了
xixuemao 2004-09-16
  • 打赏
  • 举报
回复
up
加载更多回复(16)

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧