This commit is contained in:
Efstratios Giannopoulos 2024-06-05 14:40:49 +03:00
parent cfe5247706
commit 6f9129aecf
12 changed files with 78 additions and 76 deletions

View File

@ -1,29 +1,29 @@
package org.opencdmp.model.builder.externalfetcher; package org.opencdmp.model.builder.externalfetcher;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.authorization.Permission;
import org.opencdmp.commons.types.externalfetcher.ExternalFetcherApiSourceConfigurationEntity;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.externalfetcher.ExternalFetcherApiSourceConfiguration;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.authorization.Permission;
import org.opencdmp.commons.types.externalfetcher.ExternalFetcherApiSourceConfigurationEntity;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.externalfetcher.ExternalFetcherApiSourceConfiguration;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.*; import java.util.EnumSet;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class ExternalFetcherApiSourceConfigurationBuilder extends ExternalFetcherBaseSourceConfigurationBuilder<ExternalFetcherApiSourceConfiguration, ExternalFetcherApiSourceConfigurationEntity> { public class ExternalFetcherApiSourceConfigurationBuilder extends ExternalFetcherBaseSourceConfigurationBuilder<ExternalFetcherApiSourceConfiguration, ExternalFetcherApiSourceConfigurationEntity> {
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private final EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
@Autowired @Autowired
@ -45,7 +45,7 @@ public class ExternalFetcherApiSourceConfigurationBuilder extends ExternalFetche
FieldSet resultsFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherApiSourceConfiguration._results)); FieldSet resultsFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherApiSourceConfiguration._results));
FieldSet authFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherApiSourceConfiguration._auth)); FieldSet authFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherApiSourceConfiguration._auth));
FieldSet queriesFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherApiSourceConfiguration._queries)); FieldSet queriesFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherApiSourceConfiguration._queries));
if(!authorizationService.authorize(Permission.EditReferenceType)) return m; if(!this.authorizationService.authorize(Permission.EditReferenceType)) return m;
if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._url))) m.setUrl(d.getUrl()); if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._url))) m.setUrl(d.getUrl());
if (!resultsFields.isEmpty() && d.getResults() != null) { if (!resultsFields.isEmpty() && d.getResults() != null) {

View File

@ -1,15 +1,15 @@
package org.opencdmp.model.builder.externalfetcher; package org.opencdmp.model.builder.externalfetcher;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.authorization.Permission;
import org.opencdmp.commons.types.externalfetcher.ExternalFetcherStaticOptionSourceConfigurationEntity;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.externalfetcher.ExternalFetcherStaticOptionSourceConfiguration;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.authorization.Permission;
import org.opencdmp.commons.types.externalfetcher.ExternalFetcherStaticOptionSourceConfigurationEntity;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.externalfetcher.ExternalFetcherStaticOptionSourceConfiguration;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -19,11 +19,11 @@ import org.springframework.stereotype.Component;
import java.util.EnumSet; import java.util.EnumSet;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class ExternalFetcherStaticOptionSourceConfigurationBuilder extends ExternalFetcherBaseSourceConfigurationBuilder<ExternalFetcherStaticOptionSourceConfiguration, ExternalFetcherStaticOptionSourceConfigurationEntity> { public class ExternalFetcherStaticOptionSourceConfigurationBuilder extends ExternalFetcherBaseSourceConfigurationBuilder<ExternalFetcherStaticOptionSourceConfiguration, ExternalFetcherStaticOptionSourceConfigurationEntity> {
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private final EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
@Autowired @Autowired
@ -44,7 +44,7 @@ public class ExternalFetcherStaticOptionSourceConfigurationBuilder extends Exter
protected ExternalFetcherStaticOptionSourceConfiguration buildChild(FieldSet fields, ExternalFetcherStaticOptionSourceConfigurationEntity d, ExternalFetcherStaticOptionSourceConfiguration m) { protected ExternalFetcherStaticOptionSourceConfiguration buildChild(FieldSet fields, ExternalFetcherStaticOptionSourceConfigurationEntity d, ExternalFetcherStaticOptionSourceConfiguration m) {
FieldSet itemsFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherStaticOptionSourceConfiguration._items)); FieldSet itemsFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherStaticOptionSourceConfiguration._items));
if(!authorizationService.authorize(Permission.EditReferenceType)) return m; if(!this.authorizationService.authorize(Permission.EditReferenceType)) return m;
if (!itemsFields.isEmpty() && d.getItems() != null) { if (!itemsFields.isEmpty() && d.getItems() != null) {
m.setItems(this.builderFactory.builder(StaticBuilder.class).authorize(this.authorize).build(itemsFields, d.getItems())); m.setItems(this.builderFactory.builder(StaticBuilder.class).authorize(this.authorize).build(itemsFields, d.getItems()));

View File

@ -1,12 +1,12 @@
package org.opencdmp.model.censorship.deposit; package org.opencdmp.model.censorship.deposit;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
@ -15,7 +15,7 @@ import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DepositSourceCensor extends BaseCensor { public class DepositSourceCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DepositSourceCensor.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DepositSourceCensor.class));
@ -32,7 +32,7 @@ public class DepositSourceCensor extends BaseCensor {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty()) if (fields == null || fields.isEmpty())
return; return;
this.authService.authorize(Permission.BrowseTenantConfiguration); this.authService.authorizeForce(Permission.BrowseTenantConfiguration);
} }
} }

