import LPA library implementation from TruPhone

Converted to gradle build and updated a bunch of dependencies.
master
Peter Cai 2022-04-29 18:05:10 -04:00
parent 93f1d1baf1
commit 9ca4ce2798
100 changed files with 7773 additions and 4 deletions

1
.gitignore vendored
View File

@ -13,3 +13,4 @@
.externalNativeBuild
.cxx
local.properties
/libs/**/build

View File

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
<bytecodeTargetLevel target="1.8">
<module name="OpenEUICC.app" target="11" />
</bytecodeTargetLevel>
</component>
</project>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
@ -11,6 +12,8 @@
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/libs" />
<option value="$PROJECT_DIR$/libs/lpad-sm-dp-plus-connector" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@ -32,7 +32,7 @@ android {
}
dependencies {
implementation project(":libs:lpad-sm-dp-plus-connector")
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="target/generated-sources/asn1">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>lpad-sm-dp-plus-connector</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,6 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//target/generated-sources/asn1=UTF-8
encoding/<project>=UTF-8

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=false

View File

@ -0,0 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=11

View File

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

View File

@ -0,0 +1,36 @@
apply plugin: 'java'
configurations {
tool
}
dependencies {
tool 'javax.xml.bind:jaxb-api:2.3.0'
tool 'com.beanit:asn1bean-compiler:1.13.0'
implementation 'com.beanit:asn1bean:1.13.0'
implementation 'com.fazecast:jSerialComm:1.3.11'
implementation 'org.apache.commons:commons-lang3:3.7'
implementation 'commons-io:commons-io:2.6'
implementation 'commons-codec:commons-codec:1.11'
implementation 'com.google.code.gson:gson:2.8.4'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-all:1.10.19'
testImplementation 'com.github.tomakehurst:wiremock:2.17.0'
}
sourceSets.main.java.srcDirs = ['build/generated-sources/asn1','src/main/java']
task genAsn1(type: JavaExec) {
mainClass = 'com.beanit.asn1bean.compiler.Compiler'
args "-o", "$projectDir/build/generated-sources/asn1", "-p", "com.truphone.rsp.dto.asn1", "-f", "$projectDir/src/main/resources/PKIXExplicit88.asn", "$projectDir/src/main/resources/PKIXImplicit88.asn", "$projectDir/src/main/resources/rsp.asn"
classpath configurations.tool
}
compileJava.dependsOn genAsn1
description = 'LPAd SM-DP+ Connector'
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>lpad-sm-dp-plus-parent</artifactId>
<groupId>com.truphone.lpad</groupId>
<version>1.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>lpad-sm-dp-plus-connector</artifactId>
<name>LPAd SM-DP+ Connector</name>
<dependencies>
<dependency>
<groupId>org.openmuc</groupId>
<artifactId>jasn1-compiler</artifactId>
</dependency>
<dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerVersion>${java.version}</compilerVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<mainClass>org.openmuc.jasn1.compiler.Compiler</mainClass>
<arguments>
<argument>-o</argument>
<argument>${project.basedir}/target/generated-sources/asn1/</argument>
<argument>-p</argument>
<argument>com.truphone.rsp.dto.asn1</argument>
<argument>-f</argument>
<argument>${project.basedir}/src/main/resources/PKIXExplicit88.asn</argument>
<argument>${project.basedir}/src/main/resources/PKIXImplicit88.asn</argument>
<argument>${project.basedir}/src/main/resources/rsp.asn</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build-helper-maven-plugin}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/target/generated-sources/asn1/</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.truphone.lpa.ProfileAssistant</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin.version}</version>
<configuration>
<archive>
<manifest>
<mainClass>com.truphone.lpa.ProfileAssistant</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,59 @@
package com.truphone.es9plus;
public class AllocateProfileResponse {
private String acFormat;
private String smDpPlusAddress;
private String acToken;
private String smDpPlusOid;
private String confirmationCodeRequiredFlag;
public String getAcFormat() {
return acFormat;
}
public void setAcFormat(String acFormat) {
this.acFormat = acFormat;
}
public String getSmDpPlusAddress() {
return smDpPlusAddress;
}
public void setSmDpPlusAddress(String smDpPlusAddress) {
this.smDpPlusAddress = smDpPlusAddress;
}
public String getAcToken() {
return acToken;
}
public void setAcToken(String acToken) {
this.acToken = acToken;
}
public String getSmDpPlusOid() {
return smDpPlusOid;
}
public void setSmDpPlusOid(String smDpPlusOid) {
this.smDpPlusOid = smDpPlusOid;
}
public String getConfirmationCodeRequiredFlag() {
return confirmationCodeRequiredFlag;
}
public void setConfirmationCodeRequiredFlag(String confirmationCodeRequiredFlag) {
this.confirmationCodeRequiredFlag = confirmationCodeRequiredFlag;
}
}

