<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    捕風之巢

    統計

    留言簿(3)

    java友情鏈接

    閱讀排行榜

    評論排行榜

    創建安全的web應用程序

    為了保證web應用程序的安全,應該對登錄的用戶進行身份驗證。在WebLogic Server中進行web應用程序的身份驗證有兩種方式:
    1.基本驗證方式(Basic Authentication)
    2.表單驗證方式(Form Authentication)
    基本驗證方式比較簡單,而表單驗證方式可以提供自定義的登錄頁面和出錯處理頁面。
    1.基本驗證方式(Basic Authentication)
    ?采用這種驗證方式的web應用程序,用戶訪問時首先會彈出一個登錄界面要求用戶輸入用戶名和密碼,然后查看此用戶是否在web應用中定義的安全角色中。
    ?開發一個以基本驗證方式進行身份驗證的web應用程序的基本步驟如下。
    ?(1)在web應用程序的描述符web.xml中做如下聲明:

    ? < security-role >
      
    < role-name > webuser </ role-name >
     
    </ security-role >


    指定驗證方式為基本驗證方式:用<login-config>定義。例如:

    < login-config >
      
    < auth-method > BASIC </ auth-method >
      
    < realm-name > default </ realm-name >
     
    </ login-config >

    定義被保護的資源,例如下面這段聲明指明了只有角色webuser才能訪問被保護的資源:

    < security-constraint >
     
    < web-resource-collection >
      
    < web-resource-name > Success </ web-resource-name >
      
    < url-pattern > /welcome.jsp </ url-pattern >
       
    < http-method > GET </ http-method >
       
    < http-method > POST </ http-method >
     
    </ web-resource-collection >
     
    < auth-constraint >
      
    < role-name > webuser </ role-name >
     
    </ auth-constraint >
     
    </ security-constraint >


    (2)在weblogic.xml文件中定義安全角色到weblogic server中用戶或用戶組的映射。即指定weblogic server中的哪些實體屬于安全角色。例如下面這段聲明將weblogic server中的實體myGroup映射到安全角色webUser:

    < weblogic-web-app >
     
    < security-role-assignment >
      
    < role-name > webuser </ role-name >
      
    < principal-name > myGroup </ principal-name >
     
    </ security-role-assignment >
    </ weblogic-web-app >


    ?下面時完整的相關頁面:
    ?web.xml文件
    ?
    ?

    < web-app >
    ?
    < welcome-file-list >
    ??
    < welcome-file > welcome.jsp </ welcome >
    ?
    </ welcome-file-list >
     
    < security-constraint >
     
    < web-resource-collection >
      
    < web-resource-name > Success </ web-resource-name >
      
    < url-pattern > /welcome.jsp </ url-pattern >
       
    < http-method > GET </ http-method >
       
    < http-method > POST </ http-method >
     
    </ web-resource-collection >
     
    < auth-constraint >
      
    < role-name > webuser </ role-name >
     
    </ auth-constraint >
     
    </ security-constraint >
     
    < login-config >
      
    < auth-method > BASIC </ auth-method >
      
    < realm-name > default </ realm-name >
     
    </ login-config >
     
    < security-role >
      
    < role-name > webuser </ role-name >
     
    </ security-role >
    </ web-app >

    weblogic.xml文件

    < weblogic-web-app >
     
    < security-role-assignment >
      
    < role-name > webuser </ role-name >
      
    < principal-name > myGroup </ principal-name >
     
    </ security-role-assignment >
    </ weblogic-web-app >

    ?

    welcome.jsp文件

    < html >
    ?
    < head >
    ??
    < title > Browser?Based?Authentication?Example?Welcome?Page </ title >
    ?
    </ head >
    ?
    < body >
    ?
    < h1 > Browser?Based?Authentication?Example?Welcome?Page </ h1 >
    ?
    < p > Welcome <% = request.getRemoteUser() %>
    ?
    </ body >
    </ html >

    2.表單驗證方式
    使用表單驗證方式進行web應用程序的身份驗證,需要開發者定義一個登錄頁面和登錄失敗的錯誤處理頁面。登錄頁面可以時html、jsp或servlet。使用這種驗證方式的好處時可以對程序有更進一步的控制。登錄頁面應該讓用戶輸入用戶名和密碼,錯誤處理頁面應該將驗證失敗的信息反饋給用戶。開發使用表單驗證方式的web應用程序的基本步驟如下。
    (1)編寫登錄頁面和錯誤處理頁面,在web應用程序的歡迎頁面中加入到登錄頁面的超級鏈接,提示用戶首先進行登錄。登錄頁面舉例:


    < form? method ="POST" ?action ="j_security_check" >
    ???
    < input? type ="text" ?name ="j_username" >
    ???
    < input? type ="text" ?name ="j_password" >
    ???
    < input? type ="submit" ?value ="Log?in" >
    </ form >

    (2)配置web.xml

    < web-app >
    < welcome-file-list >
    ??
    < welcome-file > welcome.jsp </ welcome >
    ?
    </ welcome-file-list >
    < login-config >
    ???
    < auth-method > FORM </ auth-method >
    ???
    < realm-name > Web?Demo </ realm-name >
    ???
    < form-login-config >
    ??????
    < form-login-page > /admin/login.jsp </ form-login-page >
    ??????
    < form-error-page > /admin/error.jsp </ form-error-page >
    ???
    </ form-login-config >
    </ login-config >
    < security-role >
      
    < role-name > webuser </ role-name >
    </ security-role >
    < security-constraint >
     
    < web-resource-collection >
      
    < web-resource-name > Success </ web-resource-name >
      
    < url-pattern > /welcome.jsp </ url-pattern >
       
    < http-method > GET </ http-method >
       
    < http-method > POST </ http-method >
     
    </ web-resource-collection >
     
    < auth-constraint >
      
    < role-name > webuser </ role-name >
     
    </ auth-constraint >
    </ security-constraint >
    < security-constraint >
     
    < web-resource-collection >
      
    < web-resource-name > login </ web-resource-name >
      
    < url-pattern > /login2.jsp </ url-pattern >
       
    < http-method > GET </ http-method >
       
    < http-method > POST </ http-method >
     
    </ web-resource-collection >
     
    < auth-constraint >
      
    < role-name > webuser </ role-name >
     
    </ auth-constraint >
    </ security-constraint >
    </ web-app >

    (3)在weblogic.xml文件中定義安全角色到weblogic server中實體(用戶或用戶組)的映射。例如:

    < weblogic-web-app >
     
    < security-role-assignment >
      
    < role-name > webuser </ role-name >
      
    < principal-name > myGroup </ principal-name >
     
    </ security-role-assignment >
    </ weblogic-web-app >

    posted on 2006-10-11 10:50 捕風 閱讀(489) 評論(0)  編輯  收藏 所屬分類: web開發

    主站蜘蛛池模板: 免费精品国产自产拍在线观看 | 亚洲精品无码乱码成人| 久久久无码精品亚洲日韩按摩| 亚洲av午夜成人片精品网站 | 精品亚洲视频在线| 在线免费观看视频你懂的| 亚洲国产精品第一区二区| 一级做a爰全过程免费视频| 亚洲国产精品嫩草影院在线观看| 亚洲精品国产成人| 三年片在线观看免费大全电影| 青草草色A免费观看在线| 亚洲综合色丁香麻豆| 99久久免费国产精品特黄| 亚洲一卡2卡4卡5卡6卡在线99 | 亚欧日韩毛片在线看免费网站| 麻豆视频免费观看| 亚洲AV成人一区二区三区在线看| 三年片在线观看免费观看大全中国| 免费无码专区毛片高潮喷水| 国产香蕉免费精品视频| 国产.亚洲.欧洲在线| 免费的一级黄色片| 成人在线免费视频| 亚洲av日韩av天堂影片精品| 91在线手机精品免费观看| avtt天堂网手机版亚洲| 国产一级淫片免费播放| 中文字幕成人免费高清在线视频| 日韩免费视频一区| 一级毛片免费毛片毛片| 亚洲乱亚洲乱淫久久| 99在线精品免费视频九九视| AV激情亚洲男人的天堂国语| 亚洲熟妇无码乱子AV电影| 久久久久久久岛国免费播放 | 亚洲精品乱码久久久久久中文字幕 | 久久99国产亚洲高清观看首页| 亚洲AV无码一区二区三区牲色| 97公开免费视频| 亚洲av无码专区亚洲av不卡|