From 5f3e5fc261ae3f2b35d5e684846c6c2e7d45ed5d Mon Sep 17 00:00:00 2001 From: Stanimir Penkov Date: Thu, 20 Dec 2018 11:55:38 +0200 Subject: [PATCH 1/7] =?UTF-8?q?NY-6215:=20Add=20endpoint=20for=20updating?= =?UTF-8?q?=20login=20option=E2=80=99s=20searchable=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stanimir Penkov --- .../AccountRepositoryAdditional.java | 3 + .../AccountRepositoryAdditionalImpl.java | 71 ++++++++++++++++--- .../account/services/AccountServiceImpl.java | 52 ++++++++++++++ 3 files changed, 116 insertions(+), 10 deletions(-) diff --git a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditional.java b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditional.java index c6f039d..dd43e40 100644 --- a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditional.java +++ b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditional.java @@ -12,6 +12,7 @@ import org.springframework.stereotype.Repository; import biz.nynja.account.grpc.CompletePendingAccountCreationRequest; import biz.nynja.account.grpc.UpdateAccountRequest; import biz.nynja.account.grpc.ErrorResponse.Cause; +import biz.nynja.account.grpc.SearchableOption; import biz.nynja.account.models.Account; import biz.nynja.account.models.AccountByProfileId; import biz.nynja.account.models.AuthenticationProvider; @@ -58,4 +59,6 @@ public interface AccountRepositoryAdditional { Optional searchAccountByLoginOption(AuthenticationProvider loginOption) throws IncorrectAccountCountException; void removeNullsForSearchableOption(); + + boolean updateSearchableOption(UUID profileId, String authProviderType, String authProvider, SearchableOption searchableOption); } diff --git a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java index f0e92ca..c3d61c1 100644 --- a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java +++ b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java @@ -36,6 +36,7 @@ import biz.nynja.account.grpc.CompletePendingAccountCreationRequest; import biz.nynja.account.grpc.ContactType; import biz.nynja.account.grpc.ErrorResponse.Cause; import biz.nynja.account.grpc.Role; +import biz.nynja.account.grpc.SearchableOption; import biz.nynja.account.grpc.UpdateAccountRequest; import biz.nynja.account.models.Account; import biz.nynja.account.models.AccountBuilder; @@ -747,6 +748,54 @@ public class AccountRepositoryAdditionalImpl implements AccountRepositoryAdditio return false; } + @Override + public boolean updateSearchableOption(UUID profileId, String authProviderType, String authProvider, + SearchableOption searchableOption) { + if (authProviderType == null || authProvider == null || authProviderType.isEmpty() || authProvider.isEmpty()) { + logger.error( + "Error updating searchable option in profile {}. Auth provider info (type and/or identifier) is missing.", + profileId); + return false; + } + + Profile existingProfile = profileRepository.findByProfileId(profileId); + if (existingProfile == null) { + logger.error( + "Error updating searchable option in profile {}. Existing profile with the provided id {} was not found.", + profileId); + return false; + } + + ProfileByAuthenticationProvider existingProfileByAuthenticationProvider = profileByAuthenticationProviderRepository + .findByAuthenticationProviderAndAuthenticationProviderType(authProvider, authProviderType); + if (existingProfileByAuthenticationProvider == null) { + logger.error( + "Error updating searchable option in profileByAuthenticationProvider. Existing profileByAuthenticationProvider for {}:{} was not found.", + authProviderType, authProvider); + return false; + } + + CassandraBatchOperations batchOperations = cassandraTemplate.batchOps(); + WriteResult wr = null; + try { + updateSearchableInProfileByAuthenticationProvider(batchOperations, existingProfileByAuthenticationProvider, + searchableOption); + if (!updateSearchableInProfile(batchOperations, existingProfile, authProviderType, authProvider, + searchableOption)) { + return false; + } + wr = batchOperations.execute(); + } catch (IllegalArgumentException | IllegalStateException e) { + logger.debug("Exception while updating searchable option for auth provider {}:{} in profile{}: {}.", + authProviderType, authProvider, profileId, e.getMessage()); + } + if (wr != null && wr.wasApplied()) { + logger.info("Successfully updated searchable option in profile {}.", profileId); + return true; + } + return false; + } + @Override public Optional getAccountByLoginOption(AuthenticationProvider loginOption) throws IncorrectAccountCountException { @@ -887,11 +936,12 @@ public class AccountRepositoryAdditionalImpl implements AccountRepositoryAdditio CassandraBatchOperations batchOperations = cassandraTemplate.batchOps(); WriteResult wr; try { - setDefaultSearchableInProfileByAuthenticationProvider(batchOperations, - profilesByAuthenticationProvider.get(i)); - if (!setDefaultSearchableInProfile(batchOperations, profileToUpdate, + updateSearchableInProfileByAuthenticationProvider(batchOperations, + profilesByAuthenticationProvider.get(i), SearchableOption.SEARCH_ENABLED); + if (!updateSearchableInProfile(batchOperations, profileToUpdate, profilesByAuthenticationProvider.get(i).getAuthenticationProviderType(), - profilesByAuthenticationProvider.get(i).getAuthenticationProvider())) { + profilesByAuthenticationProvider.get(i).getAuthenticationProvider(), + SearchableOption.SEARCH_ENABLED)) { logger.error( "Error replacing null with default searchable option for profile {}: auth provider {}:{}.", profilesByAuthenticationProvider.get(i).getProfileId(), @@ -915,14 +965,14 @@ public class AccountRepositoryAdditionalImpl implements AccountRepositoryAdditio } } - private void setDefaultSearchableInProfileByAuthenticationProvider(CassandraBatchOperations batchOps, - ProfileByAuthenticationProvider profileByAuthenticationProvider) { - profileByAuthenticationProvider.setSearchable(Boolean.TRUE); + private void updateSearchableInProfileByAuthenticationProvider(CassandraBatchOperations batchOps, + ProfileByAuthenticationProvider profileByAuthenticationProvider, SearchableOption searchableOption) { + profileByAuthenticationProvider.setSearchable(AuthenticationProvider.isSearchDisabled(searchableOption)); batchOps.update(profileByAuthenticationProvider); } - private boolean setDefaultSearchableInProfile(CassandraBatchOperations batchOps, Profile profileToUpdate, - String authProviderType, String authProvider) { + private boolean updateSearchableInProfile(CassandraBatchOperations batchOps, Profile profileToUpdate, + String authProviderType, String authProvider, SearchableOption searchableOption) { Set authProviderSet = profileToUpdate.getAuthenticationProviders(); if (authProviderSet == null) { logger.error("No existing auth providers found for profile {}.", profileToUpdate.getProfileId()); @@ -930,7 +980,8 @@ public class AccountRepositoryAdditionalImpl implements AccountRepositoryAdditio } AuthenticationProvider authProviderToUpdate = AuthenticationProvider - .createAuthenticationProviderWithSearchableOption(authProviderType, authProvider, Boolean.TRUE); + .createAuthenticationProviderWithSearchableOption(authProviderType, authProvider, + AuthenticationProvider.isSearchDisabled(searchableOption)); Optional currentAuthProvider = AuthenticationProvider .foundExistingAuthenticationProviderByTypeAndValue(authProviderType, authProvider, authProviderSet); if (!currentAuthProvider.isPresent()) { diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index ae63d02..9511276 100644 --- a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java +++ b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java @@ -50,6 +50,7 @@ import biz.nynja.account.grpc.SearchResultDetails; import biz.nynja.account.grpc.StatusResponse; import biz.nynja.account.grpc.UpdateAccountRequest; import biz.nynja.account.grpc.UpdateAuthenticationProviderRequest; +import biz.nynja.account.grpc.UpdateSearchableOptionRequest; import biz.nynja.account.models.Account; import biz.nynja.account.models.AccountByProfileId; import biz.nynja.account.models.AccountByQrCode; @@ -1184,4 +1185,55 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas responseObserver.onCompleted(); } + @Override + @PerformPermissionCheck + @Permitted(role = RoleConstants.ADMIN) + @Permitted(role = RoleConstants.USER) + public void updateSearchableOption(UpdateSearchableOptionRequest request, + StreamObserver responseObserver) { + if (request.getAuthenticationType() == null || request.getAuthenticationType().isEmpty()) { + logAndBuildGrpcStatusResponse(responseObserver, StatusResponse.newBuilder(), + "Missing authentication provider type", "", Cause.MISSING_AUTH_PROVIDER_TYPE); + return; + } + if (request.getAuthenticationIdentifier() == null || request.getAuthenticationIdentifier().isEmpty()) { + logAndBuildGrpcStatusResponse(responseObserver, StatusResponse.newBuilder(), + "Missing authentication provider identifier", "", Cause.MISSING_AUTH_PROVIDER_ID); + return; + } + if (request.getProfileId() == null || request.getProfileId().isEmpty()) { + logAndBuildGrpcStatusResponse(responseObserver, StatusResponse.newBuilder(), "Missing profile id", "", + Cause.MISSING_PROFILE_ID); + return; + } + if (!util.isValidUuid(request.getProfileId())) { + logAndBuildGrpcStatusResponse(responseObserver, StatusResponse.newBuilder(), "Invalid profile id", "", + Cause.INVALID_PROFILE_ID); + return; + } + + List existingAccountsForProfile = accountByProfileIdRepository + .findAllByProfileId(UUID.fromString(request.getProfileId())); + + if (!permissionsValidator.isRpcAllowed(existingAccountsForProfile)) { + logAndBuildGrpcStatusResponse(responseObserver, StatusResponse.newBuilder(), + "Can not update searchable option for authentication provider in profile {}.", + request.getProfileId(), Cause.ERROR_PERMISSION_DENIED); + return; + } + + if (!accountRepositoryAdditional.updateSearchableOption(UUID.fromString(request.getProfileId()), + request.getAuthenticationType(), request.getAuthenticationIdentifier(), request.getSearchOption())) { + logAndBuildGrpcStatusResponse(responseObserver, StatusResponse.newBuilder(), + "Can not update searchable option for authentication provider in profile {}.", + request.getProfileId(), Cause.ERROR_UPDATING_SEARCHABLE_OPTION); + return; + } + + logger.info("Successfully updated authentication provider {}:{} with searchable option {} in profile {}", + request.getAuthenticationType(), request.getAuthenticationIdentifier(), request.getSearchOption(), + request.getProfileId()); + responseObserver.onNext(StatusResponse.newBuilder().setStatus("SUCCESS").build()); + responseObserver.onCompleted(); + } } -- GitLab From 4b78f5e80aa53ffc1167c31bf37b22bf6265a947 Mon Sep 17 00:00:00 2001 From: Stanimir Penkov Date: Thu, 20 Dec 2018 12:02:46 +0200 Subject: [PATCH 2/7] NY-6215: Additional check added. Signed-off-by: Stanimir Penkov --- .../repositories/AccountRepositoryAdditionalImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java index c3d61c1..16aed3b 100644 --- a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java +++ b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java @@ -757,6 +757,11 @@ public class AccountRepositoryAdditionalImpl implements AccountRepositoryAdditio profileId); return false; } + if (searchableOption == null) { + logger.error("Error updating searchable option {}:{} in profile {}. Can not use null for searchableOption.", + authProviderType, authProvider, profileId); + return false; + } Profile existingProfile = profileRepository.findByProfileId(profileId); if (existingProfile == null) { -- GitLab From c5b80966c7fd10ea630f450e2f07e8e924e9a09f Mon Sep 17 00:00:00 2001 From: Stanimir Penkov Date: Thu, 20 Dec 2018 17:56:13 +0200 Subject: [PATCH 3/7] NY-6215: Code Review Changes - extracted validation method; - additional check added. Signed-off-by: Stanimir Penkov --- .../account/services/AccountServiceImpl.java | 58 +++++++++++++------ 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index 9511276..07c0e57 100644 --- a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java +++ b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java @@ -1191,24 +1191,11 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas @Permitted(role = RoleConstants.USER) public void updateSearchableOption(UpdateSearchableOptionRequest request, StreamObserver responseObserver) { - if (request.getAuthenticationType() == null || request.getAuthenticationType().isEmpty()) { - logAndBuildGrpcStatusResponse(responseObserver, StatusResponse.newBuilder(), - "Missing authentication provider type", "", Cause.MISSING_AUTH_PROVIDER_TYPE); - return; - } - if (request.getAuthenticationIdentifier() == null || request.getAuthenticationIdentifier().isEmpty()) { - logAndBuildGrpcStatusResponse(responseObserver, StatusResponse.newBuilder(), - "Missing authentication provider identifier", "", Cause.MISSING_AUTH_PROVIDER_ID); - return; - } - if (request.getProfileId() == null || request.getProfileId().isEmpty()) { - logAndBuildGrpcStatusResponse(responseObserver, StatusResponse.newBuilder(), "Missing profile id", "", - Cause.MISSING_PROFILE_ID); - return; - } - if (!util.isValidUuid(request.getProfileId())) { - logAndBuildGrpcStatusResponse(responseObserver, StatusResponse.newBuilder(), "Invalid profile id", "", - Cause.INVALID_PROFILE_ID); + + Validation validation = validateUpdateSearchableOptionRequest(request); + if (validation.hasErrors()) { + logAndBuildGrpcStatusResponse(responseObserver, StatusResponse.newBuilder(), validation.getErrorMessage(), + "", validation.getCause().get()); return; } @@ -1236,4 +1223,39 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas responseObserver.onNext(StatusResponse.newBuilder().setStatus("SUCCESS").build()); responseObserver.onCompleted(); } + + private Validation validateUpdateSearchableOptionRequest(UpdateSearchableOptionRequest request) { + Validation validation = new Validation(); + + if (request.getAuthenticationType() == null || request.getAuthenticationType().isEmpty()) { + validation.addError( + new ValidationError("Missing authentication provider type", Cause.MISSING_AUTH_PROVIDER_TYPE)); + return validation; + } + + if (!request.getAuthenticationType().equals(AuthenticationType.EMAIL.toString()) + && !request.getAuthenticationType().equals(AuthenticationType.PHONE.toString())) { + validation.addError( + new ValidationError("Missing authentication provider type", Cause.INVALID_AUTH_PROVIDER_TYPE)); + return validation; + } + + if (request.getAuthenticationIdentifier() == null || request.getAuthenticationIdentifier().isEmpty()) { + validation.addError( + new ValidationError("Missing authentication provider identifier", Cause.MISSING_AUTH_PROVIDER_ID)); + return validation; + } + + if (request.getProfileId() == null || request.getProfileId().isEmpty()) { + validation.addError(new ValidationError("Missing profile id", Cause.MISSING_PROFILE_ID)); + return validation; + } + + if (!util.isValidUuid(request.getProfileId())) { + validation.addError(new ValidationError("Invalid profile id", Cause.INVALID_PROFILE_ID)); + return validation; + } + + return validation; + } } -- GitLab From 56f5323843485a4ea03a15a00ce7e7793d9cadcb Mon Sep 17 00:00:00 2001 From: Stanimir Penkov Date: Thu, 3 Jan 2019 11:56:32 +0200 Subject: [PATCH 4/7] NY-6215: Change error message Signed-off-by: Stanimir Penkov --- .../java/biz/nynja/account/services/AccountServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index 07c0e57..fef7825 100644 --- a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java +++ b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java @@ -1236,7 +1236,7 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas if (!request.getAuthenticationType().equals(AuthenticationType.EMAIL.toString()) && !request.getAuthenticationType().equals(AuthenticationType.PHONE.toString())) { validation.addError( - new ValidationError("Missing authentication provider type", Cause.INVALID_AUTH_PROVIDER_TYPE)); + new ValidationError("Invalid authentication provider type", Cause.INVALID_AUTH_PROVIDER_TYPE)); return validation; } -- GitLab From 7b72be7686a0fd4919f90deb97bc460354d7a8ac Mon Sep 17 00:00:00 2001 From: Stanimir Penkov Date: Thu, 3 Jan 2019 16:36:38 +0200 Subject: [PATCH 5/7] NY-6215: Code Review Changes - extracted method; Signed-off-by: Stanimir Penkov --- .../AccountRepositoryAdditionalImpl.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java index 16aed3b..bcfdf04 100644 --- a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java +++ b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java @@ -751,15 +751,8 @@ public class AccountRepositoryAdditionalImpl implements AccountRepositoryAdditio @Override public boolean updateSearchableOption(UUID profileId, String authProviderType, String authProvider, SearchableOption searchableOption) { - if (authProviderType == null || authProvider == null || authProviderType.isEmpty() || authProvider.isEmpty()) { - logger.error( - "Error updating searchable option in profile {}. Auth provider info (type and/or identifier) is missing.", - profileId); - return false; - } - if (searchableOption == null) { - logger.error("Error updating searchable option {}:{} in profile {}. Can not use null for searchableOption.", - authProviderType, authProvider, profileId); + + if (!haveNeededSearchableOptionData(profileId, authProviderType, authProvider, searchableOption)) { return false; } @@ -801,6 +794,22 @@ public class AccountRepositoryAdditionalImpl implements AccountRepositoryAdditio return false; } + private boolean haveNeededSearchableOptionData(UUID profileId, String authProviderType, String authProvider, + SearchableOption searchableOption) { + if (authProviderType == null || authProvider == null || authProviderType.isEmpty() || authProvider.isEmpty()) { + logger.error( + "Error updating searchable option in profile {}. Auth provider info (type and/or identifier) is missing.", + profileId); + return false; + } + if (searchableOption == null) { + logger.error("Error updating searchable option {}:{} in profile {}. Can not use null for searchableOption.", + authProviderType, authProvider, profileId); + return false; + } + return true; + } + @Override public Optional getAccountByLoginOption(AuthenticationProvider loginOption) throws IncorrectAccountCountException { -- GitLab From 6ce8f5c74c3bcc7b12e9e1ef92cd68aba8197b91 Mon Sep 17 00:00:00 2001 From: Stanimir Penkov Date: Thu, 3 Jan 2019 18:22:56 +0200 Subject: [PATCH 6/7] NY-6215: Code Review Changes - moved validation method; Signed-off-by: Stanimir Penkov --- .../account/services/AccountServiceImpl.java | 38 +------------------ .../nynja/account/validation/Validators.java | 35 +++++++++++++++++ 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index fef7825..15c6145 100644 --- a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java +++ b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java @@ -1192,7 +1192,8 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas public void updateSearchableOption(UpdateSearchableOptionRequest request, StreamObserver responseObserver) { - Validation validation = validateUpdateSearchableOptionRequest(request); + Validation validation = authenticationProvider.validateUpdateSearchableOptionRequest(request.getProfileId(), + request.getAuthenticationType(), request.getAuthenticationIdentifier()); if (validation.hasErrors()) { logAndBuildGrpcStatusResponse(responseObserver, StatusResponse.newBuilder(), validation.getErrorMessage(), "", validation.getCause().get()); @@ -1223,39 +1224,4 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas responseObserver.onNext(StatusResponse.newBuilder().setStatus("SUCCESS").build()); responseObserver.onCompleted(); } - - private Validation validateUpdateSearchableOptionRequest(UpdateSearchableOptionRequest request) { - Validation validation = new Validation(); - - if (request.getAuthenticationType() == null || request.getAuthenticationType().isEmpty()) { - validation.addError( - new ValidationError("Missing authentication provider type", Cause.MISSING_AUTH_PROVIDER_TYPE)); - return validation; - } - - if (!request.getAuthenticationType().equals(AuthenticationType.EMAIL.toString()) - && !request.getAuthenticationType().equals(AuthenticationType.PHONE.toString())) { - validation.addError( - new ValidationError("Invalid authentication provider type", Cause.INVALID_AUTH_PROVIDER_TYPE)); - return validation; - } - - if (request.getAuthenticationIdentifier() == null || request.getAuthenticationIdentifier().isEmpty()) { - validation.addError( - new ValidationError("Missing authentication provider identifier", Cause.MISSING_AUTH_PROVIDER_ID)); - return validation; - } - - if (request.getProfileId() == null || request.getProfileId().isEmpty()) { - validation.addError(new ValidationError("Missing profile id", Cause.MISSING_PROFILE_ID)); - return validation; - } - - if (!util.isValidUuid(request.getProfileId())) { - validation.addError(new ValidationError("Invalid profile id", Cause.INVALID_PROFILE_ID)); - return validation; - } - - return validation; - } } diff --git a/src/main/java/biz/nynja/account/validation/Validators.java b/src/main/java/biz/nynja/account/validation/Validators.java index 930b836..f1f1689 100644 --- a/src/main/java/biz/nynja/account/validation/Validators.java +++ b/src/main/java/biz/nynja/account/validation/Validators.java @@ -346,6 +346,41 @@ public class Validators { } } + public Validation validateUpdateSearchableOptionRequest(String profileId, String authenticationType, + String authenticationIdentifier) { + Validation validation = new Validation(); + if (authenticationType == null || authenticationType.isEmpty()) { + validation.addError( + new ValidationError("Missing authentication provider type", Cause.MISSING_AUTH_PROVIDER_TYPE)); + return validation; + } + + if (!authenticationType.equals(AuthenticationType.EMAIL.toString()) + && !authenticationType.equals(AuthenticationType.PHONE.toString())) { + validation.addError( + new ValidationError("Invalid authentication provider type", Cause.INVALID_AUTH_PROVIDER_TYPE)); + return validation; + } + + if (authenticationIdentifier == null || authenticationIdentifier.isEmpty()) { + validation.addError( + new ValidationError("Missing authentication provider identifier", Cause.MISSING_AUTH_PROVIDER_ID)); + return validation; + } + + if (profileId == null || profileId.isEmpty()) { + validation.addError(new ValidationError("Missing profile id", Cause.MISSING_PROFILE_ID)); + return validation; + } + + if (!isValidUuid(profileId)) { + validation.addError(new ValidationError("Invalid profile id", Cause.INVALID_PROFILE_ID)); + return validation; + } + + return validation; + } + private boolean isValidUuid(String id) { return id.matches("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"); } -- GitLab From 9f46b35be91a7549994e9adc6abe5588904c2a06 Mon Sep 17 00:00:00 2001 From: Stanimir Penkov Date: Fri, 4 Jan 2019 17:30:27 +0200 Subject: [PATCH 7/7] NY-6215: Updated role Signed-off-by: Stanimir Penkov --- .../java/biz/nynja/account/services/AccountServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index 15c6145..a300fb8 100644 --- a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java +++ b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java @@ -1187,7 +1187,7 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas @Override @PerformPermissionCheck - @Permitted(role = RoleConstants.ADMIN) + @Permitted(role = RoleConstants.ACCOUNT_ADMIN) @Permitted(role = RoleConstants.USER) public void updateSearchableOption(UpdateSearchableOptionRequest request, StreamObserver responseObserver) { -- GitLab