View File

@ -0,0 +1,216 @@
package com.truphone.es9plus;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.truphone.es9plus.message.request.AuthenticateClientReq;
import com.truphone.es9plus.message.request.GetBoundProfilePackageReq;
import com.truphone.es9plus.message.request.HandleNotificationReq;
import com.truphone.es9plus.message.request.InitiateAuthenticationReq;
import com.truphone.es9plus.message.response.AuthenticateClientResp;
import com.truphone.es9plus.message.response.GetBoundProfilePackageResp;
import com.truphone.es9plus.message.response.InitiateAuthenticationResp;
import com.truphone.util.LogStub;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Es9PlusImpl {
private static final Gson GS = new GsonBuilder().disableHtmlEscaping().create();
private static final Logger LOG = Logger.getLogger(Es9PlusImpl.class.getName());
private static final String INITIATE_AUTHENTICATION_PATH = "/gsma/rsp2/es9plus/initiateAuthentication";
private static final String AUTHENTICATE_CLIENT_PATH = "/gsma/rsp2/es9plus/authenticateClient";
private static final String GET_BOUND_PROFILE_PACKAGE_PATH = "/gsma/rsp2/es9plus/getBoundProfilePackage";
private static final String HANDLE_NOTIFICATION_PATH = "/gsma/rsp2/es9plus/handleNotification";
//private static final String ALLOCATE_PROFILE_PATH = "/custom/profile/";
// private String rspServerUrl;
// public void configure(String rspServerUrl) {
//
// this.rspServerUrl = rspServerUrl;
// }
public InitiateAuthenticationResp initiateAuthentication(final String euiccChallenge,
final String euiccInfo1,
final String smdpAddress) {
try {
InitiateAuthenticationReq initiateAuthenticationReq = new InitiateAuthenticationReq();
initiateAuthenticationReq.setEuiccChallenge(euiccChallenge);
initiateAuthenticationReq.setEuiccInfo1(euiccInfo1);
initiateAuthenticationReq.setSmdpAddress(smdpAddress);
String body = GS.toJson(initiateAuthenticationReq);
if (LogStub.getInstance().isDebugEnabled()) {
LogStub.getInstance().logDebug(LOG, "RSP Request: " + body);
}
HttpResponse result = new HttpRSPClient().clientRSPRequest(body, "https://"+smdpAddress, INITIATE_AUTHENTICATION_PATH);
if (result != null && !"".equals(result.getContent())) {
String response = toJsonString(result.getContent());
if (LogStub.getInstance().isDebugEnabled()) {
LogStub.getInstance().logDebug(LOG, "RSP Response: " + response);
}
return GS.fromJson(response, InitiateAuthenticationResp.class);
}
} catch (Exception e) {
LOG.log(Level.SEVERE, "Error contacting RSP Server", e);
throw new RuntimeException("Unable to communicate with RSP Server");
}
return null;
}
public AuthenticateClientResp authenticateClient(final String transactionId,
final String authenticateServerResponse,
final String smdpAddress) {
try {
AuthenticateClientReq authenticateClientReq = new AuthenticateClientReq();
authenticateClientReq.setTransactionId(transactionId);
authenticateClientReq.setAuthenticateServerResponse(authenticateServerResponse);
String body = GS.toJson(authenticateClientReq);
if (LogStub.getInstance().isDebugEnabled()) {
LogStub.getInstance().logDebug(LOG, "RSP Request: " + body);
}
HttpResponse result = new HttpRSPClient().clientRSPRequest(body, "https://" + smdpAddress, AUTHENTICATE_CLIENT_PATH);
if (result != null && !"".equals(result.getContent())) {
String response = toJsonString(result.getContent());
if (LogStub.getInstance().isDebugEnabled()) {
LogStub.getInstance().logDebug(LOG, "RSP Response: " + response);
}
return GS.fromJson(response, AuthenticateClientResp.class);
} else {
LOG.severe("Error contacting RSP Server");
throw new RuntimeException("Unable to communicate with RSP Server");
}
} catch (Exception e) {
LOG.log(Level.SEVERE, "Error contacting RSP Server", e);
throw new RuntimeException("Unable to communicate with RSP Server");
}
}
public GetBoundProfilePackageResp getBoundProfilePackage(final String transactionId,
final String prepareDownloadResponse,
final String smdpAddress) {
try {
GetBoundProfilePackageReq getBoundProfilePackageReq = new GetBoundProfilePackageReq();
getBoundProfilePackageReq.setTransactionId(transactionId);
getBoundProfilePackageReq.setPrepareDownloadResponse(prepareDownloadResponse);
String body = GS.toJson(getBoundProfilePackageReq);
if (LogStub.getInstance().isDebugEnabled()) {
LogStub.getInstance().logDebug(LOG, "RSP Request: " + body);
}
HttpResponse result = new HttpRSPClient().clientRSPRequest(body, "https://" + smdpAddress, GET_BOUND_PROFILE_PACKAGE_PATH);
if (result != null && !"".equals(result.getContent())) {
String response = toJsonString(result.getContent());
if (LogStub.getInstance().isDebugEnabled()) {
LogStub.getInstance().logDebug(LOG, "RSP Response: " + response);
}
return GS.fromJson(response, GetBoundProfilePackageResp.class);
}
} catch (Exception e) {
LOG.log(Level.SEVERE, "Error contacting RSP Server", e);
throw new RuntimeException("Unable to communicate with RSP Server");
}
return null;
}
/**
* ES9+.handleNotification
*/
public void handleNotification(final String pendingNotification, String serverAddress) {
try {
HandleNotificationReq handleNotificationReq = new HandleNotificationReq();
handleNotificationReq.setPendingNotification(pendingNotification);
String body = GS.toJson(handleNotificationReq);
if (LogStub.getInstance().isDebugEnabled()) {
LogStub.getInstance().logDebug(LOG, "RSP Request: " + body);
}
HttpResponse result = new HttpRSPClient().clientRSPRequest(body, "https://"+serverAddress, HANDLE_NOTIFICATION_PATH);
if (result != null && result.getStatusCode() == 204) {
if (LogStub.getInstance().isDebugEnabled()) {
LogStub.getInstance().logDebug(LOG, "RSP Response was 204 ");
}
} else {
LOG.severe("Error contacting RSP Server or not 204: " + result);
throw new RuntimeException("Unable to handle notification with RSP Server");
}
} catch (Exception e) {
LOG.log(Level.SEVERE, "Error contacting RSP Server", e);
throw new RuntimeException("Unable to handle notification with RSP Server");
}
}
// public AllocateProfileResponse allocateProfile(final String eid,
// final String mcc) {
//
// try {
// String body = "eid=" + eid + "&mcc=" + mcc;
//
// if (LogStub.getInstance().isDebugEnabled()) {
// LogStub.getInstance().logDebug(LOG, "RSP Request: " + body);
// }
//
// HttpResponse result = new HttpRSPClient().clientSimpleRequest(body, rspServerUrl, ALLOCATE_PROFILE_PATH);
//
// if (result != null && !"".equals(result.getContent())) {
// if (LogStub.getInstance().isDebugEnabled()) {
// LogStub.getInstance().logDebug(LOG, "RSP Response: " + result);
// }
//
// return getAllocateProfileResponse(result.getContent());
// } else {
// throw new RuntimeException("No profile could be allocated");
// }
// } catch (Exception e) {
// LOG.log(Level.SEVERE, e.getMessage(), e);
//
// throw new RuntimeException("Unable to allocate profile with RSP Server");
// }
// }
private AllocateProfileResponse getAllocateProfileResponse(final String content) {
AllocateProfileResponse allocateProfileResponse = null;
String fixedContent = content != null ? (content.startsWith("$") ? content.substring(1) : content) : "";
String[] responseTokens = fixedContent.split("\\$");
if (responseTokens.length > 1) {
allocateProfileResponse = new AllocateProfileResponse();
allocateProfileResponse.setAcFormat(responseTokens[0]);
allocateProfileResponse.setSmDpPlusAddress(responseTokens[1]);
allocateProfileResponse.setAcToken(responseTokens.length > 2 ? responseTokens[2] : "");
allocateProfileResponse.setSmDpPlusOid(responseTokens.length > 3 ? responseTokens[3] : null);
allocateProfileResponse.setConfirmationCodeRequiredFlag(responseTokens.length > 4 ? responseTokens[4] : null);
}
return allocateProfileResponse;
}
private String toJsonString(final String msg) {
int index = msg.indexOf("{");
return msg.substring(index);
}
}

