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

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

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

    posts - 37,  comments - 53,  trackbacks - 0
      2010年3月19日
    grails應(yīng)用以war包的方式發(fā)布到weblogic本來應(yīng)該是沒有什么問題的,也不需要像網(wǎng)上說的那樣進行weblogic的配置,但是有兩個小問題在實際的使用中需要注意:
    1.我的應(yīng)用中,使用了spring-security-cas的插件來實現(xiàn)cas client,但是不知道為什么在生產(chǎn)war包是,在web.xml中,有兩個CAS Single Sign Out Filter的mapping,結(jié)果導(dǎo)致發(fā)布失敗,需要手工刪除一個(目前的解決辦法)
    2.grails的urlmapping插件,如果映射“/”到某個action,目前好像是不成功的,但是只要不是“/”,則沒有這個問題。如果默認(rèn)的根目錄不是index.gsp,這個可能需要在訪問“/”時進行跳轉(zhuǎn)的處理。

    posted @ 2011-02-09 16:21 雪地孤鴻 閱讀(520) | 評論 (0)編輯 收藏
    1.weblogic必須是10.3.4.0或以上版本,由于cas server采用了spring 2.5的版本,使用JPA2.0的原因,weblogic10.3.4之前的版本不支持jpa2.0
    2.cas server webapp 如果以war的方式發(fā)布,會因為log4j.xml的問題而不能正常發(fā)布,具體原因還沒有完全弄清楚,但是如果以解開后的文件夾目錄的方式發(fā)布則沒有問題。

    posted @ 2011-02-09 16:16 雪地孤鴻 閱讀(3264) | 評論 (2)編輯 收藏
    測試環(huán)境下使用的是mysql數(shù)據(jù)庫,切換到正式的oralce數(shù)據(jù)庫中去發(fā)現(xiàn)cas server是無效的,主要的原因是由于數(shù)據(jù)庫的差異導(dǎo)致的
    認(rèn)證用戶的sql語句在mysql下為
    select password from user_login where username=? and enabled=true
    而在oracle下應(yīng)該為
    select password from user_login where username=? and enabled=1
    主要由于oralce和mysql對boolean字段的處理不一致導(dǎo)致的。

    posted @ 2011-01-26 09:05 雪地孤鴻 閱讀(719) | 評論 (0)編輯 收藏

    cas server logout后,默認(rèn)是停留在cas的退出頁面,一般我們需要重新轉(zhuǎn)向到客戶端網(wǎng)站的登錄或是相關(guān)的頁面,一般需要進行一下配置

    1.cas-server端,配置文件為/WEB-INFO/cas-servlet.xml中的logoutController

     <bean id="logoutController" class="org.jasig.cas.web.LogoutController" 
         p:centralAuthenticationService-ref="centralAuthenticationService" 
         p:logoutView="casLogoutView" 
         p:warnCookieGenerator-ref="warnCookieGenerator" 
         p:ticketGrantingTicketCookieGenerator-ref="ticketGrantingTicketCookieGenerator"   
          p:followServiceRedirects="true"/>

    posted @ 2011-01-21 13:38 雪地孤鴻 閱讀(1068) | 評論 (1)編輯 收藏

    經(jīng)過將近兩天的測試,參考眾多網(wǎng)友的貢獻,終于完成了對cas的主要配置和測試,現(xiàn)記錄如下

    基本需求:

    1.cas server-3.4.5,casclient-3.2(官方版本),均可在cas官方網(wǎng)站下載,http://www.jasig.org

    2.使用低成本的http協(xié)議進行傳輸,俺買不起ssl證書

    3.通過jdbc進行用戶驗證

    4.需要通過casserver提供除登錄用戶名以外的附加信息

    參考資料:

    1.cas官方網(wǎng)站的用戶幫助手冊和wiki

    2.網(wǎng)友“城市獵人”的blog,http://yuzhwe.javaeye.com/blog/830143

    3.網(wǎng)友“悟空悟道”的blog,http://llhdf.javaeye.com/blog/764385

    4.其他網(wǎng)友貢獻的相關(guān)的blog,都是通過google出來,就不一一列出了,一并致謝!!!

    好了,下面進入正題,如果您不想測試中出現(xiàn)異常情況,或是獲取不到相關(guān)數(shù)據(jù),請關(guān)注文中的紅色字體部分。

    (1)使用http協(xié)議的設(shè)置,如果您也像我一樣,買不起ssl數(shù)字證書,對安全的要求也不是特別的搞,下面的配置就可以幫助解決這個問題:

    在cas-server-webapp中的/WEB-INF/spring-configuration/ticketGrantingTicketCookieGenerator.xml文件中有如下配置

    <bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
      p:cookieSecure="true"     //默認(rèn)為true,使用https,如果只需要http,修改為false即可
      p:cookieMaxAge="-1"
      p:cookieName="CASTGC"
      p:cookiePath="/cas" />

     (2)使用jdbc數(shù)據(jù)源進行用戶認(rèn)證,需要修改cas的authenticationHandlers方式,在文件/WEB-INF/deployerConfigContext.xml有如下配置:

    <property name="authenticationHandlers">
       <list>
        <!--
         | This is the authentication handler that authenticates services by means of callback via SSL, thereby validating
         | a server side SSL certificate.
         +-->
        <bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
         p:httpClient-ref="httpClient" />
        <!--
         | This is the authentication handler declaration that every CAS deployer will need to change before deploying CAS
         | into production.  The default SimpleTestUsernamePasswordAuthenticationHandler authenticates UsernamePasswordCredentials
         | where the username equals the password.  You will need to replace this with an AuthenticationHandler that implements your
         | local authentication strategy.  You might accomplish this by coding a new such handler and declaring
         | edu.someschool.its.cas.MySpecialHandler here, or you might use one of the handlers provided in the adaptors modules.
         +-->
        <!--<bean class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler" />-->
         <bean  class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler">
             <property name="dataSource" ref="dataSource" />
            
    <property name="sql" value="select password from userInfo where username=? and enabled=true" />
             //用戶密碼編碼方式

             <property name="passwordEncoder"
               ref="passwordEncoderBean"/>
             </bean>  
       </list>
      </property>

    該屬性中的list只要用一個認(rèn)證通過即可,建議將紅色部分放在第一位,如果確認(rèn)只用jdbc一種方式,其他認(rèn)證方式均可刪除。另外需要在在文件中添加datasoure和passordEncoder兩個bean,如下

    <!-- Data source definition -->
     <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName">
        <value>com.mysql.jdbc.Driver</value>
      </property>
      <property name="url">
        <value>jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=utf-8</value>    //如果使用mysql數(shù)據(jù)庫,應(yīng)該加上后面的編碼參數(shù),否則可能導(dǎo)致客戶端對TGT票據(jù)無法識別的問題
      </property>
      <property name="username"><value>root</value></property>
      <property name="password"><value>password</value></property>
     </bean>
     <bean id="passwordEncoderBean" class="org.jasig.cas.authentication.handler.DefaultPasswordEncoder">
            <constructor-arg value="SHA1" />  //cas
    server默認(rèn)支持MD5和SHA1兩種編碼方式,如果需要其他的編碼方式例如SHA256,512等,可自行實現(xiàn)org.jasig.cas.authentication.handler.PasswordEncoder接口
        </bean>

    附加備注:如果您是使用cas server的源碼自行編譯的話,需要在cas-server-web模塊的pom.xml中添加如下模塊的依賴:

    <dependency>
           <groupId>${project.groupId}</groupId>
           <artifactId>cas-server-support-jdbc</artifactId>
           <version>${project.version}</version>
      </dependency>  

    并添加對應(yīng)數(shù)據(jù)庫的jdbc的jar包。

    (3)讓cas server提供更多的用戶數(shù)據(jù)共客戶端使用

    通過測試,由于cas的代碼更新過程中的變化較大,所以包兼容的問題好像一直存在,在測試中我就碰到過,花費時間比較多,建議同學(xué)們在使用過程中使用官方的最新的發(fā)布版本。在我使用的這個版本中,請參考前面的關(guān)于server和client端的版本說明,應(yīng)該沒有包沖突的問題,測試通過。下面進行配置,配置文件:/WEB-INF/deployerConfigContext.xml
    <property name="credentialsToPrincipalResolvers">
       <list>
           <!--<bean class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver" />-->
        <!-- modify on 2011-01-18,add user info -->
        <bean class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver" >
          <property name="attributeRepository" >   //為認(rèn)證過的用戶的Principal添加屬性
          <ref local="attributeRepository"/>
         </property> 
        </bean>
          <bean
         class="org.jasig.cas.authentication.principal.HttpBasedServiceCredentialsToPrincipalResolver" />
       </list>
      </property>
     修改該文件中默認(rèn)的 attributeRepositorybean配置
    <!-- 在這里配置獲取更多用戶的信息 -->
     <bean id="attributeRepository" class="org.jasig.services.persondir.support.jdbc.SingleRowJdbcPersonAttributeDao">
      <constructor-arg index="0" ref="dataSource" />
      <constructor-arg index="1" value="select id as UId, password_hint as ph from userInfo where username=? and enabled=true" />
      <property name="queryAttributeMapping">
       <map>
       <entry key="username" value="uid"/><!-- 這里必須這么寫,系統(tǒng)會自己匹配,貌似和where語句后面的用戶名字段的拼寫沒有什么關(guān)系 -->
       </map>
      </property>
       <!-- 要獲取的屬性在這里配置 -->
      <property name="resultAttributeMapping">
       <map>
       <entry key="UId" value="userId" /> //key為對應(yīng)的數(shù)據(jù)庫字段名稱,value為提供給客戶端獲取的屬性名字,系統(tǒng)會自動填充值
       <entry key="ph" value="passwordHint" />   
       </map>
      </property>
    </bean> 
    備注:網(wǎng)上有很多的關(guān)于這個的配置,但是如果您使用的是我提供的版本或是高于這個版本,就應(yīng)該象上面這樣配置,無用質(zhì)疑,網(wǎng)上大部分的配置都是基于
    person-directory-impl,person-directory-api
    1.1左右的版本,而最新的cas使用的是1.5的版本,經(jīng)過查看源代碼和api docs確定最新版本的屬性參數(shù)如上配置。

    修改該xml文件中最后一個默認(rèn)的serviceRegistryDao bean中的屬性全部注釋掉,或者刪除,
    這個bean中的RegisteredServiceImpl的ignoreAttributes屬性將決定是否添加attributes屬性內(nèi)容,默認(rèn)為false:不添加,只有去掉這個配置,
    cas server才會將獲取的用戶的附加屬性添加到認(rèn)證用的Principal的attributes中去,我在這里犯過這樣的錯誤,最后還是通過跟蹤源碼才發(fā)現(xiàn)的。
    <bean
      id="serviceRegistryDao"
            class="org.jasig.cas.services.InMemoryServiceRegistryDaoImpl">
            <!--
                <property name="registeredServices">
                    <list>
                        <bean class="org.jasig.cas.services.RegisteredServiceImpl">
                            <property name="id" value="0" />
                            <property name="name" value="HTTP" />
                            <property name="description" value="Only Allows HTTP Urls" />
                            <property name="serviceId" value="http://**" />
                        </bean>

                        <bean class="org.jasig.cas.services.RegisteredServiceImpl">
                            <property name="id" value="1" />
                            <property name="name" value="HTTPS" />
                            <property name="description" value="Only Allows HTTPS Urls" />
                            <property name="serviceId" value="https://**" />
                        </bean>

                        <bean class="org.jasig.cas.services.RegisteredServiceImpl">
                            <property name="id" value="2" />
                            <property name="name" value="IMAPS" />
                            <property name="description" value="Only Allows HTTPS Urls" />
                            <property name="serviceId" value="imaps://**" />
                        </bean>

                        <bean class="org.jasig.cas.services.RegisteredServiceImpl">
                            <property name="id" value="3" />
                            <property name="name" value="IMAP" />
                            <property name="description" value="Only Allows IMAP Urls" />
                            <property name="serviceId" value="imap://**" />
                        </bean>
                    </list>
                </property>-->
               </bean>

     修改WEB-INF\view\jsp\protocol\2.0\casServiceValidationSuccess.jsp文件,如下:

    <%@ page session="false"%>
    <%@ taglib prefix="c" uri=">
    <%@ taglib uri="
    <cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
     <cas:authenticationSuccess>
      <cas:user>${fn:escapeXml(assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.id)}</cas:user>
      <c:if test="${not empty pgtIou}">
       <cas:proxyGrantingTicket>${pgtIou}</cas:proxyGrantingTicket>
      </c:if>
      <c:if test="${fn:length(assertion.chainedAuthentications) > 1}">
       <cas:proxies>
        <c:forEach var="proxy" items="${assertion.chainedAuthentications}"
         varStatus="loopStatus" begin="0"
         end="${fn:length(assertion.chainedAuthentications)-2}" step="1">
         <cas:proxy>${fn:escapeXml(proxy.principal.id)}</cas:proxy>
        </c:forEach>
       </cas:proxies>
      </c:if>
       <c:if
       test="${fn:length(assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.attributes)

    >
    0}">
       <cas:attributes>
        <c:forEach
    var="attr"
         items="${assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.attributes}"
         varStatus="loopStatus"
    begin="0"
         end="${fn:length(assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.attributes)-1}"
         step="1">
         <cas:${fn:escapeXml(attr.key)}>${fn:escapeXml(attr.value)}</cas:${fn:escapeXml(attr.key)}>
        </c:forEach>
       </cas:attributes>
      </c:if>
     </cas:authenticationSuccess>
    </cas:serviceResponse>
    客戶端配置:
    1.過濾器CAS Validation Filter:
    <filter>
      <filter-name>CAS Validation Filter</filter-name>
      <filter-class> org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class>
      <init-param>
        <param-name>casServerUrlPrefix</param-name>
        <param-value>http://domainserver:8081/cas</param-value>
      </init-param>
    </filter>
    在客戶端獲取信息
    AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
    String loginName = principal.getName();//獲取用戶名
    Map<String, Object> attributes = principal.getAttributes();
    if(attributes != null) {
     System.out.println(attributes.get("userId"));
     System.out.println(attributes.get("passwordHint"));
    }

     


     

    posted @ 2011-01-21 10:06 雪地孤鴻 閱讀(15892) | 評論 (9)編輯 收藏
    最近在使用G2G做項目,開發(fā)環(huán)境的數(shù)據(jù)庫為Mysql,在使用grails的分頁組件時沒有任何問題,但是將數(shù)據(jù)庫切換到ORACLE上就出現(xiàn)了問題,在分頁的時候,記錄總數(shù)是對了的,但在進行翻頁的時候,總會有前一頁的數(shù)據(jù)存在,而當(dāng)前的數(shù)據(jù)總是顯示不對,經(jīng)過將近一天的仔細(xì)排查才找到問題的關(guān)鍵,主要是由于數(shù)據(jù)庫的差異引起的,由于的我的查詢不需要進行排序,所以在原來的查詢結(jié)果中沒有就排序語句,這就導(dǎo)致在mysql中完全正常的功能,到了oralce中每次查詢的排序不一致,結(jié)果就導(dǎo)致在翻頁的時候總有前一頁的數(shù)據(jù)存在,可能是由于數(shù)據(jù)庫的引擎規(guī)則的不一致導(dǎo)致的。
    再次記下!

    posted @ 2010-12-13 11:15 雪地孤鴻 閱讀(722) | 評論 (0)編輯 收藏
       今天早上出來給老婆大人買早點,騎著老婆大人的小車,在路上奔馳,突然一種思緒飛入腦中,想想自己也是三十多歲的人了,卻是一事無成。我本IT出生,參加工作以來,卻一直徘徊在IT技術(shù)的和行業(yè)解決方案之間搖擺,最后終于下定決心朝著行業(yè)解決方案的方向發(fā)展,卻選擇了一個旅游行業(yè),雖說春秋在國內(nèi)也算的上不錯的旅游公司,但這個行業(yè)確實亂象叢生。該公司在信息化方面更是不知所謂,早三暮四。雖然我不應(yīng)該對公司說三道四,但還是忍不住要說兩句。算了,這個都是我個人的抉擇,我現(xiàn)在是IT技術(shù)方面沒有什么看家的本事,行業(yè)知識也沒有什么,長此以往,很是危險,隨著年齡的增長,抗風(fēng)險能力會越來月差,我必須要重新的思考和抉擇,不然真的要落的老婆大人預(yù)見的場景了,我自己不甘心這樣,也 不能讓老婆看扁啊。行業(yè)的解決方案肯定是我的房展方向,是繼續(xù)在這個行業(yè)發(fā)展,還是重新挑選行業(yè),這是個比較重要的決定,但是不管怎么樣,我的老本行--IT技術(shù)也支撐不了幾年了,我必須要反省,深思我過去的規(guī)劃和執(zhí)行,重新規(guī)劃和執(zhí)行,努力的保障家庭幸福的經(jīng)濟基礎(chǔ),開拓新的事業(yè)。
    今天在這里寫下如此的只言片語,就是為了鞭策自己,不能讓自己在被短期的利益而動搖長期的規(guī)劃和執(zhí)行,年紀(jì)也不小了,還沒有一個像樣的事業(yè),以后的風(fēng)險會越來越大。
    posted @ 2010-05-03 10:35 雪地孤鴻| 編輯 收藏
    最近在試用Grails進行開發(fā)一個小項目,需要使用oracle數(shù)據(jù)庫,我使用的是Oracle 11g,簡單的配置如下:
    1.添加jdbc lib到Grails項目的lib中,我使用的是ojdcb6_g.jar
    2.修改grails生成項目的DataSource.groovy文件中關(guān)于DataSource的相關(guān)配置:關(guān)鍵點是關(guān)于hibernate方言的配置,由于grails默認(rèn)使用的是HSQL內(nèi)存數(shù)據(jù)庫,推薦使用的是mysql數(shù)據(jù)庫;但是在使用oracle數(shù)據(jù)庫時,需要配置hiernate的方言;其他的如URL,drive,username,password等配置和一般的配置沒有什么區(qū)別,詳細(xì)配置如下:
    dataSource {
        pooled = true
        driverClassName = "oracle.jdbc.OracleDriver"
        username = "paygateway"
        password = "paygateway"
        dialect = "org.hibernate.dialect.OracleDialect"
           
        logSql = true
    }


    posted @ 2010-03-19 13:38 雪地孤鴻 閱讀(2008) | 評論 (1)編輯 收藏
    <2010年3月>
    28123456
    78910111213
    14151617181920
    21222324252627
    28293031123
    45678910

    常用鏈接

    留言簿(17)

    隨筆分類

    隨筆檔案

    文章檔案

    blog

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 国产精品亚洲专区在线播放| 日韩版码免费福利视频| 亚洲免费观看网站| 国产亚洲精久久久久久无码77777| 无码国产精品一区二区免费式直播 | 免费人成在线观看网站品爱网日本| 色欲国产麻豆一精品一AV一免费| 一个人免费观看日本www视频| 亚洲粉嫩美白在线| 久久亚洲精品无码aⅴ大香| 亚洲色精品88色婷婷七月丁香 | 国产午夜亚洲精品不卡电影| 亚洲免费视频播放| 亚洲精品偷拍无码不卡av| 国产亚洲精品xxx| 亚洲午夜福利精品久久| 国产又大又黑又粗免费视频| 皇色在线视频免费网站| 亚洲高清免费在线观看| 一级毛片免费观看不卡的| A片在线免费观看| 精品97国产免费人成视频 | 又粗又大又长又爽免费视频| 毛片a级毛片免费播放下载| 日日麻批免费40分钟日本的| 免费无码VA一区二区三区| 最近2019中文免费字幕在线观看 | 亚洲日韩在线观看免费视频| 免费看国产一级特黄aa大片| 成人免费视频国产| 永久免费AV无码网站在线观看| 免费人成视频在线| 国内外成人免费视频| 色吊丝最新永久免费观看网站 | 久久亚洲精品无码aⅴ大香 | 曰批全过程免费视频网址| 亚洲黄色免费观看| 国产v精品成人免费视频400条| 美女被免费喷白浆视频| 久久综合AV免费观看| 大香人蕉免费视频75|