锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲香蕉免费有线视频,亚洲AV无码资源在线观看,亚洲精品无码乱码成人http://m.tkk7.com/mashiguang/archive/2009/12/07/304958.htmlmashiguangmashiguangMon, 07 Dec 2009 01:50:00 GMThttp://m.tkk7.com/mashiguang/archive/2009/12/07/304958.htmlhttp://m.tkk7.com/mashiguang/comments/304958.htmlhttp://m.tkk7.com/mashiguang/archive/2009/12/07/304958.html#Feedback4http://m.tkk7.com/mashiguang/comments/commentRss/304958.htmlhttp://m.tkk7.com/mashiguang/services/trackbacks/304958.html浣跨敤cas鍋?/span>sso helloword

鍥犱負宸ヤ綔闇瑕佹帴瑙﹀埌sso錛屾嵁鐭ョ洰鍓嶅鏁?/span>sso浣跨敤鑰墮瞾鐨?/span>cas瀹炵幇錛屼笖鍙戠幇浣跨敤cas鐪熺殑鏄緢綆鍗曞氨鍙互鍋氬嚭涓涓崟鐐圭櫥褰曠郴緇熸潵錛?/span>cas榪樻彁渚涗赴瀵岀殑鎵╁睍鍔熻兘錛屽浜庢墿灞曞姛鑳芥棩鍚庡啀緇嗙粏鐮旂┒錛岃繖閲屽彧浣跨敤cas鍋氫竴涓?/span>hello world鏉ヨ褰曟湰浜虹殑瀛︿範榪囩▼錛屽鏈夊垢琚珮浜虹湅鍒幫紝榪樻湜鎸囧嚭寮婄梾錛屼笉鍚濊祼鏁欍?/span>

鍦ㄤ嬌鐢?/span>cas涔嬪墠鏈濂藉鏁板瓧璇佷功鏈夋墍浜嗚В錛屼笉浜嗚В涔熸病鏈夊叧緋伙紝璺熺潃鎴戠殑姝ラ涔熶竴鏍峰彲浠ヨ窇鐨勯氥?/span>

鍑嗗宸ヤ綔

闇瑕佺殑鏂囦歡錛?/span>

ü         Jdk6

ü         Tomcat

ü         cas-server-3.3.2

ü         cas-client-3.1.9

璇佷功

涓嬮潰鏄?/span>keytool鍛戒護鐨勪竴浜涘父鐢ㄦ柟娉曪紝鍏堝湪榪欓噷璁よ瘑涓涓嬪畠浠紝涓浼氬効浼氱敤鐨勫埌銆?/span>

浣跨敤keytool鍛戒護鐢熸垚瀵嗛挜搴?/span>

keytool -genkey -alias tomcat -keyalg RSA -dname "CN=pcma, OU=vanceinfo, O=vanceinfo, L=haidian, S=beijing, C=CN" -keystore c:"keystore5.jks

CN錛氫富鏈哄悕

OU錛氱粍緇囧崟浣?/span>

O錛氱粍緇?/span>

L錛氬湴鍖?/span>

S錛氬煄甯?/span>

C錛氬浗瀹?br />
濡傛灉闇瑕佹寚瀹氬瘑閽ユ湁鏁堟湡錛屾坊鍔?validity 365鍗沖彲錛屽崟浣嶆槸澶╋紝濡傦細
keytool -genkey -alias tomcat -keyalg RSA -dname "xxxxx" -keystore xxxxx -validity 365

瀵煎嚭璇佷功

keytool -export -file c:/server5.crt -alias tomcat -keystore c:"keystore5.jks

灝嗚瘉涔﹀鍏ュ埌瀹㈡埛绔?/span>jdk

keytool -import -keystore "D:"Java"jdk1.6.0_14"jre"lib"security"cacerts" -file c:/server5.crt -alias tomcat

浠庡瘑閽ュ簱涓垹闄ゆ寚瀹氬埆鍚嶇殑璇佷功

keytool -delete -noprompt -alias tomcat -keystore E:"apache-tomcat-6.0.20_2"conf"keystore2.jks

鏌ョ湅瀵嗛挜搴撲腑鐨勮瘉涔?/span>

keytool -list -v -keystore c:"keystore5.jks

閰嶇疆tomcat

浣跨敤keytool鍛戒護鐢熸垚瀵嗛挜搴撱?/span>

