From 7bafde32fde203ae3550cb5ee5f8de0a70298aa4 Mon Sep 17 00:00:00 2001 From: Andrey Subbotin Date: Mon, 9 Apr 2018 09:36:52 +0400 Subject: [PATCH] PL-10619 REST should have an ability to work without security token for entities with constraints (rename application property) --- .../cuba/core/app/importexport/EntityImportExport.java | 2 +- .../cuba/core/app/serialization/EntitySerialization.java | 6 +++--- .../src/com/haulmont/cuba/core/global/GlobalConfig.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/core/src/com/haulmont/cuba/core/app/importexport/EntityImportExport.java b/modules/core/src/com/haulmont/cuba/core/app/importexport/EntityImportExport.java index 441bbb7ef5..09cf1d5432 100644 --- a/modules/core/src/com/haulmont/cuba/core/app/importexport/EntityImportExport.java +++ b/modules/core/src/com/haulmont/cuba/core/app/importexport/EntityImportExport.java @@ -673,7 +673,7 @@ public class EntityImportExport implements EntityImportExportAPI { } protected boolean useSecurityToken() { - return globalConfig.getRestUseSecurityTokenForClient(); + return globalConfig.getRestRequiresSecurityToken(); } protected Entity findReferenceEntity(Entity entity, EntityImportViewProperty viewProperty, CommitContext commitContext, diff --git a/modules/global/src/com/haulmont/cuba/core/app/serialization/EntitySerialization.java b/modules/global/src/com/haulmont/cuba/core/app/serialization/EntitySerialization.java index b0015e6211..09953619b3 100644 --- a/modules/global/src/com/haulmont/cuba/core/app/serialization/EntitySerialization.java +++ b/modules/global/src/com/haulmont/cuba/core/app/serialization/EntitySerialization.java @@ -231,7 +231,7 @@ public class EntitySerialization implements EntitySerializationAPI { writeFields(entity, jsonObject, view, cyclicReferences); } - if (globalConfig.getRestUseSecurityTokenForClient()) { + if (globalConfig.getRestRequiresSecurityToken()) { if (entity instanceof BaseGenericIdEntity || entity instanceof EmbeddableEntity) { SecurityState securityState = getSecurityState(entity); if (securityState != null) { @@ -461,7 +461,7 @@ public class EntitySerialization implements EntitySerializationAPI { } } - if (globalConfig.getRestUseSecurityTokenForClient() && entity instanceof BaseGenericIdEntity) { + if (globalConfig.getRestRequiresSecurityToken() && entity instanceof BaseGenericIdEntity) { JsonPrimitive securityTokenJonPrimitive = jsonObject.getAsJsonPrimitive("__securityToken"); if (securityTokenJonPrimitive != null) { byte[] securityToken = Base64.getDecoder().decode(securityTokenJonPrimitive.getAsString()); @@ -572,7 +572,7 @@ public class EntitySerialization implements EntitySerializationAPI { Entity entity = metadata.create(metaClass); clearFields(entity); readFields(jsonObject, entity); - if (globalConfig.getRestUseSecurityTokenForClient() && entity instanceof EmbeddableEntity) { + if (globalConfig.getRestRequiresSecurityToken() && entity instanceof EmbeddableEntity) { JsonPrimitive securityTokenJonPrimitive = jsonObject.getAsJsonPrimitive("__securityToken"); if (securityTokenJonPrimitive != null) { byte[] securityToken = Base64.getDecoder().decode(securityTokenJonPrimitive.getAsString()); diff --git a/modules/global/src/com/haulmont/cuba/core/global/GlobalConfig.java b/modules/global/src/com/haulmont/cuba/core/global/GlobalConfig.java index 915dbbe684..9d0f8876be 100644 --- a/modules/global/src/com/haulmont/cuba/core/global/GlobalConfig.java +++ b/modules/global/src/com/haulmont/cuba/core/global/GlobalConfig.java @@ -238,8 +238,8 @@ public interface GlobalConfig extends Config { /** * @return true if REST doesn't check security token for entities with security constraints */ - @Property("cuba.rest.useSecurityTokenForClient") + @Property("cuba.rest.requiresSecurityToken") @Source(type = SourceType.DATABASE) @DefaultBoolean(false) - boolean getRestUseSecurityTokenForClient(); + boolean getRestRequiresSecurityToken(); } \ No newline at end of file