cerulean

之前用axis2生成代码的时候都没有在意过,一路用default configuration下来。
前一阵子发现以前的代码在生成时选择的data binding不是用默认的adb方式,而是用xmlbeans。
google了一番不同数据绑定的区别,好像也没什么结果,大意就是adb的最简单,但是有局限性;xmlbeans支持的比较全面,但是用起来有点儿复杂。不过,我也没有体会出来xmlbeans强大在哪里……只是知道生成的代码更多了,调用起来更绕弯子而已。。。

server端用xmlbeans生成,client端用adb生成,互通是没有问题的。
client端用xmlbeans生成时,需要把产生于resources里面的所有.class文件打成jar包加到client端的build path里,否则运行client加载类的时候就会报错了,好诡异,太不友好了。
类似这种错误:

ClassNotFoundException : Cannot load SchemaTypeSystem. Unable to load class with name schemaorg_apache_xmlbeans.system.s68C41DB812F52C975439BA10FE4FEE54.TypeSystemHolder. Make sure the generated binary files are on the classpath.


所幸是在官方网站上有说明:http://ws.apache.org/axis2/tools/1_2/CodegenToolReference.html
posted @ 2009-12-30 15:59 cerulean 阅读(662) | 评论 (0)编辑 收藏
一个JNLP文件中的资源必须由同一个证书签名
当需要不同证书时,可以创建多个JNLP文件,并在主JNLP文件中引用之。

遇到过的问题:找不到子JNLP文件中的资源
解决方法:竟然把子JNLP文件放到比主JNLP文件所在目录低一级就可以了?!
posted @ 2009-11-20 15:13 cerulean 阅读(446) | 评论 (0)编辑 收藏

 

JLabel.setText("<html>auto new line</html>");
JLabel.setText("<html>line<br>force new line</html>");

 

posted @ 2009-10-29 11:43 cerulean 阅读(3388) | 评论 (1)编辑 收藏
费了半天劲,敢情Firefox在3.0版本后又支持弹出modal window啦
window.showModalDialog


posted @ 2009-09-22 15:59 cerulean 阅读(312) | 评论 (0)编辑 收藏
HttpClient.getHttpConnectionManager().getParams().setSoTimeout()
HttpClient.getHttpConnectionManager().getParams().setConnectionTimeout()

第一个针对连接建立后,但是没有收到response的超时时间,测试时可将server simulator收到request后等一段时间后再回response。
出错信息:
java.net.SocketTimeoutException: Read timed out

第二个针对连接建立的超时时间,测试时可将目的IP地址设为不存在的IP地址。
出错信息:
org.apache.commons.httpclient.ConnectTimeoutException: The host did not accept the connection within timeout of 8000 ms
        at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:154)
默认值为0,如果不设置的话大概2分多钟才会得到异常


posted @ 2009-09-10 16:09 cerulean 阅读(5145) | 评论 (1)编辑 收藏
导入了某证书至truststore,建立SSL连接时遇到错误
javax.net.ssl.SSLKeyException: RSA premaster secret error
Caused by: java.security.InvalidKeyException: Illegal key size or default parameters

在windows上双击查看该证书时发现Public Key是4096bit,查了一番后发现Java默认好像不能处理这么长的key,必须要按照JCE的一个Unlimited Strength Jurisdiction Policy
http://java.sun.com/javase/downloads/index_jdk5.jsp里面就有下载,这样貌似就可以处理这种强度比较高的了。


posted @ 2009-09-08 17:24 cerulean 阅读(2042) | 评论 (0)编辑 收藏
打印数组的方法,小地方,却老忘记,来自FindBugs的提示:
The code invokes toString on an array, which will generate a fairly useless result such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable String that gives the contents of the array.

Arrays提供一系列接收不同类型数组作为参数的toString方法

String[] array = new String[]{"a","b","c"};
System.out.println(Arrays.toString(array));