View File

@ -0,0 +1,122 @@
package com.truphone.es9plus;
import com.truphone.util.LogStub;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.BufferedWriter;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;
public class HttpRSPClient {
private static final Logger LOG = Logger.getLogger(HttpRSPClient.class.getName());
public HttpResponse clientRSPRequest(final String body,
final String rspServerUrl,
final String url) throws Exception {
Pair<String, String> contentType = new Pair<>("Content-Type", "application/json");
Pair<String, String> accept = new Pair<>("Accept", "application/json");
Pair<String, String> userAgent = new Pair<>("User-Agent", "gsma-rsp-com.truphone.lpad");
Pair<String, String> xAdminProtocol = new Pair<>("X-Admin-Protocol", "gsma/rsp/v2.2.0");
return invoke("POST", body, rspServerUrl, url, Arrays.asList(contentType, accept, userAgent, xAdminProtocol));
}
public HttpResponse clientSimpleRequest(final String body,
final String rspServerUrl,
final String url) throws Exception {
Pair<String, String> contentType = new Pair<>("Content-type", "application/x-www-form-urlencoded");
Pair<String, String> userAgent = new Pair<>("User-Agent", "gsma-rsp-com.truphone.lpad");
Pair<String, String> xAdminProtocol = new Pair<>("X-Admin-Protocol", "gsma/rsp/v2.2.0");
if (LogStub.getInstance().isDebugEnabled()) {
LogStub.getInstance().logDebug(LOG, LogStub.getInstance().getTag() + " - HttpRSPClient - clientSimpleRequest parameters - body : " +
body + " rspServerUrl:" + rspServerUrl + " contentType: " + contentType + " user agent: " + userAgent +
" xAdminProtocol: " + xAdminProtocol + " url: " + url);
}
return invoke("POST", body, rspServerUrl, url, Arrays.asList(contentType, userAgent, xAdminProtocol));
}
private HttpResponse invoke(final String method,
final String body,
final String rspServerUrl,
final String url,
final List<Pair<String, String>> headers) throws Exception {
StringBuilder endpoint = new StringBuilder(rspServerUrl);
HttpResponse httpResponse = new HttpResponse();
if (StringUtils.isNotBlank(url)) {
endpoint.append(url);
}
if (LogStub.getInstance().isDebugEnabled()) {
LogStub.getInstance().logDebug(LOG, LogStub.getInstance().getTag() + " - HttpRSPClient - invoke URL: " + endpoint.toString());
}
URL urlResource = new URL(endpoint.toString());
HttpURLConnection con = (HttpURLConnection) urlResource.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setRequestMethod(method);
con.setConnectTimeout(600000);
con.setReadTimeout(600000);
if (headers != null) {
for (Pair<String, String> header : headers) {
con.setRequestProperty(header.getKey(), header.getValue());
}
}
OutputStream os = con.getOutputStream();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
writer.write(body);
writer.flush();
writer.close();
os.close();
httpResponse.setStatusCode(con.getResponseCode());
httpResponse.setContent(IOUtils.toString(con.getInputStream(), StandardCharsets.UTF_8));
return httpResponse;
}
private class Pair<T, E> {
private T key;
private E value;
public Pair(T key, E value) {
this.key = key;
this.value = value;
}
public T getKey() {
return key;
}
public void setKey(T key) {
this.key = key;
}
public E getValue() {
return value;
}
public void setValue(E value) {
this.value = value;
}
}
}

