Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

6 Commits

Repository files navigation

rps-engine-client-java

Regdata RPS Engine Client library (Java)

RPS Engine Client library documentation

The full documentation is available in RPS Community

Installation

Use maven to install the RPS Engine Client library. Add the following dependency in dependencies section of your pom.xml file

<!-- https://mvnrepository.com/artifact/ch.regdata.rps.engine.client/rps-engine-api-client -->
<dependency>
<groupId>ch.regdata.rps.engine.client</groupId>
<artifactId>rps-engine-api-client</artifactId>
<version>3.10.0</version>
</dependency>

Usage

Initialization

First initialize EngineProviderFactory class with the apiKey and secretKey you got from RPS CoreConfiguration

packagech.regdata.rps.engine.client.examples;
importch.regdata.rps.engine.client.http.HttpClientEngineProvider;
publicabstractclassEngineProviderFactory {
publicstaticHttpClientEngineProvidergetEngineProvider() {
// Configuration options for RPS Engine Client library.finalStringengineHostName = "https://engine.rpsprod.ch";// Example: "https://engine.rpsprod.ch"finalStringidentityHostName = "https://identity.rpsprod.ch"; // Example: "https://identity.rpsprod.ch",finalStringapiKey = "****************"; // Example: "518155d0-4774-467c-b891-6ebd3ea07f08"finalStringsecretKey = "*****************"; // Example: "75582a544bdasa23easdasdaadssd5f60369b9866026d8485aa49f7edcfe986bb1"// Set the engine provider with connection detailsHttpClientEngineProviderengineProvider = newHttpClientEngineProvider();
engineProvider.setApiKey(apiKey);
engineProvider.setSecretKey(secretKey);
engineProvider.setIdentityHost(identityHostName);
engineProvider.setEngineHost(engineHostName);
returnengineProvider;
}
}

Simple example

Then do transformations as in the following SimpleUsageExample class

packageyourpackage;
importch.regdata.rps.engine.client.*;
importch.regdata.rps.engine.client.enginecontext.ProcessingContext;
importch.regdata.rps.engine.client.enginecontext.RPSEngineContextResolver;
importch.regdata.rps.engine.client.http.HttpClientEngineProvider;
importch.regdata.rps.engine.client.mapping.RPSMapping;
importch.regdata.rps.engine.client.model.api.value.IRPSValue;
importch.regdata.rps.engine.client.model.api.value.RPSValue;
importjava.util.ArrayList;
importjava.util.Arrays;
publicclassSimpleUsageExample {
publicstaticvoidmain(String[] args) {
// Get the engine provider with connection detailsHttpClientEngineProviderengineProvider = EngineProviderFactory.getEngineProvider();
System.out.println("--- Example of simple protection and deprotection ---");
// Manually creates admin rights context.ContextadminRightsContext = newContext(newArrayList<>(Arrays.asList(
newEvidence("Role", "Admin")
)));
// Manually creates protecting processing context.ProcessingContextprotectProcessingContext = newProcessingContext(newArrayList<>(Arrays.asList(
newEvidence("Action", "Protect")
)));
// Manually creates deprotecting processing context.ProcessingContextdeprotectProcessingContext = newProcessingContext(newArrayList<>(Arrays.asList(
newEvidence("Action", "Deprotect")
)));
// Different constructors with ability to specify Instance and Original value.RPSValuerawFirstName = newRPSValue(newRPSMapping("User", "FirstName"), "Jonny");
RPSValuerawLastName = newRPSValue(newRPSMapping("User", "LastName"), "Silverhand");
RPSValuerawBirthDate = newRPSValue(newRPSMapping("User", "BirthDate"), "16.11.1988");
RPSValueprotectedFirstName = newRPSValue(newRPSMapping("User", "FirstName"), "n99toNMwdjjGtWs3SxkrxQ==");
RPSValueprotectedLastName = newRPSValue(newRPSMapping("User", "LastName"), "FLGqfDklPngzYAD8066q40drM1jZYQzKktF1YO81A==");
RPSValueprotectedBirthDate = newRPSValue(newRPSMapping("User", "BirthDate"), "28.03.1985");
try {
RPSEngineengine = newRPSEngine(engineProvider,
newRPSEngineConverter(),
newRPSEngineContextResolver(null));
RequestContextrequestContext = engine
.createContext()
.withRequest(
newIRPSValue[]{rawFirstName, rawLastName, rawBirthDate},
adminRightsContext,
protectProcessingContext)
.withRequest(
newIRPSValue[]{protectedFirstName, protectedLastName, protectedBirthDate},
adminRightsContext,
deprotectProcessingContext);
// Calls the transformation API -> will lead to protect the datarequestContext.transform();
// Get the protected valuesSystem.out.println("Raw fist name. Original: " + rawFirstName.getOriginal() + ". Transformed: " + rawFirstName.getTransformed());
System.out.println("Raw last name. Original: " + rawLastName.getOriginal() + ". Transformed: " + rawLastName.getTransformed());
System.out.println("Raw birth date. Original: " + rawBirthDate.getOriginal() + ". Transformed: " + rawBirthDate.getTransformed());
System.out.println("Protected first name. Original: " + protectedFirstName.getOriginal() + ". Transformed: " + protectedFirstName.getTransformed());
System.out.println("Protected last name. Original: " + protectedLastName.getOriginal() + ". Transformed: " + protectedLastName.getTransformed());
System.out.println("Protected birth date. Original: " + protectedBirthDate.getOriginal() + ". Transformed: " + protectedBirthDate.getTransformed());
System.out.println();
} catch (Exceptione) {
e.printStackTrace();
}
}
}

About

Regdata RPS Engine Client library (Java)

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages