use of net.cryptonomica.returns.VerificationStruct in project cryptonomica by Cryptonomica.
the class EthNodeAPI method getVerificationDataFromSmartContract.
//
@ApiMethod(name = "getVerificationFromSC", path = "getVerificationFromSC", httpMethod = ApiMethod.HttpMethod.GET)
@SuppressWarnings("unused")
public VerificationStruct getVerificationDataFromSmartContract(// final HttpServletRequest httpServletRequest,
final User googleUser, @Named("ethereumAcc") final String ethereumAcc) throws IllegalArgumentException, UnauthorizedException {
// ensure registered user ( - may be later only for verified):
CryptonomicaUser cryptonomicaUser = UserTools.ensureCryptonomicaRegisteredUser(googleUser);
// check form:
LOG.warning("ethereumAcc" + ethereumAcc);
if (ethereumAcc == null || ethereumAcc.equals("")) {
throw new IllegalArgumentException("Provided text is to short or empty");
}
String tomcatWeb3jAPIkey = ofy().load().key(Key.create(AppSettings.class, "tomcatweb3jAPIkey")).now().getValue();
String urlHost = "https://tomcatweb3j.cryptonomica.net";
String urlPath = "/getVerification";
String urlAddress = urlHost + urlPath;
// HashMap<String, String> queryMap = new HashMap<>();
// queryMap.put("address", ethereumAcc);
String postRequestBody = "address=" + ethereumAcc;
HTTPResponse httpResponse = HttpService.postRequestWithAPIkey(urlAddress, postRequestBody, tomcatWeb3jAPIkey);
// LOG.warning("httpResponse: " + new Gson().toJson(httpResponse));
byte[] httpResponseContentBytes = httpResponse.getContent();
String httpResponseContentString = new String(httpResponseContentBytes, StandardCharsets.UTF_8);
// Test:
// Object resObj = new Gson().fromJson(httpResponseContentString, Object.class); // --- exception
// LOG.warning("resObj: " + new Gson().toJson(resObj));
LOG.warning("httpResponseContentString: " + httpResponseContentString);
VerificationStruct verificationStruct = GSON.fromJson(httpResponseContentString, VerificationStruct.class);
/* header:
content-type: application/json;charset=utf-8
body:
{
"fingerprint": "",
"keyCertificateValidUntil": 0,
"firstName": "",
"lastName": "",
"birthDate": 0,
"nationality": "",
"verificationAddedOn": 0,
"revokedOn": 0
}
*/
return verificationStruct;
}
Aggregations