《flex安全性》word版_第1頁
《flex安全性》word版_第2頁
《flex安全性》word版_第3頁
《flex安全性》word版_第4頁
《flex安全性》word版_第5頁
已閱讀5頁,還剩13頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、后臺hibernate,spring前臺flex如何使用Blazeds安全,請看下文什么是Blazeds安全?Blazeds安全用來控制對服務(wù)器端destination的訪問(destination的配置在后臺的remoting-config.xml文件中),F(xiàn)lex客戶端只有通過服務(wù)端驗證才能連接到一個destination,Blazeds使用底層J2EE應(yīng)用服務(wù)器安全框架來支持身份驗證和授權(quán)。你可以定義自己的邏輯執(zhí)行身份驗證和授權(quán)。在后臺我們限制對一個destination的訪問是通過為destination添加安全約束例如我們定義一個安全約束Custommanagerguest定義一個有

2、安全約束的destinationspringcodeTableViewService什么是security constraint一個安全約束確保一個用戶在訪問destination前必須要經(jīng)過驗證。安全約束中可以定義角色,用戶可以以這些角色中的一個訪問服務(wù)。配置一個安全約束可以使用basic或者自定義驗證兩者方式。兩者的區(qū)別是服務(wù)端響應(yīng)方式不同,如果用戶為經(jīng)過驗證,basic驗證會發(fā)生401錯誤,瀏覽器彈出一個登錄框如下圖:Custom驗證方式會發(fā)送一個錯誤到客戶端,一般情況下我們使用custom驗證,本文的重點是Custom安全約束。關(guān)于login commandBlazeds使用一個登錄命

3、令來檢查證書和記錄登錄到服務(wù)器的用戶。Blazeds包括了實現(xiàn)Tomcat,JBoss,BEA,WebLogic,WebSpher,JRUN等J2EE應(yīng)用服務(wù)器的login command。一個登錄命令必須實現(xiàn)接口。示例:關(guān)于安全通道和端點除了驗證和授權(quán)用戶,你也可以使用安全通道和端點實現(xiàn)一個安全的傳輸協(xié)議。例如下面的AMF通道定義了一個非安全的傳輸連接Blazeds提供在HTTPS連接上傳輸數(shù)據(jù)的安全版本的AMF和HTTP通道和端點下面示例定義了一個AMF通道使用安全的傳輸機(jī)制e建立安全約束a定義約束:BasicmanagerguestCustommanagerguest配置destinat

4、ion./此destination引用的是basicUsersSC custom安全約束./此destination引用的是trusted basic安全約束如果要配置的destination太多,而這些destination使用的又是同一個安全約束,則可以使用如下默認(rèn)約束方式,如果一個destination再次配置了securitiy-constraint,會覆蓋default-security-constraint。對方法提供安全約束如下方式可以對某一個destination提供的部分方法使用安全約束。對應(yīng)的exclude-methods可以對部分方法不使用安全約束pany.SampleS

5、erviceCustom驗證使用custom驗證傳送驗證證書到一個destination,你需要指定一個name和password做為參數(shù)到ChannelSet.login方法。通過調(diào)用ChannelSet.logout()移除證書。如:channelSet.login(“name”,”pwd”);因為多個destination使用相同通道,所以相應(yīng)的channelSet對象登錄到一個destination會記錄了用戶到其他的使用了相同通道的destination。如果兩個組件使用不同的證書到一個相同的ChannelSet對象,最后一個證書會有效。調(diào)用Logout方法記錄所有組件退出desti

6、nation。服務(wù)端如何處理Logout,依賴per-client-authentication屬性的配置,如果per-client-authentication設(shè)置為false,logout方法會使當(dāng)前session無效,新的FlexSession對象會自動創(chuàng)建或代替。如果per-client-authentication設(shè)置為true,logou方法會清除存儲在Flexclient對象中的驗證信息,不會使FlexClient或FlexSession對象無效。自定義驗證示例給TOMCAT服務(wù)器配置自定義驗證A將flex-tomcat-common.jar,flex-tomcat-server

