牛仔褲的夏天

          JAVA是藍色的- online

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            30 隨筆 :: 5 文章 :: 15 評論 :: 0 Trackbacks
          在tomcat中的配置比較簡單
          首先定義了tomcat-users.xml 中的內容,主要設置了用戶和角色
          <?xml?version='1.0'?encoding='utf-8'?>
          <tomcat-users>
          ??
          <role?rolename="tomcat"/>
          ??
          <role?rolename="role1"/>
          ??
          <role?rolename="manager"/>
          ??
          <role?rolename="wxds"?description=""/>
          ??
          <role?rolename="admin"/>
          ??
          <user?username="tomcat"?password="tomcat"?roles="tomcat"/>
          ??
          <user?username="both"?password="tomcat"?roles="tomcat,role1"/>
          ??
          <user?username="role1"?password="tomcat"?roles="role1"/>
          ??
          <user?username="abc"?password="abc"?fullName="abcabc"?roles="wxds"/>
          ??
          <user?username="admin"?password=""?roles="admin,manager"/>
          </tomcat-users>

          然后在application中的web.xml中對應的<web-app>中增加如下設置
          ???<security-constraint>
          ???????
          <web-resource-collection>
          ???????????
          <web-resource-name>Protected?Area</web-resource-name>
          ????????
          <!--?Define?the?context-relative?URL(s)?to?be?protected?-->
          ???????????
          <url-pattern>*</url-pattern>
          ????????
          <!--?If?you?list?http?methods,?only?those?methods?are?protected?-->
          ????????
          <http-method>DELETE</http-method>
          ???????????
          <http-method>GET</http-method>
          ???????????
          <http-method>POST</http-method>
          ????????
          <http-method>PUT</http-method>
          ???????
          </web-resource-collection>
          ???????
          <auth-constraint>
          ???????????
          <!--?Anyone?with?one?of?the?listed?roles?may?access?this?area?-->
          ???????????
          <role-name>wxds</role-name>
          ???????
          </auth-constraint>
          ???
          </security-constraint>
          ???
          <login-config>
          ???????
          <auth-method>BASIC</auth-method>
          ???????
          <realm-name>EShop</realm-name>
          ???
          </login-config>

          這樣就好了,登錄這個web應用會有個驗證窗口彈出,輸入用戶名abc和密碼abc后就能正常訪問了。

          在weblogic8.1中的配置比較麻煩,首先在web.xml的<web-app>中增加上面一段代碼后,還要加上這一段
          <security-role>
          ??????
          <role-name>wxds</role-name>
          </security-role>

          然后新建一個weblogic.xml 內容如下
          <?xml?version="1.0"?encoding="UTF-8"?>
          <!DOCTYPE?weblogic-web-app?PUBLIC?"-//BEA?Systems,?Inc.//DTD?Web?Application?8.1//EN"?"http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd">

          <weblogic-web-app>

          ??
          <security-role-assignment>
          ????
          <role-name>wxds</role-name>
          ????
          <principal-name>wxds_group</principal-name>
          ??
          </security-role-assignment>

          </weblogic-web-app>

          進入weblogic的console,在mydomain-security-realms中新建一個realm
          name: wxdsRealm
          check roles and policies for: web applications and ejbs protected in dd
          展開wxdsRealm,
          在providers中configure a new default adjudicator... 默認創建
          在auditors中創建一個缺省auditor
          然后創建一個缺省的authentication,authorizers, cred mappers 和role mapper 等等
          最后可以在testing中測試一下 validate this security realm... 看是否successful

          在groups中定義一個group name: wxds_group
          在users中configure a new user
          name: jyds password:11111111
          把剛才建立的wxds_group 增加進來

          把Security中的Default Realm設置為wxdsRealm, 最后Apply就ok啦。

          posted on 2006-03-22 14:24 luckyrobbie 閱讀(475) 評論(0)  編輯  收藏 所屬分類: Tomcat & Weblogic
          主站蜘蛛池模板: 沾益县| 仙桃市| 黔南| 布尔津县| 广宁县| 南城县| 华阴市| 河南省| 白银市| 济源市| 崇明县| 濮阳县| 五指山市| 巴塘县| 临漳县| 庐江县| 专栏| 黄陵县| 新宁县| 合江县| 洞口县| 怀化市| 龙井市| 南漳县| 全椒县| 盐山县| 文水县| 育儿| 菏泽市| 昆明市| 安徽省| 楚雄市| 柘荣县| 双江| 鄂州市| 南雄市| 隆昌县| 沁水县| 柘荣县| 安义县| 开化县|