Lock Account in Spring Security

參考:https://gist.github.com/max747/1327260

這實在是太厲害而且巧妙的程式,在Spring Security中利用AuthenticationFailureBadCredentialsEvent 解決Login登入失敗次數問題後,直接鎖帳號!

程式寫得太漂亮了!感謝這位大作!

廣告
張貼在 Uncategorized | 發表留言

改變執行序的優先順序 Windows process priority via command line

在Linux有renice

renice -5 PID

但在Microsoft Windows得用
cmd.exe /c start "Process Monitor" /High "C:\tomcat\bin\tomcat8.exe"
或是

wmic process where name="tomcat8.exe" CALL setpriority “above normal"

參考:https://superuser.com/questions/620724/changing-windows-process-priority-via-command-line

張貼在 Uncategorized | 發表留言

以Maven專案建立Runable Jar檔案的pom.xml

參考:https://stackoverflow.com/questions/1729054/including-dependencies-in-a-jar-with-maven

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.test.TestMain</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>

張貼在 Uncategorized | 發表留言

HTML 5 Canvas paint

http://literallycanvas.com
http://literallycanvas.com

張貼在 Uncategorized | 發表留言

Google reCapacha

<%@page import="java.net.*, java.io.*"%>

<%@page import="java.net.*, java.io.*"%>

<%@ page language="java" contentType="text/html; charset=UTF-8″ pageEncoding="UTF-8″%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %><%  response.setCharacterEncoding(“UTF-8″); request.setCharacterEncoding(“UTF-8″);%>

 

<% String g_recaptcha_response = (String)request.getParameter(“g-recaptcha-response"); String secret="6Lep5yUUAAAAANxHjoIVJl9Vc6PhD1qlA8sbYnG1″; URL dest = new URL(“https://www.google.com/recaptcha/api/siteverify?secret="+secret+"&response="+g_recaptcha_response); URLConnection yc = dest.openConnection(); BufferedReader in = new BufferedReader( new InputStreamReader( yc.getInputStream())); StringBuffer sb = new StringBuffer(); String inputLine; while ((inputLine = in.readLine()) != null){ sb.append(inputLine); } if (!sb.toString().matches(“.+\"success\"\\s*:\\s*true\\s*.+") ) out.println(sb.toString()); in.close();%>

 

張貼在 Uncategorized | 發表留言

Tomcat SSL KeyStore JKS擷取private key

參考:https://security.stackexchange.com/questions/3779/how-can-i-export-my-private-key-from-a-java-keytool-keystore

keytool -importkeystore -srckeystore ./localhost.keystore -destkeystore ./localhost.p12.pfx -srcstoretype jks -deststoretype PKCS12 -srcalias tomcat -destalias tomcat

openssl pkcs12 -in ./localhost.p12.pfx -nocerts -nodes -out ./localhost.private.key

 

張貼在 Uncategorized | 發表留言

Tomcat 8 加入 Microsoft Service服務後,增加記憶體設定

參考:

https://tomcat.apache.org/tomcat-8.5-doc/windows-service-howto.html

tomcat8.exe //US//Tomcat8 --JvmMs 512 --JvmMx 4096

張貼在 Uncategorized | 發表留言