List of usage examples for java.security SignatureException printStackTrace
public void printStackTrace()
From source file:com.znsx.cms.service.impl.LicenseManagerImpl.java
/** * License/*ww w .j a v a 2s. co m*/ * * @param license * ?License * @throws BusinessException * @author huangbuji * <p /> * Create at 2013 ?7:34:21 */ private void contentCheck(License license) throws BusinessException { if (StringUtils.isBlank(license.getSignature())) { throw new BusinessException(ErrorCode.LICENSE_HAS_BEEN_CHANGED, "License content has been changed !"); } // String publicKeyString = getPublicKey(); byte[] publicKey = getPublicBinKey(); boolean contentVerify = false; try { // contentVerify = LicenceUtil.verify(license.toString(), // publicKeyString, license.getSignature()); contentVerify = LicenceUtil.verifyBinKey(license.toString(), publicKey, license.getSignature()); } catch (SignatureException e) { e.printStackTrace(); throw new BusinessException(ErrorCode.LICENSE_FORMAT_INVALID, "Format of license file invalid !"); } catch (Exception e) { e.printStackTrace(); throw new BusinessException(ErrorCode.ERROR, e.getMessage()); } if (!contentVerify) { throw new BusinessException(ErrorCode.LICENSE_HAS_BEEN_CHANGED, "License content has been changed !"); } }
From source file:org.dasein.cloud.cloudstack.CSMethod.java
public String buildUrl(String command, Param... params) throws CloudException, InternalException { ProviderContext ctx = provider.getContext(); String apiShared = ""; String apiSecret = ""; try {/* w w w.ja v a 2 s .c o m*/ List<ContextRequirements.Field> fields = provider.getContextRequirements().getConfigurableValues(); for (ContextRequirements.Field f : fields) { if (f.type.equals(ContextRequirements.FieldType.KEYPAIR)) { byte[][] keyPair = (byte[][]) ctx.getConfigurationValue(f); apiShared = new String(keyPair[0], "utf-8"); apiSecret = new String(keyPair[1], "utf-8"); } } } catch (UnsupportedEncodingException ignore) { } if (ctx == null) { throw new CloudException("No context was set for this request"); } try { StringBuilder str = new StringBuilder(); String apiKey = apiShared; String accessKey = apiSecret; StringBuilder newKey = new StringBuilder(); for (int i = 0; i < apiKey.length(); i++) { char c = apiKey.charAt(i); if (c != '\r') { newKey.append(c); } } apiKey = newKey.toString(); newKey = new StringBuilder(); for (int i = 0; i < accessKey.length(); i++) { char c = accessKey.charAt(i); if (c != '\r') { newKey.append(c); } } accessKey = newKey.toString(); str.append(ctx.getCloud().getEndpoint()); // Make sure the url ends up exactly as http://x.x.x.x:y/client/api?command= // otherwise the server may choke like we've found it does for uploadSslCert command. while (str.lastIndexOf("/") == str.length() - 1) { str.deleteCharAt(str.length() - 1); } if (!str.toString().endsWith("/api")) { str.append("/api"); } str.append("?command="); str.append(command); for (Param param : params) { str.append("&"); str.append(param.getKey()); if (param.getValue() != null) { str.append("="); str.append(URLEncoder.encode(param.getValue(), "UTF-8").replaceAll("\\+", "%20")); } } str.append("&apiKey="); str.append(URLEncoder.encode(apiKey, "UTF-8").replaceAll("\\+", "%20")); str.append("&signature="); try { str.append(URLEncoder.encode(getSignature(command, apiKey, accessKey, params), "UTF-8") .replaceAll("\\+", "%20")); } catch (SignatureException e) { throw new InternalException(e); } return str.toString(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); throw new RuntimeException("This cannot happen: " + e.getMessage()); } }
From source file:gpps.service.impl.ThirdPaySupportServiceImpl.java
private void sendExecuteRepay(Map<String, String> params, String baseUrl) { //LoanNoList + PlatformMoneymoremore + AuditType + RandomTimeStamp + Remark1 + Remark2 + Remark3 + ReturnURL + NotifyURL StringBuilder sBuilder = new StringBuilder(); sBuilder.append(StringUtil.strFormat(params.get("LoanNoList"))); sBuilder.append(StringUtil.strFormat(params.get("PlatformMoneymoremore"))); sBuilder.append(StringUtil.strFormat(params.get("AuditType"))); sBuilder.append(StringUtil.strFormat(params.get("RandomTimeStamp"))); sBuilder.append(StringUtil.strFormat(params.get("Remark1"))); sBuilder.append(StringUtil.strFormat(params.get("Remark2"))); sBuilder.append(StringUtil.strFormat(params.get("Remark3"))); sBuilder.append(StringUtil.strFormat(params.get("ReturnURL"))); sBuilder.append(StringUtil.strFormat(params.get("NotifyURL"))); RsaHelper rsa = RsaHelper.getInstance(); String signInfo = rsa.signData(sBuilder.toString(), innerThirdPaySupportService.getPrivateKey()); params.put("SignInfo", signInfo); String body = httpClientService.post(baseUrl, params); Gson gson = new Gson(); Map<String, String> returnParams = gson.fromJson(body, Map.class); try {/*from w ww.j a v a2 s . c om*/ checkExecutePaybackProcessor(returnParams); } catch (SignatureException e) { e.printStackTrace(); } catch (ResultCodeException e) { e.printStackTrace(); } }
From source file:gpps.service.impl.ThirdPaySupportServiceImpl.java
private void sendCheck(Map<String, String> params, String baseUrl) { //LoanNoList + PlatformMoneymoremore + AuditType + RandomTimeStamp + Remark1 + Remark2 + Remark3 + ReturnURL + NotifyURL StringBuilder sBuilder = new StringBuilder(); sBuilder.append(StringUtil.strFormat(params.get("LoanNoList"))); sBuilder.append(StringUtil.strFormat(params.get("PlatformMoneymoremore"))); sBuilder.append(StringUtil.strFormat(params.get("AuditType"))); sBuilder.append(StringUtil.strFormat(params.get("RandomTimeStamp"))); sBuilder.append(StringUtil.strFormat(params.get("Remark1"))); sBuilder.append(StringUtil.strFormat(params.get("Remark2"))); sBuilder.append(StringUtil.strFormat(params.get("Remark3"))); sBuilder.append(StringUtil.strFormat(params.get("ReturnURL"))); sBuilder.append(StringUtil.strFormat(params.get("NotifyURL"))); RsaHelper rsa = RsaHelper.getInstance(); String signInfo = rsa.signData(sBuilder.toString(), innerThirdPaySupportService.getPrivateKey()); params.put("SignInfo", signInfo); String body = httpClientService.post(baseUrl, params); Gson gson = new Gson(); Map<String, String> returnParams = gson.fromJson(body, Map.class); try {/*w w w . j ava 2 s .c o m*/ checkBuyProcessor(returnParams); } catch (SignatureException e) { e.printStackTrace(); } catch (ResultCodeException e) { e.printStackTrace(); } }