Integration and Usage
Initialization
mvn install:install-file -DgroupId=com.github.ontio -DartifactId=ontlogin-sdk-java -Dversion=1.0.0 -Dpackaging=jar -Dfile=ontlogin-sdk-java-1.0.0.jar <dependency>
<groupId>com.github.ontio</groupId>
<artifactId>ontlogin-sdk-java</artifactId>
<version>1.0.0</version>
</dependency>Add API Methods
// Challenge request
@PostMapping("/challenge")
public Result generateChallenge(@RequestBody ClientHello clientHello) throws Exception {
String action = "generateChallenge";
ServerHello result = loginService.generateChallenge(action, clientHello);
return new Result(action, ErrorInfo.SUCCESS.code(), ErrorInfo.SUCCESS.descEN(), result);
}
// Challenge submission
@PostMapping("/validate")
public Result validateClientResponse(@RequestBody ClientResponse clientResponse) throws Exception {
String action = "validateClientResponse";
String token = loginService.validateClientResponse(action, clientResponse);
return new Result(action, ErrorInfo.SUCCESS.code(), ErrorInfo.SUCCESS.descEN(), token);
}
// Other business logic
@PostMapping("/check-jwt")
public Result checkJwt(@RequestBody JSONObject req) {
String action = "checkJwt";
String token = req.getString("token");
loginService.checkJwt(action, token);
return new Result(action, ErrorInfo.SUCCESS.code(), ErrorInfo.SUCCESS.descEN(), ErrorInfo.SUCCESS.descEN());
}Use loginService
loginServiceImport SDKUtil and Initialize ontlogin Sdk
SDKUtil and Initialize ontlogin SdkHandle VP
Last updated