posted @ 2009-08-17 15:17 cerulean 阅读(1126) | 评论 (0)编辑 收藏
FindBugs,http://findbugs.sourceforge.net/
发现代码中潜在bug的工具,有eclipse的插件,安装后右键单击java project name,点击Find Bugs,切换到FindBugs得perspective可以看到结果,速度还比较快,比之前用过的一个(虽然已经记不得名字了)快一些~具体的效果还是要逐个分析。

Bug categories:

Correctness bug
Probable bug - an apparent coding mistake resulting in code that was probably not what the developer intended. We strive for a low false positive rate.
Bad Practice
Violations of recommended and essential coding practice. Examples include hash code and equals problems, cloneable idiom, dropped exceptions, serializable problems, and misuse of finalize. We strive to make this analysis accurate, although some groups may not care about some of the bad practices.
Dodgy
Code that is confusing, anomalous, or written in a way that leads itself to errors. Examples include dead local stores, switch fall through, unconfirmed casts, and redundant null check of value known to be null. More false positives accepted. In previous versions of FindBugs, this category was known as Style.
Multithreaded correctness
     Incorrect lazy initialization and update of static field
     Calls Thread.sleep() with a lock held: better to use wait(lock)
     Synchronization on interned String could deadlock: 最好不用字符串,以免重复
Performance
     invokes inefficient new String() constructor
     concatenates strings using + in a loop: better to use append StringBuffer
     inner class usage


posted @ 2009-08-14 16:04 cerulean 阅读(954) | 评论 (0)编辑 收藏
Server

创建本地证书:

keytool -genkey -alias testserver-keyalg RSA -keystore keystore

其中alias自己起一个别名,keystore为证书库的文件路径

还可以加上-keysize 1024、2048、4096等来指定公钥的大小,由此导出的证书查看时可以看到公钥的大小是与之一致的。keysize越大genkey时耗费时间越长。


会要求键入一个密码,为这个证书库的访问密码

会要求填写一些信息,姓名、单位、地区之类

最后要求键入一个密码,为这条证书别名的密码

导出cert

keytool -export -alias testserver-file testcert.cer -keystore keystore

这里的别名和文件名同上一步


Client

直接导入cert

Truststore文件中存储的是作为client,信任那些server的证书。所以需要将server提供的证书导入进来(当然可以导入n个),client才能信任。

keytool -import -alias testserver-file testcert.cer -keystore truststore

导入时需要输入密码,该密码应该是truststore文件的访问密码,密码正确才能修改其信息。

提示是否信任该证书信息,确认。

查看证书信息:

keytool –list –v –keystore truststore

如果导入过多个,则可以看到多条entry

删除某一个证书entry,通过指定别名来删:

keytool -delete -alias testserver-keystore truststore


上述是自签名的证书,证书链的长度只为
1

真正商用时,需要找相关机构(例如verisign)认证通过才能成为有效的证书:

生成证书签名请求:

keytool -certreq -keyalg RSA -alias testserver -file certreq.csr -keystore keystore

之后能够收到一个证书文件,证书链信息包含了该机构的一些信息,然后再导入。


有两种方法建立
HTTPS连接,

一种是,在java中可以设置相关的4个系统参数,指向相关的keystore,truststore,一旦设置,在运行时就不可改变了。除非一定要使用多个不同的证书库文件,否则可以把多个不同证书都导入到同一个证书库里,这样,设置系统参数为唯一的值也够用,而且也比较简单一些。

另一种是,自己继承相关接口实现自己的证书管理器,这样可以自定义相关行为,也可以load不同的证书库。


如果不设置
password,就认为不检查文件完整性,也能通过。如果设置了password,但是不正确,则会遇到密码错误的异常;如果server证书没有导入到client得信任列表里,则会遇到找不到可信证书的异常。

posted @ 2009-07-16 17:27 cerulean 阅读(541) | 评论 (0)编辑 收藏
一个反编译的好工具,600KB,简单好使又免费,比之前用过的好~
http://java.decompiler.free.fr/?q=jdgui
posted @ 2009-06-24 13:45 cerulean 阅读(273) | 评论 (0)编辑 收藏
仅列出标题
共6页: 上一页 1 2 3 4 5 6 下一页 

导航

<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

统计

常用链接

留言簿(3)

随笔分类

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