View File

@ -0,0 +1,26 @@
package com.truphone.es9plus;
public class HttpResponse {
private String content;
private int statusCode;
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public int getStatusCode() {
return statusCode;
}
public void setStatusCode(int statusCode) {
this.statusCode = statusCode;
}
}

View File

@ -0,0 +1,10 @@
package com.truphone.es9plus;
public class LpaUtils {
public static String generateCtxParams1() {
return "";
}
}

View File

@ -0,0 +1,4 @@
package com.truphone.es9plus.message;
public interface MsgBody {
}

View File

@ -0,0 +1,12 @@
package com.truphone.es9plus.message;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface MsgType {
String value();
}

View File

@ -0,0 +1,28 @@
package com.truphone.es9plus.message.request;
import com.truphone.es9plus.message.MsgType;
import com.truphone.es9plus.message.request.base.RequestMsgBody;
@MsgType("/gsma/rsp2/es9plus/authenticateClient")
public class AuthenticateClientReq extends RequestMsgBody {
private String transactionId;
private String authenticateServerResponse;
public String getTransactionId() {
return transactionId;
}
public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
public String getAuthenticateServerResponse() {
return authenticateServerResponse;
}
public void setAuthenticateServerResponse(String authenticateServerResponse) {
this.authenticateServerResponse = authenticateServerResponse;
}
}

