diff --git a/README.md b/README.md index 867f62a..d932dae 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,25 @@ The method will return Status `OK` on success and `FLOW_ERROR` if the SDK was no This method will populate the provided list with all the backends known to the SDK. The method will return Status `OK` on success and `FLOW_ERROR` if the SDK was not initialized. +##### `Status GetServiceDetails(String url, ServiceDetails serviceDetails)` +This method is provided for applications working with the _MIRACL MFA Platform_. +After scanning a QR Code from the platform login page, the app should extract the URL from it and call this method to retreive the service details. +The service details include the _backend URL_ which needs to be set back to the SDK in order connect it to the platform. +This method could be called even before the SDK has been initialized, or alternatively the SDK could be initialized without setting a backend, and `SetBackend()` could be used after the backend URL has been retreived through this method. +The returned `ServiceDetails` look as follows: +```java +public class ServiceDetails { + public String name; + public String backendUrl; + public String rpsPrefix; + public String logoUrl; +} + ``` +* `name` is the service readable name +* `backendUrl` is the URL of the service backend. This URL has to be set either via the SDK `Init()` method or using `SetBackend()` +* `rpsPrefix` is RPS prefix setting which is also provided together with `backendUrl` while setting a backend +* `logoUrl` is the URL of the service logo. The logo is a UI element that could be used by the app. + ##### `Status GetSessionDetails(String accessCode, SessionDetails sessionDetails)` This method could be optionally used to retrieve details regarding a browser session when the SDK is used to authenticate users to an online service, such as the _MIRACL MFA Platform_. In this case an `accessCode` is transferred to the mobile device out-of-band e.g. via scanning a graphical code. The code is then provided to this method to get the session details. diff --git a/build.gradle b/build.gradle index aff4f41..74b2ab0 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.2' + classpath 'com.android.tools.build:gradle:2.2.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle.properties b/gradle.properties index 7a3edec..887bdac 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,7 +16,7 @@ # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME=1.4-SNAPSHOT +VERSION_NAME=1.5-SNAPSHOT GROUP=com.miracl RELEASE_REPOSITORY_URL=http://10.10.23.15:8081/content/repositories/mpinsdk/ SNAPSHOT_REPOSITORY_URL=http://10.10.23.15:8081/content/repositories/mpinsdk-snapshot/ diff --git a/mpin-sdk-core b/mpin-sdk-core index 16308c7..807c293 160000 --- a/mpin-sdk-core +++ b/mpin-sdk-core @@ -1 +1 @@ -Subproject commit 16308c7491f524e711fa87dbafc95724a4df6189 +Subproject commit 807c2938c465a85b91b642cfae107b6f9236096d diff --git a/mpinsdk/src/main/java/com/miracl/mpinsdk/MPinSDK.java b/mpinsdk/src/main/java/com/miracl/mpinsdk/MPinSDK.java index acd794b..e440fe4 100644 --- a/mpinsdk/src/main/java/com/miracl/mpinsdk/MPinSDK.java +++ b/mpinsdk/src/main/java/com/miracl/mpinsdk/MPinSDK.java @@ -22,6 +22,7 @@ import android.content.Context; import com.miracl.mpinsdk.model.OTP; +import com.miracl.mpinsdk.model.ServiceDetails; import com.miracl.mpinsdk.model.SessionDetails; import com.miracl.mpinsdk.model.Status; import com.miracl.mpinsdk.model.User; @@ -159,6 +160,10 @@ public Status GetSessionDetails(String accessCode, SessionDetails sessionDetails return nGetSessionDetails(mPtr, accessCode, sessionDetails); } + public Status GetServiceDetails(String url, ServiceDetails serviceDetails) { + return nGetServiceDetails(mPtr, url, serviceDetails); + } + public void DeleteUser(User user) { nDeleteUser(mPtr, user); } @@ -242,6 +247,8 @@ private native Status nInitWithCustomHeaders(long ptr, Map confi private native Status nGetSessionDetails(long ptr, String accessCode, SessionDetails sessionDetails); + private native Status nGetServiceDetails(long ptr, String url, ServiceDetails serviceDetails); + private native void nDeleteUser(long ptr, User user); private native Status nListUsers(long ptr, List users); diff --git a/mpinsdk/src/main/java/com/miracl/mpinsdk/model/ServiceDetails.java b/mpinsdk/src/main/java/com/miracl/mpinsdk/model/ServiceDetails.java new file mode 100644 index 0000000..b8f2cde --- /dev/null +++ b/mpinsdk/src/main/java/com/miracl/mpinsdk/model/ServiceDetails.java @@ -0,0 +1,27 @@ +/*************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + ***************************************************************/ +package com.miracl.mpinsdk.model; + +public class ServiceDetails { + + public String name; + public String backendUrl; + public String rpsPrefix; + public String logoUrl; +} diff --git a/mpinsdk/src/main/jni/JNIMPinSDK.cpp b/mpinsdk/src/main/jni/JNIMPinSDK.cpp index 52cfe48..a56fe83 100644 --- a/mpinsdk/src/main/jni/JNIMPinSDK.cpp +++ b/mpinsdk/src/main/jni/JNIMPinSDK.cpp @@ -234,6 +234,29 @@ static jobject nGetSessionDetails(JNIEnv* env, jobject jobj, jlong jptr, jstring return MakeJavaStatus(env, status); } +static jobject nGetServiceDetails(JNIEnv* env, jobject jobj, jlong jptr, jstring jurl, jobject jserviceDetails){ + MPinSDK* sdk = (MPinSDK*) jptr; + MPinSDK::ServiceDetails serviceDetails; + + MPinSDK::Status status = sdk->GetServiceDetails(JavaToStdString(env, jurl), serviceDetails); + + if(status == MPinSDK::Status::OK) + { + jclass clsServiceDetails = env->FindClass("com/miracl/mpinsdk/model/ServiceDetails"); + jfieldID fIdName = env->GetFieldID(clsServiceDetails, "name", "Ljava/lang/String;"); + jfieldID fIdBackendUrl = env->GetFieldID(clsServiceDetails, "backendUrl", "Ljava/lang/String;"); + jfieldID fIdRpsPrefix = env->GetFieldID(clsServiceDetails, "rpsPrefix", "Ljava/lang/String;"); + jfieldID fIdLogoUrl = env->GetFieldID(clsServiceDetails, "logoUrl", "Ljava/lang/String;"); + + env->SetObjectField(jserviceDetails, fIdName, env->NewStringUTF(serviceDetails.name.c_str())); + env->SetObjectField(jserviceDetails, fIdBackendUrl, env->NewStringUTF(serviceDetails.backendUrl.c_str())); + env->SetObjectField(jserviceDetails, fIdRpsPrefix, env->NewStringUTF(serviceDetails.rpsPrefix.c_str())); + env->SetObjectField(jserviceDetails, fIdLogoUrl, env->NewStringUTF(serviceDetails.logoUrl.c_str())); + } + + return MakeJavaStatus(env, status); +} + static void nDeleteUser(JNIEnv* env, jobject jobj, jlong jptr, jobject juser) { MPinSDK* sdk = (MPinSDK*) jptr; @@ -384,6 +407,7 @@ static JNINativeMethod g_methodsMPinSDK[] = NATIVE_METHOD(nFinishAuthenticationMFA, "(JLcom/miracl/mpinsdk/model/User;Ljava/lang/String;Ljava/lang/StringBuilder;)Lcom/miracl/mpinsdk/model/Status;"), NATIVE_METHOD(nDeleteUser, "(JLcom/miracl/mpinsdk/model/User;)V"), NATIVE_METHOD(nGetSessionDetails, "(JLjava/lang/String;Lcom/miracl/mpinsdk/model/SessionDetails;)Lcom/miracl/mpinsdk/model/Status;"), + NATIVE_METHOD(nGetServiceDetails, "(JLjava/lang/String;Lcom/miracl/mpinsdk/model/ServiceDetails;)Lcom/miracl/mpinsdk/model/Status;"), NATIVE_METHOD(nListUsers, "(JLjava/util/List;)Lcom/miracl/mpinsdk/model/Status;"), NATIVE_METHOD(nListAllUsers, "(JLjava/util/List;)Lcom/miracl/mpinsdk/model/Status;"), NATIVE_METHOD(nListUsersForBackend, "(JLjava/util/List;Ljava/lang/String;)Lcom/miracl/mpinsdk/model/Status;"),