View File

@ -1,14 +1,12 @@
package org.opencdmp.model.censorship.filetransformer; package org.opencdmp.model.censorship.filetransformer;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import org.opencdmp.model.censorship.deposit.DepositSourceCensor;
import org.opencdmp.model.tenantconfiguration.DepositTenantConfiguration;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
@ -17,7 +15,7 @@ import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class FileTransformerSourceCensor extends BaseCensor { public class FileTransformerSourceCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(FileTransformerSourceCensor.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(FileTransformerSourceCensor.class));
@ -34,7 +32,7 @@ public class FileTransformerSourceCensor extends BaseCensor {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty()) if (fields == null || fields.isEmpty())
return; return;
this.authService.authorize(Permission.BrowseTenantConfiguration); this.authService.authorizeForce(Permission.BrowseTenantConfiguration);
} }
} }

View File

@ -1,12 +1,12 @@
package org.opencdmp.model.censorship.tenantconfiguration; package org.opencdmp.model.censorship.tenantconfiguration;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
@ -15,7 +15,7 @@ import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class CssColorsTenantConfigurationCensor extends BaseCensor { public class CssColorsTenantConfigurationCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(CssColorsTenantConfigurationCensor.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(CssColorsTenantConfigurationCensor.class));
@ -32,7 +32,7 @@ public class CssColorsTenantConfigurationCensor extends BaseCensor {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty()) if (fields == null || fields.isEmpty())
return; return;
this.authService.authorize(Permission.BrowseTenantConfiguration); this.authService.authorizeForce(Permission.BrowseTenantConfiguration);
} }
} }

View File

@ -1,12 +1,12 @@
package org.opencdmp.model.censorship.tenantconfiguration; package org.opencdmp.model.censorship.tenantconfiguration;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
@ -15,7 +15,7 @@ import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DefaultUserLocaleTenantConfigurationCensor extends BaseCensor { public class DefaultUserLocaleTenantConfigurationCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DefaultUserLocaleTenantConfigurationCensor.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DefaultUserLocaleTenantConfigurationCensor.class));
@ -32,7 +32,7 @@ public class DefaultUserLocaleTenantConfigurationCensor extends BaseCensor {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty()) if (fields == null || fields.isEmpty())
return; return;
this.authService.authorize(Permission.BrowseTenantConfiguration); this.authService.authorizeForce(Permission.BrowseTenantConfiguration);
} }
} }

View File

@ -1,15 +1,15 @@
package org.opencdmp.model.censorship.tenantconfiguration; package org.opencdmp.model.censorship.tenantconfiguration;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import org.opencdmp.model.censorship.deposit.DepositSourceCensor;
import org.opencdmp.model.tenantconfiguration.DepositTenantConfiguration;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import org.opencdmp.model.censorship.deposit.DepositSourceCensor;
import org.opencdmp.model.tenantconfiguration.DepositTenantConfiguration;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
@ -18,7 +18,7 @@ import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DepositTenantConfigurationCensor extends BaseCensor { public class DepositTenantConfigurationCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DepositTenantConfigurationCensor.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DepositTenantConfigurationCensor.class));
@ -38,7 +38,7 @@ public class DepositTenantConfigurationCensor extends BaseCensor {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty()) if (fields == null || fields.isEmpty())
return; return;
this.authService.authorize(Permission.BrowseTenantConfiguration); this.authService.authorizeForce(Permission.BrowseTenantConfiguration);
FieldSet sourcesFields = fields.extractPrefixed(this.asIndexerPrefix(DepositTenantConfiguration._sources)); FieldSet sourcesFields = fields.extractPrefixed(this.asIndexerPrefix(DepositTenantConfiguration._sources));
this.censorFactory.censor(DepositSourceCensor.class).censor(sourcesFields, userId); this.censorFactory.censor(DepositSourceCensor.class).censor(sourcesFields, userId);

