Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'miracl/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Simeon Aladjem committed Dec 15, 2016
2 parents 379620e + fbc1c25 commit 3b4f66e
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 3 deletions.
19 changes: 19 additions & 0 deletions README.md
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -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/
Expand Down
2 changes: 1 addition & 1 deletion mpin-sdk-core
7 changes: 7 additions & 0 deletions mpinsdk/src/main/java/com/miracl/mpinsdk/MPinSDK.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -242,6 +247,8 @@ private native Status nInitWithCustomHeaders(long ptr, Map<String, String> 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<User> users);
Expand Down
27 changes: 27 additions & 0 deletions 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;
}
24 changes: 24 additions & 0 deletions mpinsdk/src/main/jni/JNIMPinSDK.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;"),
Expand Down

0 comments on commit 3b4f66e

Please sign in to comment.