PL-10619 REST should have an ability to work without security token for entities with constraints (rename application property)

This commit is contained in:
Andrey Subbotin 2018-04-09 09:36:52 +04:00
parent fccfda8f17
commit 7bafde32fd
3 changed files with 6 additions and 6 deletions

View File

@ -673,7 +673,7 @@ public class EntityImportExport implements EntityImportExportAPI {
} }
protected boolean useSecurityToken() { protected boolean useSecurityToken() {
return globalConfig.getRestUseSecurityTokenForClient(); return globalConfig.getRestRequiresSecurityToken();
} }
protected Entity findReferenceEntity(Entity entity, EntityImportViewProperty viewProperty, CommitContext commitContext, protected Entity findReferenceEntity(Entity entity, EntityImportViewProperty viewProperty, CommitContext commitContext,

View File

@ -231,7 +231,7 @@ public class EntitySerialization implements EntitySerializationAPI {
writeFields(entity, jsonObject, view, cyclicReferences); writeFields(entity, jsonObject, view, cyclicReferences);
} }
if (globalConfig.getRestUseSecurityTokenForClient()) { if (globalConfig.getRestRequiresSecurityToken()) {
if (entity instanceof BaseGenericIdEntity || entity instanceof EmbeddableEntity) { if (entity instanceof BaseGenericIdEntity || entity instanceof EmbeddableEntity) {
SecurityState securityState = getSecurityState(entity); SecurityState securityState = getSecurityState(entity);
if (securityState != null) { 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"); JsonPrimitive securityTokenJonPrimitive = jsonObject.getAsJsonPrimitive("__securityToken");
if (securityTokenJonPrimitive != null) { if (securityTokenJonPrimitive != null) {
byte[] securityToken = Base64.getDecoder().decode(securityTokenJonPrimitive.getAsString()); byte[] securityToken = Base64.getDecoder().decode(securityTokenJonPrimitive.getAsString());
@ -572,7 +572,7 @@ public class EntitySerialization implements EntitySerializationAPI {
Entity entity = metadata.create(metaClass); Entity entity = metadata.create(metaClass);
clearFields(entity); clearFields(entity);
readFields(jsonObject, entity); readFields(jsonObject, entity);
if (globalConfig.getRestUseSecurityTokenForClient() && entity instanceof EmbeddableEntity) { if (globalConfig.getRestRequiresSecurityToken() && entity instanceof EmbeddableEntity) {
JsonPrimitive securityTokenJonPrimitive = jsonObject.getAsJsonPrimitive("__securityToken"); JsonPrimitive securityTokenJonPrimitive = jsonObject.getAsJsonPrimitive("__securityToken");
if (securityTokenJonPrimitive != null) { if (securityTokenJonPrimitive != null) {
byte[] securityToken = Base64.getDecoder().decode(securityTokenJonPrimitive.getAsString()); byte[] securityToken = Base64.getDecoder().decode(securityTokenJonPrimitive.getAsString());

View File

@ -238,8 +238,8 @@ public interface GlobalConfig extends Config {
/** /**
* @return true if REST doesn't check security token for entities with security constraints * @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) @Source(type = SourceType.DATABASE)
@DefaultBoolean(false) @DefaultBoolean(false)
boolean getRestUseSecurityTokenForClient(); boolean getRestRequiresSecurityToken();
} }