View File

@ -1,18 +1,15 @@
package org.opencdmp.model.censorship.tenantconfiguration; package org.opencdmp.model.censorship.tenantconfiguration;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import org.opencdmp.model.censorship.deposit.DepositSourceCensor;
import org.opencdmp.model.censorship.filetransformer.FileTransformerSourceCensor;
import org.opencdmp.model.filetransformer.FileTransformerSource;
import org.opencdmp.model.tenantconfiguration.DepositTenantConfiguration;
import org.opencdmp.model.tenantconfiguration.FileTransformerTenantConfiguration;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import org.opencdmp.model.censorship.filetransformer.FileTransformerSourceCensor;
import org.opencdmp.model.tenantconfiguration.FileTransformerTenantConfiguration;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
@ -21,7 +18,7 @@ import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class FileTransformerTenantConfigurationCensor extends BaseCensor { public class FileTransformerTenantConfigurationCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(FileTransformerTenantConfigurationCensor.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(FileTransformerTenantConfigurationCensor.class));
@ -41,7 +38,7 @@ public class FileTransformerTenantConfigurationCensor extends BaseCensor {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty()) if (fields == null || fields.isEmpty())
return; return;
this.authService.authorize(Permission.BrowseTenantConfiguration); this.authService.authorizeForce(Permission.BrowseTenantConfiguration);
FieldSet sourcesFields = fields.extractPrefixed(this.asIndexerPrefix(FileTransformerTenantConfiguration._sources)); FieldSet sourcesFields = fields.extractPrefixed(this.asIndexerPrefix(FileTransformerTenantConfiguration._sources));
this.censorFactory.censor(FileTransformerSourceCensor.class).censor(sourcesFields, userId); this.censorFactory.censor(FileTransformerSourceCensor.class).censor(sourcesFields, userId);

View File

@ -1,12 +1,12 @@
package org.opencdmp.model.censorship.tenantconfiguration; package org.opencdmp.model.censorship.tenantconfiguration;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
@ -15,7 +15,7 @@ import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class LogoTenantConfigurationCensor extends BaseCensor { public class LogoTenantConfigurationCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(LogoTenantConfigurationCensor.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(LogoTenantConfigurationCensor.class));
@ -32,7 +32,7 @@ public class LogoTenantConfigurationCensor extends BaseCensor {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty()) if (fields == null || fields.isEmpty())
return; return;
this.authService.authorize(Permission.BrowseTenantConfiguration); this.authService.authorizeForce(Permission.BrowseTenantConfiguration);
} }
} }

View File

@ -1,14 +1,14 @@
package org.opencdmp.model.censorship.tenantconfiguration; package org.opencdmp.model.censorship.tenantconfiguration;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import org.opencdmp.model.tenantconfiguration.TenantConfiguration;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import org.opencdmp.model.tenantconfiguration.TenantConfiguration;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class TenantConfigurationCensor extends BaseCensor { public class TenantConfigurationCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TenantConfigurationCensor.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TenantConfigurationCensor.class));
@ -37,7 +37,7 @@ public class TenantConfigurationCensor extends BaseCensor {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty()) if (fields == null || fields.isEmpty())
return; return;
this.authService.authorize(Permission.BrowseTenantConfiguration); this.authService.authorizeForce(Permission.BrowseTenantConfiguration);
FieldSet cssColorsFields = fields.extractPrefixed(this.asIndexerPrefix(TenantConfiguration._cssColors)); FieldSet cssColorsFields = fields.extractPrefixed(this.asIndexerPrefix(TenantConfiguration._cssColors));
this.censorFactory.censor(CssColorsTenantConfigurationCensor.class).censor(cssColorsFields, userId); this.censorFactory.censor(CssColorsTenantConfigurationCensor.class).censor(cssColorsFields, userId);

View File

