Skip to content

Commit

Permalink
adding validation
Browse files Browse the repository at this point in the history
  • Loading branch information
xxLestadxx committed Dec 18, 2020
1 parent e14a1fd commit c7185ce
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.recheck-io</groupId>
<artifactId>hammerJ</artifactId>
<version>1.0.13</version>
<version>1.0.15</version>

<dependencies>
<dependency>
Expand Down
37 changes: 21 additions & 16 deletions src/main/java/io/recheck/client/crypto/E2EEncryption.java
Original file line number Diff line number Diff line change
Expand Up @@ -1157,29 +1157,34 @@ public JSONObject checkHash(String dataChainId, String userId) throws ServerExce
* @throws ServerException
*/
public JSONObject checkHashWithExternalId(String dataChainId, String userId, String requestId) throws ServerException, ValidationException {
if (userId.contains("re_")) {
userId = userId.substring(3);
}
if (validateEthAddress(userId) || validateAEAddress(userId)) {
if (userId.contains("re_")) {
userId = userId.substring(3);
}

try{
JSONObject result = convertExternalId(dataChainId, userId);
dataChainId = result.get("dataId").toString();
}catch (Exception e){
throw new ValidationException(e.getMessage());
}
try{
JSONObject result = convertExternalId(dataChainId, userId);
dataChainId = result.get("dataId").toString();
}catch (Exception e){
throw new ValidationException(e.getMessage());
}


String query = "&userId=" + userId + "&dataId=" + dataChainId + "&requestId=" + requestId;
String query = "&userId=" + userId + "&dataId=" + dataChainId + "&requestId=" + requestId;

String getUrl = getEndpointUrl("tx/info", query);
LOGGER.severe("query URL " + getUrl);
String getUrl = getEndpointUrl("tx/info", query);
LOGGER.severe("query URL " + getUrl);

String serverResponse = getRequest(getUrl);
JSONObject serverRes = new JSONObject(serverResponse);
String serverResponse = getRequest(getUrl);
JSONObject serverRes = new JSONObject(serverResponse);

LOGGER.severe("Server responds to checkHash GET " + serverRes.get("data"));
LOGGER.severe("Server responds to checkHash GET " + serverRes.get("data"));

return serverRes;
}else {
throw new ValidationException("The userId is invalid.");
}

return serverRes;
}

/**
Expand Down

0 comments on commit c7185ce

Please sign in to comment.