This commit is contained in:
ZZ 2021-10-08 16:35:21 +08:00
parent c85c0636fd
commit 7d39894ff2
2 changed files with 3 additions and 16 deletions

View File

@ -65,13 +65,12 @@ public class CoreDispatcher {
.writeTimeout(10, TimeUnit.SECONDS); .writeTimeout(10, TimeUnit.SECONDS);
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
String bearer = null; String bearer = null;
AuthSecretToken authSecretTokenOut; AuthSecretToken authSecretTokenOut = getAuthSecretTokenOut(operatorId3irdpty, operatorID);
try { try {
if (object.getClass().getSimpleName().equals("CommonRequest")) { if (object.getClass().getSimpleName().equals("CommonRequest")) {
CommonRequest commonRequest = (CommonRequest) object; CommonRequest commonRequest = (CommonRequest) object;
if (operatorId3irdpty == null) if (operatorId3irdpty == null)
operatorId3irdpty = commonRequest.getOperatorId(); operatorId3irdpty = commonRequest.getOperatorId();
authSecretTokenOut = getAuthSecretTokenOut(operatorId3irdpty, operatorID);
Date tokenExpiry = authSecretTokenOut.getTokenExpiry(); Date tokenExpiry = authSecretTokenOut.getTokenExpiry();
String oData = commonRequest.getData(); String oData = commonRequest.getData();
String tData; String tData;
@ -87,7 +86,7 @@ public class CoreDispatcher {
authSecretTokenOut.getSigSecret(), commonRequest); authSecretTokenOut.getSigSecret(), commonRequest);
} }
Request request = new Request.Builder() Request request = new Request.Builder()
.url(evcsSrvUrl + "/query_token") .url(authSecretTokenOut.getUrlPrefix() + "/query_token")
.post(okhttp3.RequestBody.create(JSON, tData)) .post(okhttp3.RequestBody.create(JSON, tData))
.build(); .build();
OkHttpClient client = builder.build(); OkHttpClient client = builder.build();
@ -116,7 +115,7 @@ public class CoreDispatcher {
throw new ServerInternalException(msg); throw new ServerInternalException(msg);
} }
final Request.Builder req = new Request.Builder() final Request.Builder req = new Request.Builder()
.url(evcsSrvUrl + url) .url(authSecretTokenOut.getUrlPrefix() + url)
.header("Authorization", "Bearer " + bearer); .header("Authorization", "Bearer " + bearer);
Request request; Request request;
assert body != null; assert body != null;

View File

@ -40,12 +40,6 @@ public class QueryTokenController extends CoreDispatcher {
tokenResponse.setOperatorId("MA6DFCTD5"); tokenResponse.setOperatorId("MA6DFCTD5");
tokenResponse.setSuccStat(0); tokenResponse.setSuccStat(0);
tokenResponse.setFailReason(0); tokenResponse.setFailReason(0);
// if (operator == null) {
// resp.setRet("4003");
// resp.setMsg("Invalid OperatorID");
// tokenResponse.setSuccStat(1);
// tokenResponse.setFailReason(1);
// } else {
String data = null; String data = null;
AuthSecretToken authSecretToken = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenTypeAndOperatorSecret( AuthSecretToken authSecretToken = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenTypeAndOperatorSecret(
operatorID, AuthSecretToken.SECRET_TOKEN_TYPE_IN, tokenRequest.getOperatorSecret()).orElse(null); operatorID, AuthSecretToken.SECRET_TOKEN_TYPE_IN, tokenRequest.getOperatorSecret()).orElse(null);
@ -79,7 +73,6 @@ public class QueryTokenController extends CoreDispatcher {
resp.setSig(encrypt.get("Sig").asText()); resp.setSig(encrypt.get("Sig").asText());
log.debug("out.enc: {}", resp); log.debug("out.enc: {}", resp);
} }
// }
return resp; return resp;
} }
@ -90,9 +83,4 @@ public class QueryTokenController extends CoreDispatcher {
return dt.toDate(); return dt.toDate();
} }
private AuthSecretToken getAuthSecretToken(String operatorID, String tokenType) {
return authSecretTokenRepository.findByOperatorIdAndSecretTokenType(operatorID, tokenType).orElse(null);
}
} }