@ -18,7 +18,9 @@ import org.opencdmp.commonmodels.models.FileEnvelopeModel;
import org.opencdmp.commonmodels.models.description.DescriptionModel; import org.opencdmp.commonmodels.models.description.DescriptionModel;
import org.opencdmp.commonmodels.models.dmp.DmpModel; import org.opencdmp.commonmodels.models.dmp.DmpModel;
import org.opencdmp.commons.JsonHandlingService; import org.opencdmp.commons.JsonHandlingService;
import org.opencdmp.commons.enums.*; import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.commons.enums.StorageType;
import org.opencdmp.commons.enums.TenantConfigurationType;
import org.opencdmp.commons.scope.tenant.TenantScope; import org.opencdmp.commons.scope.tenant.TenantScope;
import org.opencdmp.commons.scope.user.UserScope; import org.opencdmp.commons.scope.user.UserScope;
import org.opencdmp.commons.types.filetransformer.FileTransformerSourceEntity; import org.opencdmp.commons.types.filetransformer.FileTransformerSourceEntity;
@ -33,7 +35,7 @@ import org.opencdmp.model.builder.commonmodels.dmp.DmpCommonModelBuilder;
import org.opencdmp.model.description.Description; import org.opencdmp.model.description.Description;
import org.opencdmp.model.dmp.Dmp; import org.opencdmp.model.dmp.Dmp;
import org.opencdmp.model.file.RepositoryFileFormat; import org.opencdmp.model.file.RepositoryFileFormat;
import org.opencdmp.model.persist.*; import org.opencdmp.model.persist.StorageFilePersist;
import org.opencdmp.model.tenantconfiguration.TenantConfiguration; import org.opencdmp.model.tenantconfiguration.TenantConfiguration;
import org.opencdmp.query.DescriptionQuery; import org.opencdmp.query.DescriptionQuery;
import org.opencdmp.query.DmpQuery; import org.opencdmp.query.DmpQuery;
@ -233,7 +235,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
@Override @Override
public org.opencdmp.model.file.FileEnvelope exportDmp(UUID dmpId, String repositoryId, String format) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException { public org.opencdmp.model.file.FileEnvelope exportDmp(UUID dmpId, String repositoryId, String format) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException {
this.authorizationService.authorize(Permission.EditDmp); this.authorizationService.authorizeForce(Permission.EditDmp);
//GK: First get the right client //GK: First get the right client
FileTransformerRepository repository = this.getRepository(repositoryId); FileTransformerRepository repository = this.getRepository(repositoryId);
if (repository == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{format, FileTransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (repository == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{format, FileTransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale()));
@ -253,7 +255,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
@Override @Override
public org.opencdmp.model.file.FileEnvelope exportDescription(UUID descriptionId, String repositoryId, String format) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException { public org.opencdmp.model.file.FileEnvelope exportDescription(UUID descriptionId, String repositoryId, String format) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException {
this.authorizationService.authorize(Permission.EditDmp); this.authorizationService.authorizeForce(Permission.EditDmp);
//GK: First get the right client //GK: First get the right client
FileTransformerRepository repository = this.getRepository(repositoryId); FileTransformerRepository repository = this.getRepository(repositoryId);
if (repository == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{format, FileTransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (repository == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{format, FileTransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale()));
@ -294,7 +296,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
@Override @Override
public DmpModel importDmp(MultipartFile file, String repositoryId, String format) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException, JAXBException { public DmpModel importDmp(MultipartFile file, String repositoryId, String format) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException, IOException, JAXBException {
this.authorizationService.authorize(Permission.NewDmp); this.authorizationService.authorizeForce(Permission.NewDmp);
if (file == null) return null; if (file == null) return null;

View File

@ -109,8 +109,8 @@ permissions:
BrowseNotificationTemplate: BrowseNotificationTemplate:
roles: [ ] roles: [ ]
clients: [ ] clients: [ ]
allowAnonymous: true allowAnonymous: false
allowAuthenticated: true allowAuthenticated: false
EditNotificationTemplate: EditNotificationTemplate:
roles: roles:
- Admin - Admin
@ -132,7 +132,12 @@ permissions:
BrowseTenantConfiguration: BrowseTenantConfiguration:
roles: roles:
- Admin - Admin
- InstallationAdmin
- User
- TenantAdmin - TenantAdmin
- TenantUser
- TenantPlanManager
- TenantConfigManager
claims: [ ] claims: [ ]
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
@ -142,8 +147,8 @@ permissions:
- Admin - Admin
- TenantAdmin - TenantAdmin
clients: [ ] clients: [ ]
allowAnonymous: true allowAnonymous: false
allowAuthenticated: true allowAuthenticated: false
DeleteTenantConfiguration: DeleteTenantConfiguration:
roles: roles:
- Admin - Admin