閰嶇疆%tomcat_home%/conf/server.xml浣?/span>tomcat鏀寔SSL鍗忚錛屽茍鎸囧畾瀵嗛挜搴撱?/span>

<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"

               maxThreads="150" scheme="https" secure="true"

               clientAuth="false" sslProtocol="TLS" keystorePass="mashiguang"

                        keystoreFile="${catalina.home}/conf/keystore5.jks"/>

閮ㄧ講cas server

瑙e帇緙?/span>cas-server-3.3.2-release.zip鏂囦歡錛屽湪modules鐩綍閲屾壘鍒?/span>cas-server-webapp-3.3.2.war鏂囦歡錛岃繖灝辨槸涓涓仛濂戒簡鐨?/span>cas鏈嶅姟绔紝鎴戜滑鍋氱殑sso helloword鍙互鐩存帴浣跨敤錛屽彧闇鎶?/span>cas-server-webapp-3.3.2.war鏀逛簡涓畝鍗曠偣鐨勫悕瀛楋紝濡?/span>cas.war錛岀劧鍚庨儴緗插埌tomcat鍗沖彲銆?/span>

嫻忚鍣ㄨ闂?/span>https://pcma:8443/cas錛屽鏋滄墦寮鏄劇ず鐨勬槸cas榛樿鐨勭櫥褰曢〉闈紝鍒欒〃紺烘湇鍔$宸查儴緗插畬姣曘?/span>

瀹㈡埛绔嬌鐢?/span>cas client

鏂板緩涓や釜web宸ョ▼錛岀敤浜庢ā鎷熷崟鐐圭櫥褰曠郴緇熶腑鐨勫鎴風錛屽茍灝?/span>cas-client-3.1.9"modules閲岀殑jar鍖呮斁鍒?/span>web宸ョ▼lib鐩綍涓嬶紝鏄富瑕佺殑鏄?/span>cas-client-core-3.1.9.jar鏂囦歡錛屾妸spring2.5涔熸斁鍒?/span>lib鐩綍涓嬨?/span>