View File

@ -0,0 +1,37 @@
package com.truphone.es9plus.message.request;
import com.truphone.es9plus.message.MsgType;
import com.truphone.es9plus.message.request.base.RequestMsgBody;
@MsgType("/gsma/rsp2/es9plus/cancelSession")
public class CancelSessionReq extends RequestMsgBody {
private String transactionId;
private String euiccCancelSessionSigned;
private String euiccCancelSessionSignature;
public String getTransactionId() {
return transactionId;
}
public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
public String getEuiccCancelSessionSigned() {
return euiccCancelSessionSigned;
}
public void setEuiccCancelSessionSigned(String euiccCancelSessionSigned) {
this.euiccCancelSessionSigned = euiccCancelSessionSigned;
}
public String getEuiccCancelSessionSignature() {
return euiccCancelSessionSignature;
}
public void setEuiccCancelSessionSignature(String euiccCancelSessionSignature) {
this.euiccCancelSessionSignature = euiccCancelSessionSignature;
}
}

View File

@ -0,0 +1,53 @@
package com.truphone.es9plus.message.request;
import com.truphone.es9plus.message.MsgType;
import com.truphone.es9plus.message.request.base.RequestMsgBody;
@MsgType("/gsma/rsp2/es2plus/confirmOrder")
public class ConfirmOrderReq extends RequestMsgBody {
private String iccid;
private String eid;
private String matchingId;
private String comfirmationCode;
private String smdsAddress;
private boolean releaseFlag;
public String getIccid() {
return iccid;
}
public void setIccid(String iccid) {
this.iccid = iccid;
}
public String getEid() {
return eid;
}
public void setEid(String eid) {
this.eid = eid;
}
public String getMatchingId() {
return matchingId;
}
public void setMatchingId(String matchingId) {
this.matchingId = matchingId;
}
public String getComfirmationCode() {
return comfirmationCode;
}
public void setComfirmationCode(String comfirmationCode) {
this.comfirmationCode = comfirmationCode;
}
public String getSmdsAddress() {
return smdsAddress;
}
public void setSmdsAddress(String smdsAddress) {
this.smdsAddress = smdsAddress;
}
public boolean getReleaseFlag() {
return releaseFlag;
}
public void setReleaseFlag(boolean releaseFlag) {
this.releaseFlag = releaseFlag;
}
}

