A basic framework for connecting to the OpenSRS registry, executing requests and unmarshalling responses into POJOs that can then be consumed in your application.
OpenSRS Java Client and API
Documentation: https://dyanet.com/osrs/
- Configuration of multiple environments, for example,
testandprod - Jackson Marshalling and Unmarshalling of XML and envelopes
- Public certificate for SSL and MD5 signature
- Request and Response model for expansion to other APIs
- A few basic tests
- High-performance Apache HTTPClient
- Checkout the project and build with Maven or download the distribution
- Configuration is a simple
.propertiesfile, selected in this order:-Dosrs.config=<path-or-classpath-resource>— explicit JVM override- the
OSRS_CONFIGenvironment variable, same semantics — convenient for containers and.env-style deployments that export env vars instead of passing-Dflags (for example, mount a secret at/run/secrets/osrs.propertiesandexport OSRS_CONFIG=/run/secrets/osrs.properties) - otherwise
osrs-<env>.propertieson the classpath, where<env>is-Dosrs.env(defaulttest);osrs-test.propertiesandosrs-prod.propertiestemplates ship inosrs-api/src/main/resources
- Set your OpenSRS key and username (
osrs.userName,osrs.key) in the chosen configuration file - From within your application,
- get an instance of the client
OsrsClient.getInstance(false); - create a request object and set its properties
GetBalance req = new GetBalance(); req.setRegistrantIp(null); - read the response
OsrsResponse response = client.sendReceive(req); assertNotNull(response); System.out.println(response); - cast to POJO and read response properties
Balance balance = ((BalanceResponse)response).getBalance();
mvn test(ormvn verify) runs the fast, offline unit test suite and enforces a minimum instruction coverage bar via JaCoCo (seeosrs-api/pom.xml)- Tests tagged
integrationexercise the live OpenSRStestregistry over the network and are excluded by default; run them withmvn verify -Pintegration(requires valid credentials inosrs-api/src/test/resources/osrs-test.properties)