Web.xml鏂囦歡

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.4"

       xmlns="http://java.sun.com/xml/ns/j2ee"

       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

       xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee

       http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

       <context-param> 

        <param-name>contextConfigLocation</param-name> 

        <param-value> 

            /WEB-INF/config/casContext.xml  

        </param-value> 

    </context-param> 

    <listener> 

        <listener-class> 

            org.springframework.web.context.ContextLoaderListener  

        </listener-class> 

    </listener> 

    <!-- 璐熻矗鐢ㄦ埛璁よ瘉 --> 

    <filter> 

        <filter-name>CAS Authentication Filter</filter-name> 

        <filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class> 

        <!-- CAS login 鏈嶅姟鍦板潃--> 

        <init-param> 

            <param-name>casServerLoginUrl</param-name> 

            <param-value>https://pcma:8443/cas/login</param-value> 

        </init-param> 

        <init-param> 

            <param-name>renew</param-name> 

            <param-value>false</param-value> 

        </init-param> 

        <init-param> 

            <param-name>gateway</param-name> 

            <param-value>false</param-value> 

        </init-param> 

        <!-- 瀹㈡埛绔簲鐢ㄦ湇鍔″湴鍧--> 

        <init-param> 

            <param-name>serverName</param-name> 

            <param-value>http://pcma:8081</param-value> 

        </init-param> 

    </filter> 

    <!--璐熻矗Ticket鏍¢獙--> 

    <filter> 

        <filter-name>CAS Validation Filter</filter-name> 

        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 

        <init-param> 

            <param-name>targetBeanName</param-name> 

            <param-value>cas.validationfilter</param-value> 

        </init-param> 

    </filter> 

    <filter-mapping> 

        <filter-name>CAS Authentication Filter</filter-name> 

        <url-pattern>/*</url-pattern> 

    </filter-mapping> 

    <filter-mapping> 

        <filter-name>CAS Validation Filter</filter-name> 

        <url-pattern>/*</url-pattern> 

    </filter-mapping> 

</web-app>

casContext.xml鏂囦歡

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"

              "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

<bean id="cas.validationfilter" class="org.jasig.cas.client.validation.Cas10TicketValidationFilter"> 

        <property name="ticketValidator"> 

            <ref bean="cas10TicketValidator"/> 

        </property> 

        <property name="useSession"> 

            <value>true</value> 

        </property> 

        <!-- 瀹㈡埛绔簲鐢ㄦ湇鍔″湴鍧--> 

        <property name="serverName"> 

            <value>http://pcma:8081</value> 

        </property> 

        <property name="redirectAfterValidation"> 

            <value>true</value> 

        </property> 

    </bean> 

    <bean id="cas10TicketValidator" class="org.jasig.cas.client.validation.Cas10TicketValidator"> 

    <!-- 榪欓噷鍙傛暟鏄?/span>cas鏈嶅姟鍣ㄧ殑鍦板潃--> 

        <constructor-arg index="0" value="https://pcma:8443/cas" /> 

    </bean> 

</beans> 

鏂板緩index.jsp鏂囦歡

 <body>

   hello sso<br>

   <a >sso2</a>榪欎釜鍦板潃鏄彟澶栦竴鍙版満鍣ㄤ笂鐨?/span>sso瀹㈡埛绔?/span>

 </body>

涓婇潰鐨?/span>web.xml銆?/span>casContext.xml銆?/span>index.jsp鏄袱涓鎴風涓殑涓涓紝鍙︿竴涓鏍規嵁瀹為檯鎯呭喌淇敼銆?/span>

鏈鍚庝笉瑕佸繕璁板鎴風鐨?/span>jdk瑕佷嬌鐢?/span>keytool鍛戒護瀵煎叆璇佷功鏂囦歡銆?/span>

嫻嬭瘯

鍚姩tomcat錛屾祴璇曞櫒璁塊棶http://pcma:8081/sso錛屽嚭鐜?/span>cas鐧誨綍欏甸潰錛岃緭鍏ョ浉鍚岀殑鐢ㄦ埛鍚嶅拰瀵嗙爜鍗沖彲鐧誨綍錛岀櫥褰曟垚鍔熷悗欏甸潰鑷姩璺寵漿鍥?/span>http://pcma:8081/sso錛岃繖鏃剁偣鍑婚〉闈笂鐨?/span>sso2閾炬帴錛屽氨鍙互鑷姩鐧誨綍騫惰煩杞埌sso2搴旂敤銆?/span>

濡傛灉杈撳叆鐢ㄦ埛鍚嶅瘑鐮佸悗鎻愮ず涓嬮潰鐨勫紓甯革紝鏄洜涓洪儴緗插鎴風鐨?/span>jdk娌℃湁瀵煎叆璇佷功鏂囦歡鐨勫師鍥犮?/span>

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target


婧愮爜

http://m.tkk7.com/Files/mashiguang/sso.zip



mashiguang 2009-12-07 09:50 鍙戣〃璇勮
]]>
jndi璋冪敤鏃?鍚勭搴旂敤鏈嶅姟鍣↖nitialContext鐨勫啓娉?/title><link>http://m.tkk7.com/mashiguang/archive/2008/07/14/214758.html</link><dc:creator>mashiguang</dc:creator><author>mashiguang</author><pubDate>Mon, 14 Jul 2008 08:35:00 GMT</pubDate><guid>http://m.tkk7.com/mashiguang/archive/2008/07/14/214758.html</guid><wfw:comment>http://m.tkk7.com/mashiguang/comments/214758.html</wfw:comment><comments>http://m.tkk7.com/mashiguang/archive/2008/07/14/214758.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://m.tkk7.com/mashiguang/comments/commentRss/214758.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/mashiguang/services/trackbacks/214758.html</trackback:ping><description><![CDATA[<p><br /> 璋冪敤ejb鏃?濡傛灉瀹㈡埛绔拰ejb涓嶅湪鍚屼竴涓猨vm,灝辮璁劇疆InitialContext,涓嶅悓鐨勫簲鐢ㄦ湇鍔″櫒InitialContext鍐欐硶涔熶笉鍚?<br /> Context.INITIAL_CONTEXT_FACTORY:鎸囧畾鍒扮洰褰曟湇鍔$殑榪炴帴宸ュ巶<br /> Context.PROVIDER_URL:鐩綍鏈嶅姟鎻愪緵鑰匲RL</p> <p>//jboss:<br /> Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"<br /> Context.URL_PKG_PREFIXES, "org.jboss.naming"<br /> Context.PROVIDER_URL, "localhost:1099"</p> <p>//weblogic:<br /> Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"<br /> Context.PROVIDER_URL, "t3://localhost:7001"</p> <p>//apusic(閲戣澏):<br /> Context.INITIAL_CONTEXT_FACTORY, "com.apusic.jndi.InitialContextFactory"<br /> Context.PROVIDER_URL, "rmi://localhost:6888"</p> <p>//WebSphere:<br /> Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory"<br /> Context.PROVIDER_URL, "iiop://localhost:900"</p> <p><br /> //J2EE  SDK(J2EE  RI):<br /> Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory"<br /> Context.PROVIDER_URL, "iiop://127.0.0.1:1050"</p> <p>//SilverStream:<br /> Context.INITIAL_CONTEXT_FACTORY, "com.sssw.rt.jndi.AgInitCtxFactory"<br /> Context.PROVIDER_URL, "sssw://localhost:80"</p> <p>//OC4J:<br /> Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory"<br /> Context.PROVIDER_URL, "ormi://127.0.0.1/"</p> <p>//WAS5:<br /> Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory"<br /> Context.PROVIDER_URL, "iiop://localhost:2809"</p> <p> </p> <p>甯哥敤JNDI鏈嶅姟鎻愪緵鑰呰繛鎺ュ伐鍘?<br /> Filesystem:  Com.sun.jndi.fscontext.FSContextFactory鎴栬卌om.sun.jndi.fscontext.RefFSContextFactory<br /> LDAPv3:    Com.sun.jndi.ldap.LdapCtxFactory<br /> NDS:     com.novell.naming.service.nds.NdsInitialContextFactory<br /> NIS:     com.sun.jndi.nis.NISCtxFactory<br /> RMI registry: com.sun.jndi.rmi.registry.RegistryContextFactory<br /> IBM LDAP鏈嶅姟鎻愪緵鑰?   com.ibm.jndi.LDAPCtxFactory<br /> BEA 鍚嶅瓧鏈嶅姟鎻愪緵鑰?   weblogic.jndi.WLInitialContextFactory<br /> JBOSS鍚嶅瓧鏈嶅姟鎻愪緵鑰?  org.jnp.interfaces.NamingContextFactory</p> <img src ="http://m.tkk7.com/mashiguang/aggbug/214758.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/mashiguang/" target="_blank">mashiguang</a> 2008-07-14 16:35 <a href="http://m.tkk7.com/mashiguang/archive/2008/07/14/214758.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>java鑷姩鎵撳寘鐨勫樊寮?/title><link>http://m.tkk7.com/mashiguang/archive/2007/12/13/167549.html</link><dc:creator>mashiguang</dc:creator><author>mashiguang</author><pubDate>Thu, 13 Dec 2007 09:03:00 GMT</pubDate><guid>http://m.tkk7.com/mashiguang/archive/2007/12/13/167549.html</guid><wfw:comment>http://m.tkk7.com/mashiguang/comments/167549.html</wfw:comment><comments>http://m.tkk7.com/mashiguang/archive/2007/12/13/167549.html#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://m.tkk7.com/mashiguang/comments/commentRss/167549.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/mashiguang/services/trackbacks/167549.html</trackback:ping><description><![CDATA[鑷狫DK1.0寮濮嬪氨瀛樺湪鍖呰鍣ㄧ被,浣嗘槸鍦↗DK5.0涔嬪墠,蹇呴』鎵嬪伐鍦版彃鍏ユ墦鍖呭拰鎷嗗寘鐨勪唬鐮?<br /> JDK5.0涓氨鏈変簡鑷姩鎵撳寘鍔熻兘,浣嗗湪5.0涓嚜鍔ㄦ墦鍖呮椂瀛樺湪涓浜涘樊寮?鍒氭墠鐪嬨妀ava鏍稿績鎶鏈7鐗堛嬫椂鎵嶅彂鐜?<br /> <br /> <span style="color: #ff0000">浠g爜1:<br /> </span> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img alt="" src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><span style="color: #000000">Integer a</span><span style="color: #000000">=</span><span style="color: #000000">1000</span><span style="color: #000000">;<br /> <img alt="" src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />Integer b</span><span style="color: #000000">=</span><span style="color: #000000">1000</span><span style="color: #000000">;<br /> <img alt="" src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />System.out.println(a</span><span style="color: #000000">==</span><span style="color: #000000">b);</span><span style="color: #008000">//</span><span style="color: #008000">false</span></div> <span style="color: #ff0000">浠g爜2:</span><br /> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img alt="" src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><span style="color: #000000">Integer a</span><span style="color: #000000">=</span><span style="color: #000000">100</span><span style="color: #000000">;<br /> <img alt="" src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />Integer b</span><span style="color: #000000">=</span><span style="color: #000000">100</span><span style="color: #000000">;<br /> <img alt="" src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />System.out.println(a</span><span style="color: #000000">==</span><span style="color: #000000">b);</span><span style="color: #008000">//</span><span style="color: #008000">true</span></div> <span style="color: #ff0000">浠g爜3:</span><br /> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img alt="" src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><span style="color: #000000">Integer a</span><span style="color: #000000">=</span><span style="color: #0000ff">new</span><span style="color: #000000"> Integer(</span><span style="color: #000000">100</span><span style="color: #000000">);<br /> <img alt="" src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />Integer b</span><span style="color: #000000">=</span><span style="color: #0000ff">new</span><span style="color: #000000"> Integer(</span><span style="color: #000000">100</span><span style="color: #000000">);<br /> <img alt="" src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />System.out.println(a</span><span style="color: #000000">==</span><span style="color: #000000">b);</span><span style="color: #008000">//</span><span style="color: #008000">false</span></div> <br /> <p>絎竴孌典唬鐮佷笉鎴愮珛,鑰岀浜屾浠g爜鎴愮珛鐨勫師鍥犳槸:鑷姩鎵撳寘<br /> <span style="color: #ff0000">鑷姩鎵撳寘瑙勮寖瑕佹眰boolean,byte,char≤127,浠嬩簬-128→127涔嬮棿鐨剆hort鍜宨nt琚寘瑁呭埌鍥哄畾鐨勫璞′腑.</span><br /> 鎵撳寘鍜屾媶鍖呮槸緙栬瘧鍣ㄨ鍙殑錛岃屼笉鏄櫄鎷熸満錛岀紪璇戝櫒鍦ㄧ敓鎴愮被鐨勫瓧鑺傜爜鏃訛紝鎻掑叆蹇呰鐨勬柟娉曡皟鐢紝铏氭嫙鏈哄彧鏄墽琛岃繖浜涘瓧鑺傜爜銆?/p> <p>絎笁孌典唬鐮佷笉鐢ㄥ璇磋偗瀹氫笉鎴愮珛.</p> <p> </p> <img src ="http://m.tkk7.com/mashiguang/aggbug/167549.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/mashiguang/" target="_blank">mashiguang</a> 2007-12-13 17:03 <a href="http://m.tkk7.com/mashiguang/archive/2007/12/13/167549.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>ant鎵揺ar鍖呯殑璇︾粏姝ラhttp://m.tkk7.com/mashiguang/archive/2007/11/24/162758.htmlmashiguangmashiguangFri, 23 Nov 2007 16:44:00 GMThttp://m.tkk7.com/mashiguang/archive/2007/11/24/162758.htmlhttp://m.tkk7.com/mashiguang/comments/162758.htmlhttp://m.tkk7.com/mashiguang/archive/2007/11/24/162758.html#Feedback1http://m.tkk7.com/mashiguang/comments/commentRss/162758.htmlhttp://m.tkk7.com/mashiguang/services/trackbacks/162758.html闃呰鍏ㄦ枃

mashiguang 2007-11-24 00:44 鍙戣〃璇勮
]]>
apache commons-emailhttp://m.tkk7.com/mashiguang/archive/2007/11/01/157533.htmlmashiguangmashiguangThu, 01 Nov 2007 08:51:00 GMThttp://m.tkk7.com/mashiguang/archive/2007/11/01/157533.htmlhttp://m.tkk7.com/mashiguang/comments/157533.htmlhttp://m.tkk7.com/mashiguang/archive/2007/11/01/157533.html#Feedback3http://m.tkk7.com/mashiguang/comments/commentRss/157533.htmlhttp://m.tkk7.com/mashiguang/services/trackbacks/157533.html浣跨敤commons mail鏃墮渶瑕佺殑jar鍖?
1,commons-email-1.1.jar
2,mail.jar
3,activation.jar
(鍦╳eb搴旂敤閲屽彧闇瑕乧ommons-email鍖?

鍙戦佺畝鍗曠殑鏂囧瓧閭歡:

SimpleEmail email = new SimpleEmail();

email.setHostName(
"smtp.sina.com");
email.setAuthentication(
"username""password");//鍦ㄩ偖浠舵湇鍔″晢澶勬敞鍐岀殑鐢ㄦ埛鍚嶅拰瀵嗙爜
email.addTo("mailTo@163.com");
email.setFrom(
"username@sina.com""alias");

email.setCharset(
"UTF-8");//gbk鎴杇b2312,鍙鏀寔涓枃灝辮
email.setSubject("title");
email.setMsg(
"content");
email.send();

鍙戦佸甫闄勪歡鐨勯偖浠?
// Create the attachment
EmailAttachment attachment = new EmailAttachment();
attachment.setPath(
"mypictures/john.jpg");
attachment.setDisposition(EmailAttachment.ATTACHMENT);
attachment.setDescription(
"Picture of John");
attachment.setName(
"John");

// Create the email message
MultiPartEmail email = new MultiPartEmail();
email.setHostName(
"mail.myserver.com");
email.setAuthentication(
"username""password");
email.addTo(
"jdoe@somewhere.org""John Doe");
email.setFrom(
"me@apache.org""Me");
email.setCharset(
"UTF-8");
email.setSubject(
"The picture");
email.setMsg(
"Here is the picture you wanted");

// add the attachment
email.attach(attachment);

// send the email
email.send();

鍒涘緩澶氫釜EmailAttachment瀵硅薄,騫惰皟鐢∕ultiPartEmail.attach();灝卞彲浠ュ彂閫佸涓檮浠?

鍙戦丠TML鏍煎紡鐨勯偖浠?

鍙戦乭tml鏍煎紡鐨勯偖浠跺拰綆鍗曢偖浠剁殑鍖哄埆灝卞湪鍒涘緩HtmlEmail瀵硅薄
騫剁敤email.setHtmlMsg(String)鎴杄mail.setMsg(String)鎶婂惈鏈塰tml鏍囩鐨勫瓧絎︿覆璧嬬粰email瀵硅薄.
HtmlEmail瀵硅薄榪樻湁涓涓猻etTextMsg(String)鏂規硶,榪欎釜鏂規硶鍙傛暟閲岀殑html鏍囩浼氳褰撳仛鏅氬瓧絎﹀鐞?涓嶄細琚В鏋愭垚html鍏冪礌.
鏇磋緇嗗唴瀹瑰彲浠ョ湅apache commons-email鐨勭敤鎴鋒寚鍗?/a>.



mashiguang 2007-11-01 16:51 鍙戣〃璇勮
]]>
<杞?gt;,闃叉鍒鋒柊/鍚庨寮曡搗鐨勯噸澶嶆彁浜ら棶棰樼殑Java Token浠g爜錛岄潪Strutshttp://m.tkk7.com/mashiguang/archive/2007/08/21/138324.htmlmashiguangmashiguangTue, 21 Aug 2007 03:45:00 GMThttp://m.tkk7.com/mashiguang/archive/2007/08/21/138324.htmlhttp://m.tkk7.com/mashiguang/comments/138324.htmlhttp://m.tkk7.com/mashiguang/archive/2007/08/21/138324.html#Feedback6http://m.tkk7.com/mashiguang/comments/commentRss/138324.htmlhttp://m.tkk7.com/mashiguang/services/trackbacks/138324.html璐村瓙杞嚜http://hi.baidu.com/bobylou錛岃漿涔嬪墠騫舵病鏈夐獙璇佹枃绔犻噷鐨勬柟娉曟槸涓嶆槸鏈夋晥錛屼及璁″師浣滆呮妸瀹冩斁鍒癰log涔嬪墠搴旇鍋氳繃嫻嬭瘯浜嗗惂銆?br>

Struts鏈韓鏈変竴濂楀畬鍠勭殑闃叉閲嶅鎻愪氦琛ㄥ崟鐨?strong>Token(浠ょ墝)鏈哄埗錛屼絾絎旇呯洰鍓嶇殑欏圭洰鑷啓鐨刦ramework娌℃湁鐢ㄥ埌Struts錛屾晠涔熷緱鑷啓闃叉鐢ㄦ埛鍥犱負鍚庨鎴栬呭埛鏂版潵閲嶅鎻愪氦琛ㄥ崟鍐呭鐨凾oken鏈哄埗銆備笉闅撅紝瀹規槗瀹炵幇銆?/p>

瀹炵幇鍘熺悊錛氫竴鑷存с俲sp鐢熸垚琛ㄥ崟鏃訛紝鍦ㄨ〃鍗曚腑鎻掑叆涓涓殣钘?lt;input>瀛楁錛岃瀛楁灝辨槸淇濆瓨鍦ㄩ〉闈㈢鐨則oken瀛楃涓詫紝鍚屾椂鎶婅瀛楃涓插瓨鍏ession涓傜瓑鍒扮敤鎴鋒彁浜よ〃鍗曟椂錛屼細涓騫舵彁浜よ闅愯棌鐨則oken瀛楃涓層傚湪鏈嶅姟鍣ㄧ錛屾煡鐪嬩笅鏄惁鍦╯ession涓惈鏈変笌璇oken瀛楃涓茬浉絳夌殑瀛楃涓層傚鏋滄湁錛岄偅涔堣〃鏄庢槸絎竴嬈℃彁浜よ琛ㄥ崟錛岀劧鍚庡垹闄ゅ瓨鏀句簬session绔殑token瀛楃涓詫紝鍐嶅仛姝e父涓氬姟閫昏緫嫻佺▼錛涘鏋滄病鏈夛紝閭d箞琛ㄧず璇ヨ〃鍗曡閲嶅鎻愪氦錛屽仛闈炴甯告祦紼嬪鐞嗭紝鍙互璀﹀憡鎻愮ず涔熷彲浠ヤ粈涔堜篃涓嶅仛銆?/p>

鐪嬩唬鐮併?/p>

棣栧厛鏄?strong>Token涓葷被銆傜被寰堢畝鍗曪紝鑰屼笖涓昏鏂規硶閮界粰doc娉ㄩ噴浜?/p>

/*
* blog: 
http://hi.baidu.com/bobylou
* $Revision: 1.1 $
* $Date: 2007/07/18 10:02:55 $
* $Author: bobrow$
*/