7、.jar放置到TOMCAT/lib.blzaeds目錄下面編輯tomcat/conf/perties文件,添加如下路徑到common.loader屬性$catalina.home/lib/blazeds/*.jarB編輯tomcat/conf/context.xml文件,添加如下標(biāo)簽到Context descriptors:C .重啟Tomcat配置Tomcat Realm(這里的配置完全可以參考tomcat官方的文檔)由于Blazeds的安全驗證是基于J2EE服務(wù)器的安全驗證,所以登錄的用戶(有manager角色)同樣能登錄到Tomcat服務(wù)器。為了方便管理Blazeds應(yīng)用程序安全約束中的

8、的用戶和角色,我們需要配置Tomcat Realm默認(rèn)情況下,登錄到Tomcat的用戶和角色是存放在tomcat/conf/tomcat-users.xml,如下示例:什么是Realm一個Realm就是一個存有用戶和密碼及用戶相關(guān)聯(lián)角色的數(shù)據(jù)庫,用來驗證一個web應(yīng)用的有效用戶。Tomcat6定義了一個JAVA接口org.apache.catalina.Realm,實現(xiàn)了此接口的插件組件能建立和數(shù)據(jù)庫連接,如:JDBCRealm,DataSourceRealm,JNDIRealm等,其中JDBCRealm能通過一個JDBC驅(qū)動獲取存儲在關(guān)系數(shù)據(jù)庫的驗證信息。下面介紹JDBCRealm的配置。如

9、何配置一個JDBCRealmA .在你的數(shù)據(jù)庫中必須要有如下格式的兩張表。用戶表和關(guān)聯(lián)的角色表,示例如下用戶表:create table users (user_name varchar(15) not null primary key,-登錄的用戶名user_pass varchar(15) not null-用戶的密碼);用戶角色表:create table user_roles (user_name varchar(15) not null,-用戶名role_name varchar(15) not null,-用戶角色名primary key (user_name, role_name

10、);一般情況,你需要一個XML元素到tomcat/conf/server.xml配置文件。對應(yīng)ORACLEB.將對應(yīng)數(shù)據(jù)庫的JDBC驅(qū)動放到TOMCAT/LIB目錄下面,只有jar文件才能被認(rèn)到。C在tomcat/conf/server.xml中建立一個RealmD重啟Tomcat服務(wù)器關(guān)于Realm配置的一些屬性AttributeDescriptionclassNameThe fully qualified Java class name of this Realm implementation. YouMUSTspecify the value org.apache.catalina.re

11、alm.JDBCRealm here.connectionNameThe database username used to establish a JDBC connection.connectionPasswordThe database password used to establish a JDBC connection.connectionURLThe database URL used to establish a JDBC connection.digestThe digest algorithm used to store passwords in non-plaintext

12、 formats. Valid values are those accepted for the algorithm name by the java.security.MessageDigest class. See HYPERLINK http:/localhost:8010/docs/realm-howto.html l Digested Passwords#Digested Passwords Digested Passwordsfor more information. If not specified, passwords are stored in clear text.dri

13、verNameThe fully qualified Java class name of the JDBC driver to be used. Consult the documentation for your JDBC driver for the appropriate value.roleNameColThe name of the column, in theuser rolestable, that contains the name of a role assigned to this user.userCredColThe name of the column, in th

14、euserstable, that contains the password for this user (either in clear text, or digested if the digest attribute is set).userNameColThe name of the column, in theusersanduser rolestables, that contains the username of this user.userRoleTableThe name of the table that contains one row for eachroleass

15、igned to a particularusername. This table must include at least the columns named by the userNameCol and roleNameCol attributes.userTableThe name of the table that contains one row for eachusernameto be recognized by Tomcat. This table must include at least the columns named by the userNameCol and userCredCol attributes.示例:1.我連接的數(shù)據(jù)庫是ORACLE,配置如下:對應(yīng)的用戶表operator:operatoridnumber(19)codevarchar2(255 c

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論