﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-人生悲剧有二:1是万念俱灰,2是踌躇满志</title><link>http://www.blogjava.net/Fifth/</link><description /><language>zh-cn</language><lastBuildDate>Thu, 30 Apr 2026 06:23:24 GMT</lastBuildDate><pubDate>Thu, 30 Apr 2026 06:23:24 GMT</pubDate><ttl>60</ttl><item><title>转:yale cas 配置谈</title><link>http://www.blogjava.net/Fifth/archive/2007/10/21/154755.html</link><dc:creator>老五</dc:creator><author>老五</author><pubDate>Sun, 21 Oct 2007 12:07:00 GMT</pubDate><guid>http://www.blogjava.net/Fifth/archive/2007/10/21/154755.html</guid><wfw:comment>http://www.blogjava.net/Fifth/comments/154755.html</wfw:comment><comments>http://www.blogjava.net/Fifth/archive/2007/10/21/154755.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Fifth/comments/commentRss/154755.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Fifth/services/trackbacks/154755.html</trackback:ping><description><![CDATA[<a title="原文地址" style="color: red" href="http://blog.csdn.net/HuDon/archive/2007/02/06/1503234.aspx" target="_blank">原文地址</a><br />
<br />
TOMCAT :tomcat-5.5.15版<br />
JDK:1.5.06<br />
环境变量要设好.<br />
<br />
1.&nbsp; &nbsp; &nbsp; &nbsp; 启用TOMCAT的SSL<br />
把.keystore文件复制到TOMCAT的CONF目录下面。<br />
在TOMCAT的主目录的CONF目录下面，修改server.xml文件，加上以下代码<br />
&lt;Connector port="8443" maxHttpHeaderSize="8192"<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;maxThreads="150" minSpareThreads="25" maxSpareThreads="75"<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;enableLookups="false" disableUploadTimeout="true"<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;acceptCount="100" scheme="https" secure="true"<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;clientAuth="false" sslProtocol="TLS"<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;keystoreFile="conf/.keystore"<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;keystorePass="changeit"<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;/&gt;<br />
其中的keystoreFile是证书库文件，keystorePass是访问此证书库文件的密码。<br />
注：keystore文件可以用以下方法生成。<br />
Keytool &#8211;genkey &#8211;alias hostname &#8211;keyalg RSA(在接下来的第一项是名称，记住最好是和hostname同一名称)执行此操作会在用户的当前目录（user.home）下产生一个名为.keystore的文件。如果已经有了，将自动把新产生的KEY放进文件里面(此次的hostname是运行CAS服务器的名字.不要搞错,否则会在以后验证出错的.如果你是在本地测试,则用localhost就OK了)<br />
2.&nbsp; &nbsp; &nbsp; &nbsp; 导入证书文件到各个应用的JRE的JVM里面<br />
首先产生一个证书文件，用以下方法:<br />
Keytool &#8211;export &#8211;alias hostname &#8211;file filename.cer<br />
这样就在用户当前产生了一个名为filename.cer的文件<br />
接下来就把此文件导入到各应用的的JVM里面<br />
Keytool &#8211;import &#8211;alias hostname &#8211;file filename &#8211;keystore {java_home}\jre\lib\security\cacerts<br />
注：如果你的JAVA_HOME里面有空格，请用引号括住。<br />
3.&nbsp; &nbsp; &nbsp; &nbsp; 把cas.war包复制到TOMCAT的WEBAPPS下面，然后用<a href="http://localhost:8080/cas/login" target="_blank"><font color="#000000">http://localhost:8080/cas/login</font></a>就可以访问登陆了<br />
<br />
改写验证方法。CAS的默认方验证方法是用户名和密码相同，如果想改为自己的验证方式，如何做呢？你只需复制以下代码，然后在适当的地方插入你的验证代码就OK了。<br />
package org.jasig.cas.authentication.handler.support;<br />
<br />
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials;<br />
import org.springframework.util.StringUtils;<br />
<br />
public final class classname extends<br />
&nbsp; &nbsp; AbstractUsernamePasswordAuthenticationHandler {<br />
<br />
&nbsp; &nbsp; public boolean authenticateUsernamePasswordInternal(<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;final UsernamePasswordCredentials credentials) {<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;final String username = credentials.getUsername();<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;final String password = credentials.getPassword();<br />
<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;if (在此插入你的验证代码) {<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;getLog().debug(<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; "User [" + username + "] was successfully authenticated.");<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;return true;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;getLog().debug("User [" + username + "] failed authentication");<br />
<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;return false;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; protected void afterPropertiesSetInternal() throws Exception {<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;super.afterPropertiesSetInternal();<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;getLog()<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;.warn(<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; this.getClass().getName()<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;+ " is only to be used in a testing environment.&nbsp;&nbsp;NEVER enable this in a production environment.");<br />
&nbsp; &nbsp; }<br />
}<br />
<br />
然后，修改deployerConfigContext.xml（在CAS的WEB-INF目录下面）<br />
找到<br />
&lt;bean&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler" /&gt;<br />
把class改为你自己写的验证的类就OK了。<br />
到此，服务器端的配置就完成了。<br />
接下来是各个应用的配置：<br />
<br />
4.（以JAVA的配置为例子）把casclient.jar包复制到应用的lib目录下面，如果没有就创建它。然后再在应用的部署描述文件里面（web.xml）加上filter。如下:<br />
&lt;filter&gt;<br />
&nbsp; &nbsp; &lt;filter-name&gt;CAS Filter&lt;/filter-name&gt;<br />
&nbsp; &nbsp; &lt;filter-class&gt;edu.yale.its.tp.cas.client.filter.CASFilter&lt;/filter-class&gt;<br />
&nbsp; &nbsp; &lt;init-param&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&lt;param-name&gt;edu.yale.its.tp.cas.client.filter.loginUrl&lt;/param-name&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&lt;param-value&gt;<a href="https://casserverhost:8443/cas/login" target="_blank"><font color="#000000">https://casServerhost:8443/cas/login</font></a>&lt;/param-value&gt;<br />
&nbsp; &nbsp; &lt;/init-param&gt;<br />
&nbsp; &nbsp; &lt;init-param&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&lt;param-name&gt;edu.yale.its.tp.cas.client.filter.validateUrl&lt;/param-name&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&lt;param-value&gt;https:// casServerhost:8443/cas/proxyValidate&lt;/param-value&gt;<br />
&nbsp; &nbsp; &lt;/init-param&gt;<br />
&nbsp; &nbsp; &lt;init-param&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&lt;param-name&gt;edu.yale.its.tp.cas.client.filter.serverName&lt;/param-name&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&lt;param-value&gt;localhost:8080&lt;/param-value&gt;<br />
&nbsp; &nbsp; &lt;/init-param&gt;<br />
&nbsp;&nbsp;&lt;/filter&gt;<br />
&lt;filter-mapping&gt;<br />
&nbsp;&nbsp;&lt;filter-name&gt;CAS Filter&lt;/filter-name&gt;<br />
&nbsp;&nbsp;&lt;url-pattern&gt;/servlet/*&lt;/url-pattern&gt;<br />
&lt;/filter-mapping&gt;<br />
<br />
Localhost是指各个应用的服务器的名字<br />
casServerHost是指cas服务器的名字<br />
其中的filter-mapping就是配置哪些资源是需要通过CAS验证的。可以配置多个。<br />
<br />
4.&nbsp; &nbsp; &nbsp; &nbsp; 配置语言包<br />
在cas里面的WEB-INF\classes下面添加不同的语言包，然后再在\WEB-INF\view\jsp\default\ui\includes的top.jsp文件顶部加入&lt;%@ page contentType="text/html; charset=gbk" language="java" %&gt;便可以了。<br />
<br />
一些错误信息：<br />
1.&nbsp; &nbsp; &nbsp; &nbsp; keytool 认证未输入别名 &lt;mykey&gt; 已经存在<br />
这是因为你已经导入了一信任证书。在进行keytool &#8211;import的时候，如果没有指定别名，则系统默任导入的证书的名字为mykey，所以，可以先删除此证书keytool &#8211;delete &#8211;alias mykey &#8211;keystore {java_home}\jre\lib\security\cacerts<br />
然后再从新导入，或者指定别名导入keytool &#8211;import &#8211;alias name &#8211;keystore {java_home}\jre\lib\security\cacerts<br />
<br />
2.&nbsp; &nbsp; &nbsp; &nbsp; java.io.IOException: Keystore was tampered with, or password was incorrect<br />
这个很可能你的keystore文件已经被修改了，密码已经更改，直接删除这个文件，再从新生成就可以了<br />
3.&nbsp; &nbsp; &nbsp; &nbsp; javax.servlet.ServletException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target<br />
这是因为你没有在应用端导入证书。在应用端执行keytool &#8211;import &#8211;alias name &#8211;file filename.cer便可以。其中的name.cer是在前面的用keytool &#8211;export导出的cer文件<br />
<img src ="http://www.blogjava.net/Fifth/aggbug/154755.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Fifth/" target="_blank">老五</a> 2007-10-21 20:07 <a href="http://www.blogjava.net/Fifth/archive/2007/10/21/154755.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：机器上有多个Tomcat的问题</title><link>http://www.blogjava.net/Fifth/archive/2007/10/08/151159.html</link><dc:creator>老五</dc:creator><author>老五</author><pubDate>Mon, 08 Oct 2007 13:32:00 GMT</pubDate><guid>http://www.blogjava.net/Fifth/archive/2007/10/08/151159.html</guid><wfw:comment>http://www.blogjava.net/Fifth/comments/151159.html</wfw:comment><comments>http://www.blogjava.net/Fifth/archive/2007/10/08/151159.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Fifth/comments/commentRss/151159.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Fifth/services/trackbacks/151159.html</trackback:ping><description><![CDATA[<p>如果你的机器有多个Tomcat，当你执行一个Tomcat的startup命令时，它执行的是你希望的那个吗？<br />
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 我机器有多个Tomcat的目录，因为它不用安装，所以，我就进入到一个Tomcat的bin目录，执行startup.bat，结果发现不对，它执行的是另一个目录下的Tomcat。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 后来想明白了，是CATALINA_HOME的问题，不管你执行的是那个目录下的启动命令，而真正执行的是CATALINA_HOME配置的那个Tomcat的命令，或者说startup会寻找CATALINA_HOME配置的目录，启动那个Tomcat。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 切记，否则，会被耍得很郁闷......</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 另外，catalina*.bat文件也很有用，你可以自己编辑这个文件，为它指定JAVA_HOME，这样你就可以不用事先安装JDK或者JRE，自己的程序中打包一个JDK，然后，指定JAVA_HOME为自己的这个JDK的相对路径，然后用安装打包工具，如NSIS，Wise等打包，然后，安装会把这些东西都复制到指定的路径下，你的程序直接执行startup命令就可以了，这样即使用户不懂技术，安装步骤也不复杂。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 还有，好像是Tomcat4.1.29开始，Tomcat对Get的处理和Post不再一样，就带来了Tomcat的URIEncoding的问题，具体解决办法是配置URIEncoding="字符集"，我忘了从那里看到了，写在这里，如果哪位兄弟知道确切的出处，请告诉我，谢谢！</p>
<a title="原文地址" href="http://rabbit8.bokee.com/1128738.html" target="_blank">原文地址</a>
<img src ="http://www.blogjava.net/Fifth/aggbug/151159.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Fifth/" target="_blank">老五</a> 2007-10-08 21:32 <a href="http://www.blogjava.net/Fifth/archive/2007/10/08/151159.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Eclipse格式化代码时不换行</title><link>http://www.blogjava.net/Fifth/archive/2007/09/27/148902.html</link><dc:creator>老五</dc:creator><author>老五</author><pubDate>Thu, 27 Sep 2007 14:34:00 GMT</pubDate><guid>http://www.blogjava.net/Fifth/archive/2007/09/27/148902.html</guid><wfw:comment>http://www.blogjava.net/Fifth/comments/148902.html</wfw:comment><comments>http://www.blogjava.net/Fifth/archive/2007/09/27/148902.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Fifth/comments/commentRss/148902.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Fifth/services/trackbacks/148902.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;每次用Eclipse自带的Ctrl+shift+f格式化代码时，如果原来的一行代码大于80列，Eclipse就会自动换为多行，这点个人感觉不是很舒服，简单试了一下，通过以下方式可以修改：<br />
&nbsp;&nbsp;&nbsp;&nbsp;1、preferences-&gt;Java-&gt;Code&nbsp;Style-&gt;Code&nbsp;Formatter-&gt;Show... ，打开之后，选择&#8220;Line Wrapping&#8221;选项卡，在&#8220;Maximun line width&#8221;指定大于多少列时换行。<br />
&nbsp;&nbsp;&nbsp;&nbsp;2、还是在&#8220;Line Wrapping&#8221;选项卡中，能过选择"Line Wrapping policy"可以指定构造函数、方法体等的换行情况。<br />
&nbsp;&nbsp;&nbsp;&nbsp;不过，SUN推荐的编码风格默认是80列换行。
<img src ="http://www.blogjava.net/Fifth/aggbug/148902.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Fifth/" target="_blank">老五</a> 2007-09-27 22:34 <a href="http://www.blogjava.net/Fifth/archive/2007/09/27/148902.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>