package com.paizuo.framework.util;

import java.util.ArrayList;

import javax.servlet.http.HttpSession;

public class Token {

    
private static final String TOKEN_LIST_NAME = "tokenList";

    
public static final String TOKEN_STRING_NAME = "token";

    
private static ArrayList getTokenList(HttpSession session) {
       Object obj 
= session.getAttribute(TOKEN_LIST_NAME);
       
if (obj != null{
          
return (ArrayList) obj;
       }
 else {
          ArrayList tokenList 
= new ArrayList();
          session.setAttribute(TOKEN_LIST_NAME, tokenList);
          
return tokenList;
       }

    }


    
private static void saveTokenString(String tokenStr, HttpSession session) {
       ArrayList tokenList 
= getTokenList(session);
       tokenList.add(tokenStr);
       session.setAttribute(TOKEN_LIST_NAME, tokenList);
    }

   
    
private static String generateTokenString(){
       
return new Long(System.currentTimeMillis()).toString();
    }


    
/**
     * Generate a token string, and save the string in session, then return the token string.
     * 
     * 
@param HttpSession
     *            session
     * 
@return a token string used for enforcing a single request for a particular transaction.
     
*/

    
public static String getTokenString(HttpSession session) {
       String tokenStr 
= generateTokenString();
       saveTokenString(tokenStr, session);
       
return tokenStr;
    }


    
/**
     * check whether token string is valid. if session contains the token string, return true. 
     * otherwise, return false.
     * 
     * 
@param String
     *            tokenStr
     * 
@param HttpSession
     *            session
     * 
@return true: session contains tokenStr; false: session is null or tokenStr is id not in session
     
*/

    
public static boolean isTokenStringValid(String tokenStr, HttpSession session) {
       
boolean valid = false;
       
if(session != null){
          ArrayList tokenList 
= getTokenList(session);
          
if (tokenList.contains(tokenStr)) {
             valid 
= true;
             tokenList.remove(tokenStr);
          }

       }

       
return valid;
    }

}



鎬庝箞浣跨敤錛?/font>

鍦╦sp欏甸潰绔?/strong>

棣栧厛import璇ョ被錛?/p>

<%@ page import="com.paizuo.framework.util.Token" %>

琛ㄥ崟鍖呭惈闅愯棌鐨則oken瀛楃涓?

 

<form>

<input type="hidden" name="<%=Token.TOKEN_STRING_NAME %>" value="<%=Token.getTokenString(session) %>">

</form>

 

鍦⊿erver绔痑ction涓繘琛屾楠屻?/strong>

 

if(Token.isTokenStringValid(request.getParameter(Token.TOKEN_STRING_NAME), request.getSession())){
//榪涜姝e父涓氬姟嫻佺▼
}

else{
//榪涜闃查噸澶嶆彁浜ゅ鐞嗘祦紼?/span>
}

瀹屾瘯銆?/p>

]]>
servlet浣跨敤鎶宸?緇欒噧鑲跨殑web.xml鐦﹁韓.http://m.tkk7.com/mashiguang/archive/2007/07/06/128653.htmlmashiguangmashiguangFri, 06 Jul 2007 11:17:00 GMThttp://m.tkk7.com/mashiguang/archive/2007/07/06/128653.htmlhttp://m.tkk7.com/mashiguang/comments/128653.htmlhttp://m.tkk7.com/mashiguang/archive/2007/07/06/128653.html#Feedback5http://m.tkk7.com/mashiguang/comments/commentRss/128653.htmlhttp://m.tkk7.com/mashiguang/services/trackbacks/128653.htmlweb.xml閲屼篃瀵嗗瘑楹婚夯鐨勬帓婊′簡<servlet><servlet-mapping>榪欎簺椋熶箣鏃犲懗寮冧箣宕╂簝鐨勪笢瑗?鏈変竴縐嶆柟娉曞彲浠ユ敼鍠勮繖縐嶅鍐?
      鍦╳eb.xml閲屾坊鍔犲涓嬬殑閰嶇疆:
    <servlet>
        