View File

@ -0,0 +1,45 @@
package com.truphone.es9plus.message.request;
import com.truphone.es9plus.message.MsgType;
import com.truphone.es9plus.message.request.base.RequestMsgBody;
@MsgType("/gsma/rsp2/es2plus/downloadOrder")
public class DownloadOrderReq extends RequestMsgBody {
private String eid;
private String iccid;
private String profileType;
private String msisdn;
public String getMsisdn() {
return msisdn;
}
public void setMsisdn(String msisdn) {
this.msisdn = msisdn;
}
public String getEid() {
return eid;
}
public void setEid(String eid) {
this.eid = eid;
}
public String getIccid() {
return iccid;
}
public void setIccid(String iccid) {
this.iccid = iccid;
}
public String getProfileType() {
return profileType;
}
public void setProfileType(String profileType) {
this.profileType = profileType;
}
}

View File

@ -0,0 +1,28 @@
package com.truphone.es9plus.message.request;
import com.truphone.es9plus.message.MsgType;
import com.truphone.es9plus.message.request.base.RequestMsgBody;
@MsgType("/gsma/rsp2/es9plus/getBoundProfilePackage")
public class GetBoundProfilePackageReq extends RequestMsgBody {
private String transactionId;
private String prepareDownloadResponse;
public String getTransactionId() {
return transactionId;
}
public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
public String getPrepareDownloadResponse() {
return prepareDownloadResponse;
}
public void setPrepareDownloadResponse(String prepareDownloadResponse) {
this.prepareDownloadResponse = prepareDownloadResponse;
}
}

View File

@ -0,0 +1,74 @@
package com.truphone.es9plus.message.request;
import com.truphone.es9plus.message.MsgType;
import com.truphone.es9plus.message.request.base.RequestMsgBody;
import java.util.Date;
@MsgType("/gsma/rsp2/es2plus/handleDownloadProgressInfo")
public class HandleDownloadProgressInfoReq extends RequestMsgBody {
private String eid;
private String iccid;
private String profileType;
private Date timestamp;
private int notificationPointId;
private String notificationPointStatus;
private String resultData;
public String getEid() {
return eid;
}
public void setEid(String eid) {
this.eid = eid;
}
public String getIccid() {
return iccid;
}
public void setIccid(String iccid) {
this.iccid = iccid;
}
public String getProfileType() {
return profileType;
}
public void setProfileType(String profileType) {
this.profileType = profileType;
}
public Date getTimestamp() {
return timestamp;
}
public void setTimestamp(Date timestamp) {
this.timestamp = timestamp;
}
public int getNotificationPointId() {
return notificationPointId;
}
public void setNotificationPointId(int notificationPointId) {
this.notificationPointId = notificationPointId;
}
public String getNotificationPointStatus() {
return notificationPointStatus;
}
public void setNotificationPointStatus(String notificationPointStatus) {
this.notificationPointStatus = notificationPointStatus;
}
public String getResultData() {
return resultData;
}
public void setResultData(String resultData) {
this.resultData = resultData;
}
}

