| | |
| | | import com.auth0.jwt.exceptions.JWTVerificationException; |
| | | import com.auth0.jwt.interfaces.Claim; |
| | | import com.auth0.jwt.interfaces.DecodedJWT; |
| | | import com.java110.common.cache.JWTCache; |
| | | import com.java110.common.cache.MappingCache; |
| | | import com.java110.common.constant.CommonConstant; |
| | | import com.java110.common.constant.MappingConstant; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.exception.NoAuthorityException; |
| | | import com.java110.common.util.DateUtil; |
| | | import com.java110.common.util.StringUtil; |
| | | import com.java110.utils.cache.JWTCache; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.constant.CommonConstant; |
| | | import com.java110.utils.constant.MappingConstant; |
| | | import com.java110.utils.constant.ResponseConstant; |
| | | import com.java110.utils.exception.NoAuthorityException; |
| | | import com.java110.utils.util.StringUtil; |
| | | |
| | | import com.java110.core.context.ApiDataFlow; |
| | | import com.java110.core.context.DataFlow; |
| | |
| | | throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "MD5签名过程中出现错误"); |
| | | } |
| | | String reqInfo = dataFlow.getTransactionId() + dataFlow.getRequestTime() + dataFlow.getAppId(); |
| | | reqInfo += "GET,DELETE".equals(dataFlow.getRequestHeaders().get(CommonConstant.HTTP_METHOD)) ? |
| | | dataFlow.getRequestHeaders().get("REQUEST_URL") : dataFlow.getReqData(); |
| | | String url = dataFlow.getRequestHeaders().get("REQUEST_URL"); |
| | | String param = ""; |
| | | if(url.indexOf("?") > 0){ |
| | | param = url.substring(url.indexOf("?")); |
| | | } |
| | | //,DELETE |
| | | reqInfo += "GET".equals(dataFlow.getRequestHeaders().get(CommonConstant.HTTP_METHOD)) ? |
| | | param : dataFlow.getReqData(); |
| | | reqInfo += dataFlow.getAppRoutes().get(0).getSecurityCode(); |
| | | return md5(reqInfo); |
| | | } |
| | |
| | | |
| | | /***********************************JWT end***************************************/ |
| | | public static void main(String[] args) throws Exception { |
| | | KeyPair keyPair = genKeyPair(1024); |
| | | // KeyPair keyPair = genKeyPair(1024); |
| | | // |
| | | // //获取公钥,并以base64格式打印出来 |
| | | // PublicKey publicKey = keyPair.getPublic(); |
| | | // System.out.println("公钥:" + new String(Base64.getEncoder().encode(publicKey.getEncoded()))); |
| | | // |
| | | // //获取私钥,并以base64格式打印出来 |
| | | // PrivateKey privateKey = keyPair.getPrivate(); |
| | | // System.out.println("私钥:" + new String(Base64.getEncoder().encode(privateKey.getEncoded()))); |
| | | |
| | | //获取公钥,并以base64格式打印出来 |
| | | PublicKey publicKey = keyPair.getPublic(); |
| | | System.out.println("公钥:" + new String(Base64.getEncoder().encode(publicKey.getEncoded()))); |
| | | |
| | | //获取私钥,并以base64格式打印出来 |
| | | PrivateKey privateKey = keyPair.getPrivate(); |
| | | System.out.println("私钥:" + new String(Base64.getEncoder().encode(privateKey.getEncoded()))); |
| | | System.out.printf("passwdMd5 " + passwdMd5("wuxw2015")); |
| | | |
| | | } |
| | | } |