diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/AsyncHelper.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/AsyncHelper.java index 271c2f5c..de3f4191 100644 --- a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/AsyncHelper.java +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/AsyncHelper.java @@ -116,7 +116,7 @@ public interface Execution { * Start your asynchronous operation. Your implementation get a {@link ResultCatcher} object * that allows you report result of the operation once it completes its execution. * - * @param resultCatcher A result catcher that allows you report the result of the asynchronous operation. + * @param resultCatcher A result catcher that allows you to report the result of the asynchronous operation. * @throws Exception In case of failure. */ void execute(@NonNull ResultCatcher resultCatcher) throws Exception; diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/PowerAuthServerApi.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/PowerAuthServerApi.java index ccf26722..8ca342aa 100644 --- a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/PowerAuthServerApi.java +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/PowerAuthServerApi.java @@ -248,7 +248,7 @@ public interface PowerAuthServerApi { * Get information about activation. * * @param activationId Activation identifier. - * @param challenge Optional challenge, required for acquiring V3.1 {@code encryptedStatusBlob}. + * @param challenge Optional challenge, required for acquiring V3.1+ {@code encryptedStatusBlob}. * @return {@link ActivationDetail} object. * @throws Exception In case of failure. */ @@ -272,10 +272,11 @@ public interface PowerAuthServerApi { * @param tokenDigest Token digest. * @param nonce Nonce in Base64 encoding. * @param timestamp Timestamp used for calculate token. + * @param protocolVersion Protocol version, required for server 1.5+. * @return {@link TokenInfo} object in case of success. * @throws Exception In case of failure. */ - @NonNull TokenInfo validateToken(@NonNull String tokenId, @NonNull String tokenDigest, @NonNull String nonce, long timestamp) throws Exception; + @NonNull TokenInfo validateToken(@NonNull String tokenId, @NonNull String tokenDigest, @NonNull String nonce, long timestamp, @NonNull String protocolVersion) throws Exception; // Signatures diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/PowerAuthTestHelper.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/PowerAuthTestHelper.java index e8b53665..ab4e8e36 100644 --- a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/PowerAuthTestHelper.java +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/PowerAuthTestHelper.java @@ -27,6 +27,7 @@ import io.getlime.security.powerauth.integration.support.model.Application; import io.getlime.security.powerauth.integration.support.model.ApplicationDetail; import io.getlime.security.powerauth.integration.support.model.ApplicationVersion; +import io.getlime.security.powerauth.integration.support.model.ProtocolVersion; import io.getlime.security.powerauth.networking.ssl.HttpClientSslNoValidationStrategy; import io.getlime.security.powerauth.sdk.PowerAuthAuthenticationHelper; import io.getlime.security.powerauth.sdk.PowerAuthClientConfiguration; @@ -483,6 +484,6 @@ private PowerAuthTestHelper( * @return Expected protocol version for HTTP headers. */ public @NonNull String getProtocolVersionForHeader() { - return testConfig.getServerVersion().maxProtocolVersion.versionForHeader; + return ProtocolVersion.V3_1.versionForHeader; } } diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/client/PowerAuthClientFactory.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/client/PowerAuthClientFactory.java index 0ea97eb7..9a3cc19d 100644 --- a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/client/PowerAuthClientFactory.java +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/client/PowerAuthClientFactory.java @@ -23,6 +23,7 @@ import io.getlime.security.powerauth.integration.support.model.ServerVersion; import io.getlime.security.powerauth.integration.support.v10.PowerAuthClientV3_ServerV10; import io.getlime.security.powerauth.integration.support.v13.PowerAuthClientV3_ServerV13; +import io.getlime.security.powerauth.integration.support.v15.PowerAuthClientV3_ServerV15; /** * The {@code PowerAuthClientFactory} provides client that communicate with PowerAuth Server API, @@ -40,12 +41,13 @@ public class PowerAuthClientFactory { */ public PowerAuthServerApi createApiClient(@NonNull PowerAuthTestConfig testConfig) throws Exception { PowerAuthServerApi api = null; - if (testConfig.getServerVersion().numericVersion >= ServerVersion.V1_0_0.numericVersion && - testConfig.getServerVersion().numericVersion <= ServerVersion.V1_2_5.numericVersion) { + final int numVer = testConfig.getServerVersion().numericVersion; + if (numVer >= ServerVersion.V1_0_0.numericVersion && numVer < ServerVersion.V1_3_0.numericVersion) { api = new PowerAuthClientV3_ServerV10(testConfig.getServerApiUrl(), testConfig.getAuthorizationHeaderValue(), ServerVersion.V1_0_0, ServerVersion.V1_2_5); - } else if (testConfig.getServerVersion().numericVersion >= ServerVersion.V1_3_0.numericVersion && - testConfig.getServerVersion().numericVersion <= ServerVersion.LATEST.numericVersion) { - api = new PowerAuthClientV3_ServerV13(testConfig.getServerApiUrl(), testConfig.getAuthorizationHeaderValue(), ServerVersion.V1_3_0, null); + } else if (numVer >= ServerVersion.V1_3_0.numericVersion && numVer < ServerVersion.V1_5_0.numericVersion) { + api = new PowerAuthClientV3_ServerV13(testConfig.getServerApiUrl(), testConfig.getAuthorizationHeaderValue(), ServerVersion.V1_3_0, ServerVersion.V1_4_0); + } else if (numVer >= ServerVersion.V1_5_0.numericVersion && numVer <= ServerVersion.LATEST.numericVersion) { + api = new PowerAuthClientV3_ServerV15(testConfig.getServerApiUrl(), testConfig.getAuthorizationHeaderValue(), ServerVersion.V1_5_0, null); } if (api == null) { throw new Exception("Missing implementation for server API, for server version " + testConfig.getServerVersion().version); diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/model/ApplicationVersion.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/model/ApplicationVersion.java index 801f0a03..112a200a 100644 --- a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/model/ApplicationVersion.java +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/model/ApplicationVersion.java @@ -22,6 +22,7 @@ public class ApplicationVersion { private String applicationVersionName; private String applicationKey; private String applicationSecret; + private String mobileSdkConfig; private boolean supported; public String getApplicationVersionId() { @@ -63,4 +64,12 @@ public boolean isSupported() { public void setSupported(boolean supported) { this.supported = supported; } + + public String getMobileSdkConfig() { + return mobileSdkConfig; + } + + public void setMobileSdkConfig(String mobileSdkConfig) { + this.mobileSdkConfig = mobileSdkConfig; + } } diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/model/ProtocolVersion.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/model/ProtocolVersion.java index 785ea0dc..532278d5 100644 --- a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/model/ProtocolVersion.java +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/model/ProtocolVersion.java @@ -25,8 +25,8 @@ public enum ProtocolVersion { V3_1(31, "3.1"), V3_2(32, "3.2"); - public int version; - public String versionForHeader; + public final int version; + public final String versionForHeader; ProtocolVersion(int version, String versionForHeader) { this.version = version; diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/model/ServerVersion.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/model/ServerVersion.java index 9ec5842d..66f92899 100644 --- a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/model/ServerVersion.java +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/model/ServerVersion.java @@ -32,11 +32,10 @@ public enum ServerVersion { V1_2_5("1.2.5", 1002005, ProtocolVersion.V3_1), V1_3_0("1.3", 1003000, ProtocolVersion.V3_1), V1_4_0("1.4", 1004000, ProtocolVersion.V3_1), - // Server 1.5+ supports V3.2, but this SDK supports V3.1 only - V1_5_0("1.5", 1005000, ProtocolVersion.V3_1), - V1_6_0("1.6", 1006000, ProtocolVersion.V3_1), - V1_7_0("1.7", 1007000, ProtocolVersion.V3_1), - V1_8_0("1.8", 1008000, ProtocolVersion.V3_1), + V1_5_0("1.5", 1005000, ProtocolVersion.V3_2), + V1_6_0("1.6", 1006000, ProtocolVersion.V3_2), + V1_7_0("1.7", 1007000, ProtocolVersion.V3_2), + V1_8_0("1.8", 1008000, ProtocolVersion.V3_2), ; diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v10/PowerAuthClientV3_ServerV10.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v10/PowerAuthClientV3_ServerV10.java index 114a514c..7a6c4db6 100644 --- a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v10/PowerAuthClientV3_ServerV10.java +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v10/PowerAuthClientV3_ServerV10.java @@ -295,7 +295,7 @@ public ActivationDetail getActivationDetail(@NonNull Activation activation) thro @NonNull @Override - public TokenInfo validateToken(@NonNull String tokenId, @NonNull String tokenDigest, @NonNull String nonce, long timestamp) throws Exception { + public TokenInfo validateToken(@NonNull String tokenId, @NonNull String tokenDigest, @NonNull String nonce, long timestamp, @NonNull String protocolVersion) throws Exception { final ValidateTokenEndpoint.Request request = new ValidateTokenEndpoint.Request(); request.setTokenId(tokenId); request.setTokenDigest(tokenDigest); diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v13/PowerAuthClientV3_ServerV13.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v13/PowerAuthClientV3_ServerV13.java index 86394927..b950c62b 100644 --- a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v13/PowerAuthClientV3_ServerV13.java +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v13/PowerAuthClientV3_ServerV13.java @@ -328,7 +328,7 @@ public ActivationDetail getActivationDetail(@NonNull Activation activation) thro @NonNull @Override - public TokenInfo validateToken(@NonNull String tokenId, @NonNull String tokenDigest, @NonNull String nonce, long timestamp) throws Exception { + public TokenInfo validateToken(@NonNull String tokenId, @NonNull String tokenDigest, @NonNull String nonce, long timestamp, @NonNull String protocolVersion) throws Exception { final ValidateTokenEndpoint.Request request = new ValidateTokenEndpoint.Request(); request.setTokenId(tokenId); request.setTokenDigest(tokenDigest); diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/PowerAuthClientV3_ServerV15.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/PowerAuthClientV3_ServerV15.java new file mode 100644 index 00000000..6a48e856 --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/PowerAuthClientV3_ServerV15.java @@ -0,0 +1,382 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15; + +import java.util.Collections; +import java.util.List; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.PowerAuthServerApi; +import io.getlime.security.powerauth.integration.support.client.HttpRestClient; +import io.getlime.security.powerauth.integration.support.model.Activation; +import io.getlime.security.powerauth.integration.support.model.ActivationDetail; +import io.getlime.security.powerauth.integration.support.model.ActivationOtpValidation; +import io.getlime.security.powerauth.integration.support.model.ActivationStatus; +import io.getlime.security.powerauth.integration.support.model.Application; +import io.getlime.security.powerauth.integration.support.model.ApplicationDetail; +import io.getlime.security.powerauth.integration.support.model.ApplicationVersion; +import io.getlime.security.powerauth.integration.support.model.OfflineSignaturePayload; +import io.getlime.security.powerauth.integration.support.model.RecoveryConfig; +import io.getlime.security.powerauth.integration.support.model.ServerConstants; +import io.getlime.security.powerauth.integration.support.model.ServerVersion; +import io.getlime.security.powerauth.integration.support.model.SignatureData; +import io.getlime.security.powerauth.integration.support.model.SignatureInfo; +import io.getlime.security.powerauth.integration.support.model.TokenInfo; +import io.getlime.security.powerauth.integration.support.v15.endpoints.BlockActivationEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.CommitActivationEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.CreateApplicationEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.CreateApplicationVersionEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.CreateNonPersonalizedOfflineSignaturePayloadEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.CreatePersonalizedOfflineSignaturePayloadEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.GetActivationStatusEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.GetApplicationDetailEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.GetApplicationListEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.GetRecoveryConfigEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.GetSystemStatusEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.InitActivationEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.RemoveActivationEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.SetApplicationVersionSupportedEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.UnblockActivationEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.UpdateActivationOtpEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.UpdateRecoveryConfigEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.ValidateTokenEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.VerifyEcdsaSignatureEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.VerifyOfflineSignatureEndpoint; +import io.getlime.security.powerauth.integration.support.v15.endpoints.VerifyOnlineSignatureEndpoint; + +public class PowerAuthClientV3_ServerV15 implements PowerAuthServerApi { + + private final @NonNull HttpRestClient restClient; + private final @NonNull ServerVersion minSupportedVersion; + private final @NonNull ServerVersion maxSupportedVersion; + private ServerVersion currentServerVersion; + + /** + * Create REST client that communicate with PowerAuth Server RESTful API. + * + * @param serverApiUrl URL to PowerAuth Server. + * @param authorization Optional authorization header value, if PowerAuth Server require authorization. + * @param minSupportedVersion Minimum supported server version. If {@code null} is provided, then {@link ServerVersion#LATEST} is used. + * @param maxSupportedVersion Maximum supported server version. If {@code null} is provided, then {@link ServerVersion#LATEST} is used. + */ + public PowerAuthClientV3_ServerV15(@NonNull String serverApiUrl, @Nullable String authorization, @Nullable ServerVersion minSupportedVersion, @Nullable ServerVersion maxSupportedVersion) throws Exception { + this.restClient = new HttpRestClient(serverApiUrl, authorization); + this.minSupportedVersion = minSupportedVersion == null ? ServerVersion.LATEST : minSupportedVersion; + this.maxSupportedVersion = maxSupportedVersion == null ? ServerVersion.LATEST : maxSupportedVersion; + if (this.minSupportedVersion.numericVersion > this.maxSupportedVersion.numericVersion) { + throw new Exception("Minimum supported server version is higher that maximum."); + } + } + + @Override + public void validateConnection() throws Exception { + final GetSystemStatusEndpoint.Response response = restClient.send(null, new GetSystemStatusEndpoint()); + String version = response.getVersion(); + if (version == null) { + throw new Exception("Missing version in system status response."); + } + currentServerVersion = ServerVersion.versionFromString(version, true); + if (currentServerVersion.numericVersion < minSupportedVersion.numericVersion || currentServerVersion.numericVersion > maxSupportedVersion.numericVersion) { + throw new Exception("Unsupported server version " + response.getVersion()); + } + } + + @NonNull + @Override + public ServerVersion getServerVersion() throws Exception { + if (currentServerVersion == null) { + validateConnection(); + if (currentServerVersion == null) { + throw new Exception("Cannot determine server version."); + } + } + return currentServerVersion; + } + + @Nullable + @Override + public Application findApplicationByName(@NonNull String applicationName) throws Exception { + final GetApplicationListEndpoint.Response response = restClient.send(null, new GetApplicationListEndpoint()); + if (response != null && response.getApplications() != null) { + for (Application app : response.getApplications()) { + // If V1.3 server has been migrated from older version, then contains previous application names in form of identifier. + // There's no such application name in the new model. + if (applicationName.equals(app.getApplicationId())) { + return app; + } + } + } + return null; + } + + @Nullable + @Override + public ApplicationVersion findApplicationVersionByName(@NonNull ApplicationDetail applicationDetail, @NonNull String applicationVersionName) throws Exception { + if (applicationDetail.getVersions() != null) { + for (ApplicationVersion version: applicationDetail.getVersions()) { + // If V1.3 server has been migrated from older version, then contains previous version names in form of identifier. + // There's no such application version name in the new model. + if (applicationVersionName.equals(version.getApplicationVersionId())) { + return version; + } + } + } + return null; + } + + @NonNull + @Override + public List getApplicationList() throws Exception { + final GetApplicationListEndpoint.Response response = restClient.send(null, new GetApplicationListEndpoint()); + return response.getApplications() != null ? response.getApplications() : Collections.emptyList(); + } + + @NonNull + @Override + public Application createApplication(@NonNull String applicationName) throws Exception { + final CreateApplicationEndpoint.Request request = new CreateApplicationEndpoint.Request(); + request.setApplicationId(applicationName); + return restClient.send(request, new CreateApplicationEndpoint()); + } + + @NonNull + @Override + public ApplicationDetail getApplicationDetailByName(@NonNull String applicationName) throws Exception { + final GetApplicationDetailEndpoint.Request request = new GetApplicationDetailEndpoint.Request(); + request.setApplicationName(applicationName); + return restClient.send(request, new GetApplicationDetailEndpoint()); + } + + @NonNull + @Override + public ApplicationDetail getApplicationDetailById(String applicationId) throws Exception { + final GetApplicationDetailEndpoint.Request request = new GetApplicationDetailEndpoint.Request(); + request.setApplicationId(applicationId); + return restClient.send(request, new GetApplicationDetailEndpoint()); + } + + @NonNull + @Override + public ApplicationVersion createApplicationVersion(String applicationId, @NonNull String versionName) throws Exception { + final CreateApplicationVersionEndpoint.Request request = new CreateApplicationVersionEndpoint.Request(); + request.setApplicationId(applicationId); + request.setApplicationVersionId(versionName); + return restClient.send(request, new CreateApplicationVersionEndpoint()); + } + + @Override + public void setApplicationVersionSupported(String applicationVersionId, boolean supported) throws Exception { + final SetApplicationVersionSupportedEndpoint.Request request = new SetApplicationVersionSupportedEndpoint.Request(); + request.setApplicationVersionId(applicationVersionId); + final SetApplicationVersionSupportedEndpoint.Response response = restClient.send(request, new SetApplicationVersionSupportedEndpoint(supported)); + if (response.isSupported() != supported) { + throw new Exception("Application version is still " + (supported ? "unsupported" : "supported") + " after successful response."); + } + } + + @NonNull + @Override + public RecoveryConfig getRecoveryConfig(String applicationId) throws Exception { + final GetRecoveryConfigEndpoint.Request request = new GetRecoveryConfigEndpoint.Request(); + request.setApplicationId(applicationId); + return restClient.send(request, new GetRecoveryConfigEndpoint()); + } + + @Override + public void updateRecoveryConfig(@NonNull RecoveryConfig recoveryConfig) throws Exception { + final UpdateRecoveryConfigEndpoint.Request request = new UpdateRecoveryConfigEndpoint.Request(recoveryConfig); + final UpdateRecoveryConfigEndpoint.Response response = restClient.send(request, new UpdateRecoveryConfigEndpoint()); + if (!response.isUpdated()) { + throw new Exception("Recovery config for application " + recoveryConfig.getApplicationId() + " is not updated after successful response."); + } + } + + @NonNull + @Override + public Activation activationInit(@NonNull Application application, @NonNull String userId, @Nullable String otp, @Nullable ActivationOtpValidation otpValidation, @Nullable Long maxFailureCount) throws Exception { + if ((otp != null && otpValidation == null) || (otp == null) && (otpValidation != null)) { + throw new Exception("Invalid combination of activation OTP and OTP validation."); + } + final InitActivationEndpoint.Request request = new InitActivationEndpoint.Request(); + request.setApplicationId(application.getApplicationId()); + request.setUserId(userId); + request.setActivationOtp(otp); + request.setActivationOtpValidation(otpValidation); + request.setMaxFailureCount(maxFailureCount != null ? maxFailureCount : ServerConstants.DEFAULT_MAX_FAILURE_ATTEMPTS); + return restClient.send(request, new InitActivationEndpoint()); + } + + @NonNull + @Override + public Activation activationInit(@NonNull Application application, @NonNull String userId) throws Exception { + return activationInit(application, userId, null, null, null); + } + + @Override + public void updateActivationOtp(@NonNull String activationId, @NonNull String otp, @Nullable String externalUserId) throws Exception { + final UpdateActivationOtpEndpoint.Request request = new UpdateActivationOtpEndpoint.Request(); + request.setActivationId(activationId); + request.setActivationOtp(otp); + request.setExternalUserId(externalUserId != null ? externalUserId : ServerConstants.DEFAULT_EXTERNAL_USER_ID); + final UpdateActivationOtpEndpoint.Response response = restClient.send(request, new UpdateActivationOtpEndpoint()); + if (!response.isUpdated()) { + throw new Exception("Ativation OTP for activation " + activationId + " is not updated after request success."); + } + } + + @Override + public void updateActivationOtp(@NonNull Activation activation, @NonNull String otp) throws Exception { + updateActivationOtp(activation.getActivationId(), otp, ServerConstants.DEFAULT_EXTERNAL_USER_ID); + } + + @Override + public void activationCommit(@NonNull String activationId, @Nullable String otp, @Nullable String externalUserId) throws Exception { + final CommitActivationEndpoint.Request request = new CommitActivationEndpoint.Request(); + request.setActivationId(activationId); + request.setActivationOtp(otp); + request.setExternalUserId(externalUserId != null ? externalUserId : ServerConstants.DEFAULT_EXTERNAL_USER_ID); + final CommitActivationEndpoint.Response response = restClient.send(request, new CommitActivationEndpoint()); + if (!response.isActivated()) { + throw new Exception("Activation " + activationId + " is not activated after commit after successful response."); + } + } + + @Override + public void activationCommit(@NonNull Activation activation) throws Exception { + activationCommit(activation.getActivationId(), null, ServerConstants.DEFAULT_EXTERNAL_USER_ID); + } + + @Override + public void activationRemove(@NonNull String activationId, @Nullable String externalUserId, boolean revokeRecoveryCodes) throws Exception { + final RemoveActivationEndpoint.Request request = new RemoveActivationEndpoint.Request(); + request.setActivationId(activationId); + request.setExternalUserId(externalUserId); + request.setRevokeRecoveryCodes(revokeRecoveryCodes); + final RemoveActivationEndpoint.Response response = restClient.send(request, new RemoveActivationEndpoint()); + if (!response.isRemoved()) { + throw new Exception("Activation " + activationId + " is not removed after request success."); + } + } + + @Override + public void activationRemove(@NonNull Activation activation) throws Exception { + activationRemove(activation.getActivationId(), ServerConstants.DEFAULT_EXTERNAL_USER_ID, true); + } + + @Override + public void activationBlock(@NonNull String activationId, @Nullable String reason, @Nullable String externalUserId) throws Exception { + final BlockActivationEndpoint.Request request = new BlockActivationEndpoint.Request(); + request.setActivationId(activationId); + request.setReason(reason != null ? reason : ServerConstants.BLOCKED_REASON_NOT_SPECIFIED); + request.setExternalUserId(externalUserId != null ? externalUserId : ServerConstants.DEFAULT_EXTERNAL_USER_ID); + final BlockActivationEndpoint.Response response = restClient.send(request, new BlockActivationEndpoint()); + if (response.getActivationStatus() != ActivationStatus.BLOCKED) { + throw new Exception("Activation " + activationId + " is not blocked after block request success."); + } + } + + @Override + public void activationBlock(@NonNull Activation activation) throws Exception { + activationBlock(activation.getActivationId(), ServerConstants.BLOCKED_REASON_NOT_SPECIFIED, ServerConstants.DEFAULT_EXTERNAL_USER_ID); + } + + @Override + public void activationUnblock(@NonNull String activationId, @Nullable String externalUserId) throws Exception { + final UnblockActivationEndpoint.Request request = new UnblockActivationEndpoint.Request(); + request.setActivationId(activationId); + request.setExternalUserId(externalUserId != null ? externalUserId : ServerConstants.DEFAULT_EXTERNAL_USER_ID); + final UnblockActivationEndpoint.Response response = restClient.send(request, new UnblockActivationEndpoint()); + if (response.getActivationStatus() != ActivationStatus.ACTIVE) { + throw new Exception("Activation " + activationId + " is not active after unblock request success."); + } + } + + @Override + public void activationUnblock(@NonNull Activation activation) throws Exception { + activationUnblock(activation.getActivationId(), ServerConstants.DEFAULT_EXTERNAL_USER_ID); + } + + @NonNull + @Override + public ActivationDetail getActivationDetail(@NonNull String activationId, @Nullable String challenge) throws Exception { + final GetActivationStatusEndpoint.Request request = new GetActivationStatusEndpoint.Request(); + request.setActivationId(activationId); + request.setChallenge(challenge); + return restClient.send(request, new GetActivationStatusEndpoint()); + } + + @NonNull + @Override + public ActivationDetail getActivationDetail(@NonNull Activation activation) throws Exception { + return getActivationDetail(activation.getActivationId(), null); + } + + @NonNull + @Override + public TokenInfo validateToken(@NonNull String tokenId, @NonNull String tokenDigest, @NonNull String nonce, long timestamp, @NonNull String protocolVersion) throws Exception { + final ValidateTokenEndpoint.Request request = new ValidateTokenEndpoint.Request(); + request.setTokenId(tokenId); + request.setTokenDigest(tokenDigest); + request.setNonce(nonce); + request.setTimestamp(timestamp); + request.setProtocolVersion(protocolVersion); + return restClient.send(request, new ValidateTokenEndpoint()); + } + + @NonNull + @Override + public SignatureInfo verifyOnlineSignature(@NonNull SignatureData signatureData) throws Exception { + final VerifyOnlineSignatureEndpoint.Request request = new VerifyOnlineSignatureEndpoint.Request(signatureData); + return restClient.send(request, new VerifyOnlineSignatureEndpoint()); + } + + @NonNull + @Override + public SignatureInfo verifyOfflineSignature(@NonNull SignatureData signatureData) throws Exception { + final VerifyOfflineSignatureEndpoint.Request request = new VerifyOfflineSignatureEndpoint.Request(signatureData); + return restClient.send(request, new VerifyOfflineSignatureEndpoint()); + } + + @Override + public boolean verifyEcdsaSignature(@NonNull String activationId, @NonNull String data, @NonNull String signature) throws Exception { + final VerifyEcdsaSignatureEndpoint.Request request = new VerifyEcdsaSignatureEndpoint.Request(); + request.setActivationId(activationId); + request.setData(data); + request.setSignature(signature); + final VerifyEcdsaSignatureEndpoint.Response response = restClient.send(request, new VerifyEcdsaSignatureEndpoint()); + return response.isSignatureValid(); + } + + @NonNull + @Override + public OfflineSignaturePayload createNonPersonalizedOfflineSignaturePayload(String applicationId, @NonNull String data) throws Exception { + final CreateNonPersonalizedOfflineSignaturePayloadEndpoint.Request request = new CreateNonPersonalizedOfflineSignaturePayloadEndpoint.Request(); + request.setApplicationId(applicationId); + request.setData(data); + return restClient.send(request, new CreateNonPersonalizedOfflineSignaturePayloadEndpoint()); + } + + @NonNull + @Override + public OfflineSignaturePayload createPersonalizedOfflineSignaturePayload(@NonNull String activationId, @NonNull String data) throws Exception { + final CreatePersonalizedOfflineSignaturePayloadEndpoint.Request request = new CreatePersonalizedOfflineSignaturePayloadEndpoint.Request(); + request.setActivationId(activationId); + request.setData(data); + return restClient.send(request, new CreatePersonalizedOfflineSignaturePayloadEndpoint()); + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/BlockActivationEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/BlockActivationEndpoint.java new file mode 100644 index 00000000..8306bc36 --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/BlockActivationEndpoint.java @@ -0,0 +1,96 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; +import io.getlime.security.powerauth.integration.support.model.ActivationStatus; + +public class BlockActivationEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/activation/block"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + // Request + + public static class Request { + + private String activationId; + private String externalUserId; + private String reason; + + public String getActivationId() { + return activationId; + } + + public void setActivationId(String activationId) { + this.activationId = activationId; + } + + public String getExternalUserId() { + return externalUserId; + } + + public void setExternalUserId(String externalUserId) { + this.externalUserId = externalUserId; + } + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + } + + // Response + + public static class Response { + + private String activationId; + private ActivationStatus activationStatus; + + public String getActivationId() { + return activationId; + } + + public void setActivationId(String activationId) { + this.activationId = activationId; + } + + public ActivationStatus getActivationStatus() { + return activationStatus; + } + + public void setActivationStatus(ActivationStatus activationStatus) { + this.activationStatus = activationStatus; + } + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/CommitActivationEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/CommitActivationEndpoint.java new file mode 100644 index 00000000..8382fc6a --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/CommitActivationEndpoint.java @@ -0,0 +1,95 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; + +public class CommitActivationEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/activation/commit"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + // Request + + public static class Request { + + private String activationId; + private String activationOtp; + private String externalUserId; + + public String getActivationId() { + return activationId; + } + + public void setActivationId(String activationId) { + this.activationId = activationId; + } + + public String getActivationOtp() { + return activationOtp; + } + + public void setActivationOtp(String activationOtp) { + this.activationOtp = activationOtp; + } + + public String getExternalUserId() { + return externalUserId; + } + + public void setExternalUserId(String externalUserId) { + this.externalUserId = externalUserId; + } + } + + // Response + + public static class Response { + + private boolean activated; + private String activationId; + + public boolean isActivated() { + return activated; + } + + public void setActivated(boolean activated) { + this.activated = activated; + } + + public String getActivationId() { + return activationId; + } + + public void setActivationId(String activationId) { + this.activationId = activationId; + } + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/CreateApplicationEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/CreateApplicationEndpoint.java new file mode 100644 index 00000000..7b7bcdc8 --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/CreateApplicationEndpoint.java @@ -0,0 +1,59 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; +import io.getlime.security.powerauth.integration.support.model.Application; + +public class CreateApplicationEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/application/create"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + // Request + + public static class Request { + + private String applicationId; + + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationName) { + this.applicationId = applicationName; + } + } + + // Response + + public static class Response extends Application { + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/CreateApplicationVersionEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/CreateApplicationVersionEndpoint.java new file mode 100644 index 00000000..41d3604d --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/CreateApplicationVersionEndpoint.java @@ -0,0 +1,68 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; +import io.getlime.security.powerauth.integration.support.model.ApplicationVersion; + +public class CreateApplicationVersionEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/application/version/create"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + // Request + + public static class Request { + + private String applicationId; + private String applicationVersionId; + + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + + public String getApplicationVersionId() { + return applicationVersionId; + } + + public void setApplicationVersionId(String applicationVersionName) { + this.applicationVersionId = applicationVersionName; + } + } + + // Response + + public static class Response extends ApplicationVersion { + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/CreateNonPersonalizedOfflineSignaturePayloadEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/CreateNonPersonalizedOfflineSignaturePayloadEndpoint.java new file mode 100644 index 00000000..ea71b06d --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/CreateNonPersonalizedOfflineSignaturePayloadEndpoint.java @@ -0,0 +1,68 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; +import io.getlime.security.powerauth.integration.support.model.OfflineSignaturePayload; + +public class CreateNonPersonalizedOfflineSignaturePayloadEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/signature/offline/non-personalized/create"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + // Request + + public static class Request { + + private String applicationId; + private String data; + + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + } + + // Response + + public static class Response extends OfflineSignaturePayload { + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/CreatePersonalizedOfflineSignaturePayloadEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/CreatePersonalizedOfflineSignaturePayloadEndpoint.java new file mode 100644 index 00000000..9b7dce73 --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/CreatePersonalizedOfflineSignaturePayloadEndpoint.java @@ -0,0 +1,67 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; +import io.getlime.security.powerauth.integration.support.model.OfflineSignaturePayload; + +public class CreatePersonalizedOfflineSignaturePayloadEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/signature/offline/personalized/create"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + // Request + + public static class Request { + private String activationId; + private String data; + + public String getActivationId() { + return activationId; + } + + public void setActivationId(String activationId) { + this.activationId = activationId; + } + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + } + + // Response + + public static class Response extends OfflineSignaturePayload { + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/EmptyRequestObject.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/EmptyRequestObject.java new file mode 100644 index 00000000..b29f8b8f --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/EmptyRequestObject.java @@ -0,0 +1,21 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +public class EmptyRequestObject { + // Empty request object +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/GetActivationStatusEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/GetActivationStatusEndpoint.java new file mode 100644 index 00000000..5867b12d --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/GetActivationStatusEndpoint.java @@ -0,0 +1,68 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; +import io.getlime.security.powerauth.integration.support.model.ActivationDetail; + +public class GetActivationStatusEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/activation/status"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + // Request + + public static class Request { + + private String activationId; + private String challenge; + + public String getActivationId() { + return activationId; + } + + public void setActivationId(String activationId) { + this.activationId = activationId; + } + + public String getChallenge() { + return challenge; + } + + public void setChallenge(String challenge) { + this.challenge = challenge; + } + } + + // Response + + public static class Response extends ActivationDetail { + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/GetApplicationDetailEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/GetApplicationDetailEndpoint.java new file mode 100644 index 00000000..67121879 --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/GetApplicationDetailEndpoint.java @@ -0,0 +1,67 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; +import io.getlime.security.powerauth.integration.support.model.ApplicationDetail; + +public class GetApplicationDetailEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/application/detail"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + // Request + + public static class Request { + private String applicationId; + private String applicationName; + + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + + public String getApplicationName() { + return applicationName; + } + + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } + } + + // Response + + public static class Response extends ApplicationDetail { + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/GetApplicationListEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/GetApplicationListEndpoint.java new file mode 100644 index 00000000..98e7ba50 --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/GetApplicationListEndpoint.java @@ -0,0 +1,57 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import java.util.List; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; +import io.getlime.security.powerauth.integration.support.model.Application; + +public class GetApplicationListEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/application/list"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + // Empty request + + // Response + + public static class Response { + private List applications; + + public List getApplications() { + return applications; + } + + public void setApplications(List applications) { + this.applications = applications; + } + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/GetRecoveryConfigEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/GetRecoveryConfigEndpoint.java new file mode 100644 index 00000000..f7cdb7cc --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/GetRecoveryConfigEndpoint.java @@ -0,0 +1,59 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; +import io.getlime.security.powerauth.integration.support.model.RecoveryConfig; + +public class GetRecoveryConfigEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/recovery/config/detail"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + // Request + + public static class Request { + + private String applicationId; + + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + } + + // Response + + public static class Response extends RecoveryConfig { + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/GetSystemStatusEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/GetSystemStatusEndpoint.java new file mode 100644 index 00000000..f105ae28 --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/GetSystemStatusEndpoint.java @@ -0,0 +1,100 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; + +public class GetSystemStatusEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/status"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + // Empty request + + // Response + + public static class Response { + + private String status; + private String applicationName; + private String applicationDisplayName; + private String applicationEnvironment; + private String timestamp; + private String version; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getApplicationName() { + return applicationName; + } + + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } + + public String getApplicationDisplayName() { + return applicationDisplayName; + } + + public void setApplicationDisplayName(String applicationDisplayName) { + this.applicationDisplayName = applicationDisplayName; + } + + public String getApplicationEnvironment() { + return applicationEnvironment; + } + + public void setApplicationEnvironment(String applicationEnvironment) { + this.applicationEnvironment = applicationEnvironment; + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/InitActivationEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/InitActivationEndpoint.java new file mode 100644 index 00000000..a20f77aa --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/InitActivationEndpoint.java @@ -0,0 +1,96 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; +import io.getlime.security.powerauth.integration.support.model.Activation; +import io.getlime.security.powerauth.integration.support.model.ActivationOtpValidation; + +public class InitActivationEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/activation/init"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + // Request + + public static class Request { + + private String activationOtp; + private ActivationOtpValidation activationOtpValidation; + private String applicationId; + private long maxFailureCount; + private String userId; + + public String getActivationOtp() { + return activationOtp; + } + + public void setActivationOtp(String activationOtp) { + this.activationOtp = activationOtp; + } + + public ActivationOtpValidation getActivationOtpValidation() { + return activationOtpValidation; + } + + public void setActivationOtpValidation(ActivationOtpValidation activationOtpValidation) { + this.activationOtpValidation = activationOtpValidation; + } + + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + + public long getMaxFailureCount() { + return maxFailureCount; + } + + public void setMaxFailureCount(long maxFailureCount) { + this.maxFailureCount = maxFailureCount; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + } + + // Response + + public static class Response extends Activation { + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/RemoveActivationEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/RemoveActivationEndpoint.java new file mode 100644 index 00000000..f47fc028 --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/RemoveActivationEndpoint.java @@ -0,0 +1,95 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; + +public class RemoveActivationEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/activation/remove"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + // Request + + public static class Request { + + private String activationId; + private String externalUserId; + private boolean revokeRecoveryCodes; + + public String getActivationId() { + return activationId; + } + + public void setActivationId(String activationId) { + this.activationId = activationId; + } + + public String getExternalUserId() { + return externalUserId; + } + + public void setExternalUserId(String externalUserId) { + this.externalUserId = externalUserId; + } + + public boolean isRevokeRecoveryCodes() { + return revokeRecoveryCodes; + } + + public void setRevokeRecoveryCodes(boolean revokeRecoveryCodes) { + this.revokeRecoveryCodes = revokeRecoveryCodes; + } + } + + // Response + + public static class Response { + + private String activationId; + private boolean removed; + + public String getActivationId() { + return activationId; + } + + public void setActivationId(String activationId) { + this.activationId = activationId; + } + + public boolean isRemoved() { + return removed; + } + + public void setRemoved(boolean removed) { + this.removed = removed; + } + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/SetApplicationVersionSupportedEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/SetApplicationVersionSupportedEndpoint.java new file mode 100644 index 00000000..a6ec4463 --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/SetApplicationVersionSupportedEndpoint.java @@ -0,0 +1,83 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; + +public class SetApplicationVersionSupportedEndpoint implements IServerApiEndpoint { + + private final boolean supported; + + public SetApplicationVersionSupportedEndpoint(boolean supported) { + this.supported = supported; + } + + @NonNull + @Override + public String getRelativePath() { + return supported ? "/rest/v3/application/version/support" : "/rest/v3/application/version/unsupport"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + // Request + + public static class Request { + + private String applicationVersionId; + + public String getApplicationVersionId() { + return applicationVersionId; + } + + public void setApplicationVersionId(String applicationVersionId) { + this.applicationVersionId = applicationVersionId; + } + } + + // Response + + public static class Response { + + private String applicationVersionId; + private boolean supported; + + public String getApplicationVersionId() { + return applicationVersionId; + } + + public void setApplicationVersionId(String applicationVersionId) { + this.applicationVersionId = applicationVersionId; + } + + public boolean isSupported() { + return supported; + } + + public void setSupported(boolean supported) { + this.supported = supported; + } + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/UnblockActivationEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/UnblockActivationEndpoint.java new file mode 100644 index 00000000..aac1fa53 --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/UnblockActivationEndpoint.java @@ -0,0 +1,87 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; +import io.getlime.security.powerauth.integration.support.model.ActivationStatus; + +public class UnblockActivationEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/activation/unblock"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(UnblockActivationEndpoint.Response.class); + } + + // Request + + public static class Request { + + private String activationId; + private String externalUserId; + + public String getActivationId() { + return activationId; + } + + public void setActivationId(String activationId) { + this.activationId = activationId; + } + + public String getExternalUserId() { + return externalUserId; + } + + public void setExternalUserId(String externalUserId) { + this.externalUserId = externalUserId; + } + } + + // Response + + public static class Response { + + private String activationId; + private ActivationStatus activationStatus; + + public String getActivationId() { + return activationId; + } + + public void setActivationId(String activationId) { + this.activationId = activationId; + } + + public ActivationStatus getActivationStatus() { + return activationStatus; + } + + public void setActivationStatus(ActivationStatus activationStatus) { + this.activationStatus = activationStatus; + } + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/UpdateActivationOtpEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/UpdateActivationOtpEndpoint.java new file mode 100644 index 00000000..473b2599 --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/UpdateActivationOtpEndpoint.java @@ -0,0 +1,95 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; + +public class UpdateActivationOtpEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/activation/otp/update"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + // Request + + public static class Request { + + private String activationId; + private String activationOtp; + private String externalUserId; + + public String getActivationId() { + return activationId; + } + + public void setActivationId(String activationId) { + this.activationId = activationId; + } + + public String getActivationOtp() { + return activationOtp; + } + + public void setActivationOtp(String activationOtp) { + this.activationOtp = activationOtp; + } + + public String getExternalUserId() { + return externalUserId; + } + + public void setExternalUserId(String externalUserId) { + this.externalUserId = externalUserId; + } + } + + // Response + + public static class Response { + + private String activationId; + private boolean updated; + + public String getActivationId() { + return activationId; + } + + public void setActivationId(String activationId) { + this.activationId = activationId; + } + + public boolean isUpdated() { + return updated; + } + + public void setUpdated(boolean updated) { + this.updated = updated; + } + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/UpdateRecoveryConfigEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/UpdateRecoveryConfigEndpoint.java new file mode 100644 index 00000000..f39c2f29 --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/UpdateRecoveryConfigEndpoint.java @@ -0,0 +1,71 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; +import io.getlime.security.powerauth.integration.support.model.RecoveryConfig; + +public class UpdateRecoveryConfigEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/recovery/config/update"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + // Request + + public static class Request extends RecoveryConfig { + + /** + * Create request from given recovery config. + * @param config Recovery config. + */ + public Request(@NonNull RecoveryConfig config) { + setApplicationId(config.getApplicationId()); + setActivationRecoveryEnabled(config.isActivationRecoveryEnabled()); + setRecoveryPostcardEnabled(config.isRecoveryPostcardEnabled()); + setAllowMultipleRecoveryCodes(config.getAllowMultipleRecoveryCodes()); + setRemotePostcardPublicKey(config.getRemotePostcardPublicKey()); + } + } + + // Response + + public static class Response { + + private boolean updated; + + public boolean isUpdated() { + return updated; + } + + public void setUpdated(boolean updated) { + this.updated = updated; + } + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/ValidateTokenEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/ValidateTokenEndpoint.java new file mode 100644 index 00000000..38a7ecaa --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/ValidateTokenEndpoint.java @@ -0,0 +1,95 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; +import io.getlime.security.powerauth.integration.support.model.TokenInfo; + +public class ValidateTokenEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/token/validate"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + // Request + + public static class Request { + + private String tokenId; + private String tokenDigest; + private String nonce; + private long timestamp; + private String protocolVersion; + + public String getTokenId() { + return tokenId; + } + + public void setTokenId(String tokenId) { + this.tokenId = tokenId; + } + + public String getTokenDigest() { + return tokenDigest; + } + + public void setTokenDigest(String tokenDigest) { + this.tokenDigest = tokenDigest; + } + + public String getNonce() { + return nonce; + } + + public void setNonce(String nonce) { + this.nonce = nonce; + } + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public String getProtocolVersion() { + return protocolVersion; + } + + public void setProtocolVersion(String protocolVersion) { + this.protocolVersion = protocolVersion; + } + } + + // Response + + public static class Response extends TokenInfo { + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/VerifyEcdsaSignatureEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/VerifyEcdsaSignatureEndpoint.java new file mode 100644 index 00000000..20f9d45e --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/VerifyEcdsaSignatureEndpoint.java @@ -0,0 +1,82 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; + +public class VerifyEcdsaSignatureEndpoint implements IServerApiEndpoint { + + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/signature/ecdsa/verify"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + public static class Request { + + private String activationId; + private String data; + private String signature; + + public String getActivationId() { + return activationId; + } + + public void setActivationId(String activationId) { + this.activationId = activationId; + } + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } + } + + public static class Response { + + private boolean signatureValid; + + public boolean isSignatureValid() { + return signatureValid; + } + + public void setSignatureValid(boolean signatureValid) { + this.signatureValid = signatureValid; + } + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/VerifyOfflineSignatureEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/VerifyOfflineSignatureEndpoint.java new file mode 100644 index 00000000..d3a0db8f --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/VerifyOfflineSignatureEndpoint.java @@ -0,0 +1,89 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; +import io.getlime.security.powerauth.integration.support.model.SignatureData; +import io.getlime.security.powerauth.integration.support.model.SignatureInfo; + +public class VerifyOfflineSignatureEndpoint implements IServerApiEndpoint { + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/signature/offline/verify"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + public static class Request { + + private String activationId; + private String data; + private String signature; + private boolean allowBiometry; + + public Request(@NonNull SignatureData sd) { + activationId = sd.getActivationId(); + data = sd.getData(); + signature = sd.getSignature(); + allowBiometry = sd.getAllowBiometry() != null ? sd.getAllowBiometry() : false; + } + + public String getActivationId() { + return activationId; + } + + public void setActivationId(String activationId) { + this.activationId = activationId; + } + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } + + public boolean isAllowBiometry() { + return allowBiometry; + } + + public void setAllowBiometry(boolean allowBiometry) { + this.allowBiometry = allowBiometry; + } + } + + public static class Response extends SignatureInfo { + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/VerifyOnlineSignatureEndpoint.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/VerifyOnlineSignatureEndpoint.java new file mode 100644 index 00000000..63759353 --- /dev/null +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/support/v15/endpoints/VerifyOnlineSignatureEndpoint.java @@ -0,0 +1,120 @@ +/* + * Copyright 2020 Wultra s.r.o. + * + * Licensed 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 io.getlime.security.powerauth.integration.support.v15.endpoints; + +import com.google.gson.reflect.TypeToken; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.getlime.security.powerauth.integration.support.client.IServerApiEndpoint; +import io.getlime.security.powerauth.integration.support.model.SignatureData; +import io.getlime.security.powerauth.integration.support.model.SignatureInfo; +import io.getlime.security.powerauth.integration.support.model.SignatureType; + +public class VerifyOnlineSignatureEndpoint implements IServerApiEndpoint { + @NonNull + @Override + public String getRelativePath() { + return "/rest/v3/signature/verify"; + } + + @Nullable + @Override + public TypeToken getResponseType() { + return TypeToken.get(Response.class); + } + + public static class Request { + + private String activationId; + private String applicationKey; + private String data; + private String signature; + private SignatureType signatureType; + private String signatureVersion; + private Long forcedSignatureVersion; + + public Request(@NonNull SignatureData sd) { + activationId = sd.getActivationId(); + applicationKey = sd.getApplicationKey(); + data = sd.getData(); + signature = sd.getSignature(); + signatureType = sd.getSignatureType(); + signatureVersion = sd.getSignatureVersion(); + forcedSignatureVersion = sd.getForcedSignatureVersion(); + } + + public String getActivationId() { + return activationId; + } + + public void setActivationId(String activationId) { + this.activationId = activationId; + } + + public String getApplicationKey() { + return applicationKey; + } + + public void setApplicationKey(String applicationKey) { + this.applicationKey = applicationKey; + } + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } + + public SignatureType getSignatureType() { + return signatureType; + } + + public void setSignatureType(SignatureType signatureType) { + this.signatureType = signatureType; + } + + public String getSignatureVersion() { + return signatureVersion; + } + + public void setSignatureVersion(String signatureVersion) { + this.signatureVersion = signatureVersion; + } + + public Long getForcedSignatureVersion() { + return forcedSignatureVersion; + } + + public void setForcedSignatureVersion(Long forcedSignatureVersion) { + this.forcedSignatureVersion = forcedSignatureVersion; + } + } + + public static class Response extends SignatureInfo { + } +} diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/tests/TokenStoreTest.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/tests/TokenStoreTest.java index c4c83531..1141400e 100644 --- a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/tests/TokenStoreTest.java +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/tests/TokenStoreTest.java @@ -396,8 +396,9 @@ private boolean calculateAndValidateTokenDigest(@NonNull PowerAuthToken token, @ long timestamp = Long.parseLong(Objects.requireNonNull(headerComponents.get("timestamp"))); String nonce = Objects.requireNonNull(headerComponents.get("nonce")); String digest = Objects.requireNonNull(headerComponents.get("token_digest")); + String version = Objects.requireNonNull(headerComponents.get("version")); - TokenInfo tokenInfo = testHelper.getServerApi().validateToken(tokenId, digest, nonce, timestamp); + TokenInfo tokenInfo = testHelper.getServerApi().validateToken(tokenId, digest, nonce, timestamp, version); assertNotNull(tokenInfo); assertTrue(tokenInfo.isTokenValid()); assertEquals(expectedSignatureType, tokenInfo.getSignatureType());