Skip to content

poc and masking incorporated #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 26 additions & 24 deletions src/main/java/samples/flex/coreServices/GenerateKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,54 @@
import Data.Configuration;
import Invokers.ApiClient;
import Invokers.ApiException;
import Model.GeneratePublicKeyRequest;
import Model.FlexV1KeysPost200Response ;
import Model.GeneratePublicKeyRequest;

public class GenerateKey {
private static String status=null;
private static String responseCode;
public static FlexV1KeysPost200Response response=null;
private static Properties merchantProp;
private FlexV1KeysPost200Response response=null;
private Properties merchantProp;

static GeneratePublicKeyRequest request;

private static GeneratePublicKeyRequest getRequest() {
private GeneratePublicKeyRequest request;
private GeneratePublicKeyRequest getRequest() {
request = new GeneratePublicKeyRequest();
request.encryptionType("RsaOaep256");
return request;

}

public static void main(String args[]) throws Exception {
process();
GenerateKey generateKey=new GenerateKey();
generateKey.process();
}


public static FlexV1KeysPost200Response process() throws Exception {

private FlexV1KeysPost200Response process() throws Exception {
String className=GenerateKey.class.getSimpleName();
System.out.println("[BEGIN] EXECUTION OF SAMPLE CODE: "+className+"\n");
ApiClient apiClient=null;
try {
request = getRequest();

/* Read Merchant details. */
merchantProp = Configuration.getMerchantDetails();
MerchantConfig merchantConfig = new MerchantConfig(merchantProp);
ApiClient apiClient = new ApiClient(merchantConfig);

KeyGenerationApi keyGenerationApi = new KeyGenerationApi();
KeyGenerationApi keyGenerationApi = new KeyGenerationApi(merchantConfig);
apiClient=Invokers.Configuration.getDefaultApiClient();
response = keyGenerationApi.generatePublicKey(request);

responseCode = ApiClient.responseCode;
status = ApiClient.status;

System.out.println("ResponseCode :" +responseCode);
System.out.println("Status :" +status);
System.out.println(response);

} catch (ApiException e) {

e.printStackTrace();
System.out.println("Exception on calling the Sample Code " +className+": "+apiClient.getRespBody()+"\n");
} finally {
System.out.println("API REQUEST HEADERS:");
System.out.println(apiClient.getRequestHeader() + "\n");
System.out.println("API REQUEST BODY:");
System.out.println(apiClient.getRequestBody() + "\n");
System.out.println("API RESPONSE CODE: " + apiClient.getResponseCode() + "\n");
System.out.println("API RESPONSE HEADERS:");
System.out.println(apiClient.getResponseHeader() + "\n");
System.out.println("API RESPONSE BODY:");
System.out.println(apiClient.getRespBody() + "\n");
System.out.println("[END] EXECUTION OF SAMPLE CODE:" + className + "\n");
}
return response;
}
Expand Down
57 changes: 30 additions & 27 deletions src/main/java/samples/flex/coreServices/TokenizeCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,26 @@
import samples.flex.tokenization.VerifyToken;

public class TokenizeCard {
private static String status = null;
private static String responseCode;
public static FlexV1TokensPost200Response response = null;
private FlexV1TokensPost200Response response;

private FlexV1KeysPost200Response keyResponse;

public static FlexV1KeysPost200Response keyResponse;
private static Properties merchantProp;


@SuppressWarnings("rawtypes")

static Map<?, ?> tokenMap = new HashMap();
private Map<?, ?> tokenMap = new HashMap();

static TokenizeRequest request;
private TokenizeRequest request;

private static TokenizeRequest getRequest() throws Exception {
private TokenizeRequest getRequest() throws Exception {
request = new TokenizeRequest();
keyResponse = KeyGenerationNoEnc.process();
KeyGenerationNoEnc keyGenerationNoEnc=new KeyGenerationNoEnc();
keyResponse = keyGenerationNoEnc.process();
if(keyResponse!=null){
request.keyId(keyResponse.getKeyId());

}
Flexv1tokensCardInfo cardInfo = new Flexv1tokensCardInfo();
cardInfo.cardNumber("5555555555554444");
cardInfo.cardExpirationMonth("03");
Expand All @@ -55,28 +56,28 @@ private static TokenizeRequest getRequest() throws Exception {
}

public static void main(String args[]) throws Exception {
process();
TokenizeCard tokenizeCard=new TokenizeCard();
tokenizeCard.process();
}

public static void process() throws Exception {

public void process() throws Exception {
String className=TokenizeCard.class.getSimpleName();
System.out.println("[BEGIN] EXECUTION OF SAMPLE CODE: "+className+"\n");
ApiClient apiClient=null;
try {
request = getRequest();

/* Read Merchant details. */
merchantProp = Configuration.getMerchantDetails();
MerchantConfig merchantConfig = new MerchantConfig(merchantProp);
ApiClient apiClient = new ApiClient(merchantConfig);

FlexTokenApi tokenizationApi = new FlexTokenApi();
FlexTokenApi tokenizationApi = new FlexTokenApi(merchantConfig);
apiClient=Invokers.Configuration.getDefaultApiClient();
response = tokenizationApi.tokenize(request);

byte[] publicBytes = Base64.decode(keyResponse.getDer().getPublicKey());
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(publicBytes);
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
PublicKey pubKey = keyFactory.generatePublic(keySpec);


FlexToken flexTokenResponseBody = new FlexToken();
flexTokenResponseBody.setKeyId(response.getKeyId());
flexTokenResponseBody.setToken(response.getToken());
Expand All @@ -92,17 +93,19 @@ public static void process() throws Exception {

VerifyToken verifyToken = new VerifyToken();
verifyToken.verify(pubKey, tokenMap);

responseCode = ApiClient.responseCode;
status = ApiClient.status;

System.out.println("ResponseCode :" +responseCode);
System.out.println("Status :" +status);
System.out.println("ResponseBody :"+ApiClient.respBody);

} catch (ApiException e) {

e.printStackTrace();
System.out.println("Exception on calling the Sample Code" +className+": "+apiClient.getRespBody()+"\n");
} finally {
System.out.println("API REQUEST HEADERS:");
System.out.println(apiClient.getRequestHeader()+ "\n");
System.out.println("API REQUEST BODY:");
System.out.println(apiClient.getRequestBody()+ "\n");
System.out.println("API RESPONSE CODE: " + apiClient.getResponseCode()+ "\n");
System.out.println("API RESPONSE HEADERS:");
System.out.println(apiClient.getResponseHeader()+ "\n");
System.out.println("API RESPONSE BODY:");
System.out.println(apiClient.getRespBody() + "\n");
System.out.println("[END] EXECUTION OF SAMPLE CODE: " + className+ "\n");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,52 @@
import Data.Configuration;
import Invokers.ApiClient;
import Invokers.ApiException;
import Model.GeneratePublicKeyRequest;
import Model.FlexV1KeysPost200Response;
import Model.GeneratePublicKeyRequest;

public class KeyGenerationNoEnc {
public static FlexV1KeysPost200Response response = null;
public static String keyId = null;
private static Properties merchantProp;
private FlexV1KeysPost200Response response;
private Properties merchantProp;

static GeneratePublicKeyRequest request;
private GeneratePublicKeyRequest request;

private static GeneratePublicKeyRequest getRequest() {
private GeneratePublicKeyRequest getRequest() {
request = new GeneratePublicKeyRequest();
request.encryptionType("None");
return request;

}

public static void main(String args[]) throws Exception {
process();
KeyGenerationNoEnc keyGenerationNoEnc=new KeyGenerationNoEnc();
keyGenerationNoEnc.process();
}

public static FlexV1KeysPost200Response process() throws Exception {

public FlexV1KeysPost200Response process() throws Exception {
String className=KeyGenerationNoEnc.class.getSimpleName();
System.out.println("[BEGIN] EXECUTION OF SAMPLE CODE: "+className+"\n");
ApiClient apiClient=null;
try {
request = getRequest();

/* Read Merchant details. */
merchantProp = Configuration.getMerchantDetails();
MerchantConfig merchantConfig = new MerchantConfig(merchantProp);
ApiClient apiClient = new ApiClient(merchantConfig);

KeyGenerationApi keyGenerationApi = new KeyGenerationApi();
KeyGenerationApi keyGenerationApi = new KeyGenerationApi(merchantConfig);
apiClient=Invokers.Configuration.getDefaultApiClient();
response = keyGenerationApi.generatePublicKey(request);

System.out.println(ApiClient.respBody);

} catch (ApiException e) {

e.printStackTrace();
System.out.println("Exception on calling the Sample Code" +className+": "+apiClient.getRespBody()+"\n");
} finally {
System.out.println("API REQUEST HEADERS:");
System.out.println(apiClient.getRequestHeader() + "\n");
System.out.println("API REQUEST BODY:");
System.out.println(apiClient.getRequestBody() + "\n");
System.out.println("API RESPONSE CODE: " + apiClient.getResponseCode() + "\n");
System.out.println("API RESPONSE HEADERS:");
System.out.println(apiClient.getResponseHeader() + "\n");
System.out.println("API RESPONSE BODY:");
System.out.println(apiClient.getRespBody() + "\n");
System.out.println("[END] EXECUTION OF SAMPLE CODE:" + className + "\n");
}
return response;
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/samples/flex/tokenization/VerifyToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ private static boolean validateTokenSignature(PublicKey publicKey, String signed
signInstance.initVerify(publicKey);
signInstance.update(signedFields.getBytes());
success = signInstance.verify(Base64.decode(signature));
System.out.println(success);
} catch (IOException e) {
throw new FlexEncodingException("Unable to decode signature"+ e);
} catch (GeneralSecurityException e) {
Expand Down
55 changes: 30 additions & 25 deletions src/main/java/samples/payments/coreServices/CapturePayment.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@

public class CapturePayment {

private static String responseCode = null;
private static String status = null;
public static PtsV2PaymentsPost201Response paymentResponse;
public static PtsV2PaymentsCapturesPost201Response response;
private static Properties merchantProp;
private PtsV2PaymentsPost201Response paymentResponse;
private PtsV2PaymentsCapturesPost201Response response;
private Properties merchantProp;
private CapturePaymentRequest request;

static CapturePaymentRequest request;

private static CapturePaymentRequest getRequest() {
private CapturePaymentRequest getRequest() {
request = new CapturePaymentRequest();

Ptsv2paymentsClientReferenceInformation client = new Ptsv2paymentsClientReferenceInformation();
Expand Down Expand Up @@ -61,32 +58,40 @@ private static CapturePaymentRequest getRequest() {
}

public static void main(String args[]) throws Exception {
process();
CapturePayment capturePayment=new CapturePayment();
capturePayment.process();
}

public static PtsV2PaymentsCapturesPost201Response process() throws Exception {

public PtsV2PaymentsCapturesPost201Response process() throws Exception {
String className=CapturePayment.class.getSimpleName();
System.out.println("[BEGIN] EXECUTION OF SAMPLE CODE: "+className+"\n");
ApiClient apiClient=new ApiClient();
try {
request = getRequest();
/* Read Merchant details. */
merchantProp = Configuration.getMerchantDetails();
MerchantConfig merchantConfig = new MerchantConfig(merchantProp);
ApiClient apiClient = new ApiClient(merchantConfig);
ProcessPayment processPayment = new ProcessPayment();
paymentResponse = processPayment.process(Boolean.FALSE);

paymentResponse = ProcessPayment.process(false);
CaptureApi captureApi = new CaptureApi();
response = captureApi.capturePayment(request, paymentResponse.getId());

responseCode = ApiClient.responseCode;
status = ApiClient.status;

System.out.println("ResponseCode :" + responseCode);
System.out.println("Status :" + status);
System.out.println(response);

if (paymentResponse != null) {
CaptureApi captureApi = new CaptureApi(merchantConfig);
apiClient=Invokers.Configuration.getDefaultApiClient();
response = captureApi.capturePayment(request, paymentResponse.getId());
}
} catch (ApiException e) {

e.printStackTrace();
System.out.println("Exception on calling the Sample Code " +className+": "+apiClient.getRespBody()+"\n");
} finally {
System.out.println("API REQUEST HEADERS:");
System.out.println(apiClient.getRequestHeader() + "\n");
System.out.println("API REQUEST BODY:");
System.out.println(apiClient.getRequestBody() + "\n");
System.out.println("API RESPONSE CODE: " + apiClient.getResponseCode() + "\n");
System.out.println("API RESPONSE HEADERS:");
System.out.println(apiClient.getResponseHeader() + "\n");
System.out.println("API RESPONSE BODY:");
System.out.println(apiClient.getRespBody() + "\n");
System.out.println("[END] EXECUTION OF SAMPLE CODE:" + className + "\n");
}
return response;
}
Expand Down
Loading