View File

@ -0,0 +1,19 @@
package com.truphone.es9plus.message.request;
import com.truphone.es9plus.message.MsgType;
import com.truphone.es9plus.message.request.base.RequestMsgBody;
@MsgType("/gsma/rsp2/es9plus/handleNotification")
public class HandleNotificationReq extends RequestMsgBody {
private String pendingNotification;
public String getPendingNotification() {
return pendingNotification;
}
public void setPendingNotification(String pendingNotification) {
this.pendingNotification = pendingNotification;
}
}

View File

@ -0,0 +1,37 @@
package com.truphone.es9plus.message.request;
import com.truphone.es9plus.message.MsgType;
import com.truphone.es9plus.message.request.base.RequestMsgBody;
@MsgType("/gsma/rsp2/es9plus/initiateAuthentication")
public class InitiateAuthenticationReq extends RequestMsgBody {
private String euiccChallenge;
private String euiccInfo1;
private String smdpAddress;
public String getEuiccChallenge() {
return euiccChallenge;
}
public void setEuiccChallenge(String euiccChallenge) {
this.euiccChallenge = euiccChallenge;
}
public String getEuiccInfo1() {
return euiccInfo1;
}
public void setEuiccInfo1(String euiccInfo1) {
this.euiccInfo1 = euiccInfo1;
}
public String getSmdpAddress() {
return smdpAddress;
}
public void setSmdpAddress(String smdpAddress) {
this.smdpAddress = smdpAddress;
}
}

View File

@ -0,0 +1,19 @@
package com.truphone.es9plus.message.request;
import com.truphone.es9plus.message.MsgType;
import com.truphone.es9plus.message.request.base.RequestMsgBody;
@MsgType("/gsma/rsp2/es2plus/releaseProfile")
public class ReleaseProfileReq extends RequestMsgBody {
private String iccid;
public String getIccid() {
return iccid;
}
public void setIccid(String iccid) {
this.iccid = iccid;
}
}

View File

@ -0,0 +1,12 @@
package com.truphone.es9plus.message.request.base;
import com.truphone.es9plus.message.MsgBody;
import java.security.InvalidParameterException;
public abstract class RequestMsgBody implements MsgBody {
public void checkParameters() throws InvalidParameterException {
}
}

View File

@ -0,0 +1,63 @@
package com.truphone.es9plus.message.response;
import com.truphone.es9plus.message.response.base.ResponseMsgBody;
public class AuthenticateClientResp extends ResponseMsgBody {
private String transactionID;
private String profileMetadata;
private String smdpSigned2;
private String smdpSignature2;
private String smdpCertificate;
public String getTransactionID() {
return transactionID;
}
public void setTransactionID(String transactionID) {
this.transactionID = transactionID;
}
public String getProfileMetadata() {
return profileMetadata;
}
public void setProfileMetadata(String profileMetadata) {
this.profileMetadata = profileMetadata;
}
public String getSmdpSigned2() {
return smdpSigned2;
}
public void setSmdpSigned2(String smdpSigned2) {
this.smdpSigned2 = smdpSigned2;
}
public String getSmdpSignature2() {
return smdpSignature2;
}
public void setSmdpSignature2(String smdpSignature2) {
this.smdpSignature2 = smdpSignature2;
}
public String getSmdpCertificate() {
return smdpCertificate;
}
public void setSmdpCertificate(String smdpCertificate) {
this.smdpCertificate = smdpCertificate;
}
@Override
public String toString() {
return "AuthenticateClientResp{" +
"transactionID='" + transactionID + '\'' +
", profileMetadata='" + profileMetadata + '\'' +
", smdpSigned2='" + smdpSigned2 + '\'' +
", smdpSignature2='" + smdpSignature2 + '\'' +
", smdpCertificate='" + smdpCertificate + '\'' +
'}';
}
}

View File

