牛仔褲的夏天

          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 閱讀(468) 評論(0)  編輯  收藏 所屬分類: Tomcat & Weblogic
          主站蜘蛛池模板: 磴口县| 乌兰县| 巴中市| 常宁市| 巴东县| 综艺| 南通市| 嘉祥县| 博罗县| 梁河县| 水城县| 澄城县| 平果县| 武宣县| 宿州市| 通州区| 永仁县| 高青县| 信阳市| 乌鲁木齐县| 蚌埠市| 平陆县| 比如县| 大石桥市| 万州区| 临洮县| 永吉县| 霍邱县| 茌平县| 镇原县| 庆阳市| 宜兰市| 稷山县| 丹东市| 土默特左旗| 鸡西市| 新沂市| 徐汇区| 万年县| 巴里| 穆棱市|