顯示具有 Java 標籤的文章。 顯示所有文章
顯示具有 Java 標籤的文章。 顯示所有文章

2016年1月11日 星期一

Java Mail - failed to connect, no password specified

若發生無法連線

javax.mail.AuthenticationFailedException: failed to connect, no password specified?
at javax.mail.Service.connect(Service.java:329)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at com.pic.framework.util.RainbowMailTest.main(RainbowMailTest.java:72)


Java Mail - Could not connect to SMTP host: localhost, port: 25

Java Mail連線時,  需確認IPV6是否為關閉,  否則會無法連線.

2015年12月21日 星期一

Java security

key word : java web  傳輸加密
ESTful登錄設計(基於Spring及Redis的Token鑒權)
Spring MVC RestFul API接口化
用RSA加密實現Web登錄密碼加密傳輸

Java 使用加密演算法 - 產生與儲存 RSA 的金鑰

google key :
spring rss
keypairgenerator example java

在 Java 使用加密演算法(一):產生與儲存 RSA 的金鑰
在 Java 使用加密演算法(二):使用 RSA 加密與解密
在 Java 使用加密演算法(三):使用 RSA 加解密長資料
無聊寫的加解密RSA和DES,有興趣的一起討論
RSA加密算法及其與SpringMVC集成

How to read properties file in web application?

How to read properties file in web application?

Several notes:
  1. You should prefer the ClassLoader as returned by Thread#getContextClassLoader().
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    This returns the parentmost classloader which has access to all resources. The Class#getClassLoader() will only return the (child) classloader of the class in question which may not per se have access to the desired resource. It will always work in environments with a single classloader, but not always in environments with a complex hierarchy of classloaders like webapps.
  2. The /WEB-INF folder is not in the root of the classpath. The /WEB-INF/classes folder is. So you need to load the properties files relative to that.
    classLoader.getResourceAsStream("/auth.properties");
    If you opt for using the Thread#getContextClassLoader(), remove the leading /.