@ -0,0 +1,8 @@
package com.truphone.es9plus.message.response;
import com.truphone.es9plus.message.response.base.ResponseMsgBody;
public class CancelSessionResp extends ResponseMsgBody {
}

View File

@ -0,0 +1,34 @@
package com.truphone.es9plus.message.response;
import com.truphone.es9plus.message.response.base.ResponseMsgBody;
public class ConfirmOrderResp extends ResponseMsgBody {
private String eid;
private String matchingId;
private String smdpAddress;
public String getEid() {
return eid;
}
public void setEid(String eid) {
this.eid = eid;
}
public String getMatchingId() {
return matchingId;
}
public void setMatchingId(String matchingId) {
this.matchingId = matchingId;
}
public String getSmdpAddress() {
return smdpAddress;
}
public void setSmdpAddress(String smdpAddress) {
this.smdpAddress = smdpAddress;
}
}

View File

@ -0,0 +1,17 @@
package com.truphone.es9plus.message.response;
import com.truphone.es9plus.message.response.base.ResponseMsgBody;
public class DownloadOrderResp extends ResponseMsgBody {
private String iccid;
public String getIccid() {
return iccid;
}
public void setIccid(String iccid) {
this.iccid = iccid;
}
}

View File

@ -0,0 +1,26 @@
package com.truphone.es9plus.message.response;
import com.truphone.es9plus.message.response.base.ResponseMsgBody;
public class GetBoundProfilePackageResp extends ResponseMsgBody {
private String transactionID;
private String boundProfilePackage;
public String getTransactionID() {
return transactionID;
}
public void setTransactionID(String transactionID) {
this.transactionID = transactionID;
}
public String getBoundProfilePackage() {
return boundProfilePackage;
}
public void setBoundProfilePackage(String boundProfilePackage) {
this.boundProfilePackage = boundProfilePackage;
}
}

View File

@ -0,0 +1,8 @@
package com.truphone.es9plus.message.response;
import com.truphone.es9plus.message.response.base.ResponseMsgBody;
public class HandleDownloadProgressInfoResp extends ResponseMsgBody {
}

View File

@ -0,0 +1,8 @@
package com.truphone.es9plus.message.response;
import com.truphone.es9plus.message.response.base.ResponseMsgBody;
public class HandleNotificationResp extends ResponseMsgBody {
}

View File

@ -0,0 +1,64 @@
package com.truphone.es9plus.message.response;
import com.truphone.es9plus.message.response.base.ResponseMsgBody;
public class InitiateAuthenticationResp extends ResponseMsgBody {
private String transactionId;
private String serverSigned1;
private String serverSignature1;
private String euiccCiPKIdToBeUsed;
private String serverCertificate;
public String getTransactionId() {
return transactionId;
}
public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
public String getServerSigned1() {
return serverSigned1;
}
public void setServerSigned1(String serverSigned1) {
this.serverSigned1 = serverSigned1;
}
public String getServerSignature1() {
return serverSignature1;
}
public void setServerSignature1(String serverSignature1) {
this.serverSignature1 = serverSignature1;
}
public String getEuiccCiPKIdToBeUsed() {
return euiccCiPKIdToBeUsed;
}
public void setEuiccCiPKIdToBeUsed(String euiccCiPKIdToBeUsed) {
this.euiccCiPKIdToBeUsed = euiccCiPKIdToBeUsed;
}
public String getServerCertificate() {
return serverCertificate;
}
public void setServerCertificate(String serverCertificate) {
this.serverCertificate = serverCertificate;
}
@Override
public String toString() {
return "InitiateAuthenticationResp{" +
"transactionId='" + transactionId + '\'' +
", serverSigned1='" + serverSigned1 + '\'' +
", serverSignature1='" + serverSignature1 + '\'' +
", euiccCiPKIdToBeUsed='" + euiccCiPKIdToBeUsed + '\'' +
", serverCertificate='" + serverCertificate + '\'' +
'}';
}
}