Code Monkey home page Code Monkey logo

latch-sdk-java's Introduction

LATCH JAVA SDK

#### PREREQUISITES ####

CREATING THE JAR DEPENDENCY

Now using Maven (maven.apache.org) is easy to compile and pack all the code for using externally:

mvn install

And the compiled jar was located in the target directory.

You can also compile the jar with all Latch dependencies included:

mvn clean compile assembly:single =======

USING THE SDK IN JAVA

  • Include all SDK files and dependencies in your project.

  • Create a Latch object with the "Application ID" and "Secret" previously obtained.

     Latch latch = new Latch(APP_ID, SECRET);
  • Call to Latch Server. Pairing will return an account id that you should store for future api calls
     LatchResponse pairResponse = latch.pair(TOKEN);
     LatchResponse statusResponse = latch.status(ACCOUNT_ID);
     LatchResponse opStatusResponse = latch.operationStatus(ACCOUNT_ID, OPERATION_ID);
     LatchResponse unpairResponse = latch.unpair(ACCOUNT_ID);
  • After every API call, get Latch response data and errors and handle them.
     JsonObject jObject = latchResponse.getData();
     com.elevenpaths.latch.Error error = latchResponse.getError();

USING JAVA SDK FOR WEB3 SERVICES

For using the Java SDK within an Web3 service, you must complain with the following:

  • In the Latch website, having an developer account, with the Web3 permissions activated. You must see a new button for creating a Web3 new app.

  • Tutorial to follow for creating a new WEB3 app

  • You need a wallet to operate on Polygon blockchain. You can easily create one through Metamask.

You need this additional parameters:

  • WEB3WALLET: The Ethereum-based address wallet for the user that wants to pair the service.
  • WEB3SIGNATURE: A proof-of-ownership signature of a constant, in order to verify that the user owns the private key of the wallet. You can use https://etherscan.io/verifiedSignatures# to sign the following message:
  • MESSAGE TO SIGN : "Latch-Web3"

Example of using it java example

TROUBLESHOOTING

A javax.net.ssl.SSLHandshakeException with a nested sun.security.validator.ValidatorException is thrown when invoking an API call.

This exception is normally thrown when the JDK doesn't trust the CA that signs the digital certificate used in Latch's website (https://latch.telefonica.com). You may need to install the CA (http://www.startssl.com/certs/ca.pem) as a trusted certificate in your JDK's truststore (normally in jre/lib/security/cacerts) using the keytool utility.

latch-sdk-java's People

Contributors

bocanegra avatar derekkddj avatar jaesga avatar joseangelmontesmeana avatar luciamunozdev avatar pradomota avatar rpiccio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

latch-sdk-java's Issues

Certificate issue

Calling to latch.pair("token") throws an exception (jvm 1.7.0_67):
An exception has been thrown when communicating with Latch backend
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1884)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at com.elevenpaths.latch.Latch.HTTP(Latch.java:479)
at com.elevenpaths.latch.Latch.HTTP_GET(Latch.java:143)
at com.elevenpaths.latch.Latch.HTTP_GET_proxy(Latch.java:160)
at com.elevenpaths.latch.Latch.pair(Latch.java:200)

Compatibilidad Java 1.5

En el Readme del API se especifica claramente:
LATCH JAVA SDK
PREREQUISITES
Java 1.5 or above.

El problema es que dentro del código se utiliza en varias ocasiones el método

java.lang.String.isEmpty

El cual solo está disponible a partir de Java 1.6, por lo que puede dar lugar a confusión.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.