<servlet-name>InvokerServlet</servlet-name>
        
<servlet-class>
          org.apache.catalina.servlets.InvokerServlet
        
</servlet-class>
        
<init-param>
            
<param-name>debug</param-name>
            
<param-value>0</param-value>
        
</init-param>
        
<load-on-startup>-1</load-on-startup>
    
</servlet>
    
    
<servlet-mapping>
        
<servlet-name>InvokerServlet</servlet-name>
        
<url-pattern>/servlet/*</url-pattern>
    
</servlet-mapping>
      ok,鐜板湪web.xml閲屼繚鐣欒繖涓涓猻ervlet閰嶇疆灝卞彲浠ユ弧瓚蟲墍鏈夌殑servlet璋冪敤浜?姣斿璋冪敤UserManagerService榪欎釜servlet,鍦ㄩ〉闈㈣〃鍗曢噷榪欐牱鍐?
<form name="f" method="post" action="/servlet/com.mashiguang.servlet.UserManagerService">
      
<input/>
      
<submit/>
</form>
      娉ㄦ剰琛ㄥ崟action "/servlet/"鍚庨潰鏄繖涓猻ervlet class鐨勫叏鍚?

]]>
主站蜘蛛池模板: 亚洲人成人无码网www电影首页 | 日韩精品无码免费专区网站| 丁香五月亚洲综合深深爱| 在线观看免费无码视频| 亚洲国产美女视频| 国产成人在线观看免费网站 | 最好2018中文免费视频| 亚洲精品无码精品mV在线观看| 无码人妻一区二区三区免费n鬼沢 无码人妻一区二区三区免费看 | 中文字幕影片免费在线观看| 免费国产高清毛不卡片基地| 亚洲AV无码国产精品麻豆天美 | 亚洲国产AV一区二区三区四区| 亚洲精品国精品久久99热| 中文字幕免费不卡二区| 亚洲日韩精品国产3区| 亚洲精品成人无码中文毛片不卡| 在线视频免费观看爽爽爽| jizz18免费视频| 亚洲资源最新版在线观看| 国产亚洲美日韩AV中文字幕无码成人| 亚洲一区免费视频| xxxxx做受大片在线观看免费| 亚洲国产亚洲综合在线尤物| 亚洲午夜av影院| 麻豆最新国产剧情AV原创免费| 一级毛片a免费播放王色| 亚洲人成电影院在线观看| 亚洲国产日韩在线视频| 日本免费人成视频播放 | 亚洲无码日韩精品第一页| 曰曰鲁夜夜免费播放视频| 中文字幕免费人成乱码中国| 亚洲日本国产综合高清| 亚洲av永久无码精品网站| 亚洲国产成人五月综合网| 成年性羞羞视频免费观看无限| 免费在线看黄网站| 国产男女爽爽爽免费视频| 国产成人人综合亚洲欧美丁香花| 亚洲成年人电影在线观看|