use of org.apache.archiva.redback.rbac.RBACManager in project archiva by apache.
the class ArchivaRbacManager method saveOperation.
@Override
public Operation saveOperation(Operation operation) throws RbacObjectInvalidException, RbacManagerException {
boolean allFailed = true;
Exception lastException = null;
for (RBACManager rbacManager : rbacManagersPerId.values()) {
try {
if (!rbacManager.isReadOnly()) {
operation = rbacManager.saveOperation(operation);
allFailed = false;
}
} catch (Exception e) {
lastException = e;
}
}
if (lastException != null && allFailed) {
throw new RbacManagerException(lastException.getMessage(), lastException);
}
return operation;
}
use of org.apache.archiva.redback.rbac.RBACManager in project archiva by apache.
the class ArchivaRbacManager method initialize.
@Override
public void initialize() {
try {
List<String> rbacManagerIds = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration().getRbacManagerImpls();
clearCaches();
if (rbacManagerIds.isEmpty()) {
rbacManagerIds.add(RedbackRuntimeConfigurationAdmin.DEFAULT_RBAC_MANAGER_IMPL);
}
log.info("use rbacManagerIds: '{}'", rbacManagerIds);
this.rbacManagersPerId = new LinkedHashMap<>(rbacManagerIds.size());
for (String id : rbacManagerIds) {
if (StringUtils.equalsIgnoreCase("jdo", id)) {
id = RedbackRuntimeConfigurationAdmin.DEFAULT_RBAC_MANAGER_IMPL;
}
RBACManager rbacManager = applicationContext.getBean("rbacManager#" + id, RBACManager.class);
rbacManagersPerId.put(id, rbacManager);
}
} catch (RepositoryAdminException e) {
log.error(e.getMessage(), e);
throw new RuntimeException(e.getMessage(), e);
}
}
use of org.apache.archiva.redback.rbac.RBACManager in project archiva by apache.
the class ArchivaRbacManager method getAllPermissions.
@Override
public List<Permission> getAllPermissions() throws RbacManagerException {
Map<String, Permission> allPermissions = new HashMap<>();
boolean allFailed = true;
Exception lastException = null;
for (RBACManager rbacManager : rbacManagersPerId.values()) {
try {
List<Permission> permissions = rbacManager.getAllPermissions();
for (Permission p : permissions) {
allPermissions.put(p.getName(), p);
}
allFailed = false;
} catch (Exception e) {
lastException = e;
}
}
if (lastException != null && allFailed) {
throw new RbacManagerException(lastException.getMessage(), lastException);
}
return new ArrayList<>(allPermissions.values());
}
use of org.apache.archiva.redback.rbac.RBACManager in project archiva by apache.
the class ArchivaRbacManager method getPermission.
@Override
public Permission getPermission(String permissionName) throws RbacObjectNotFoundException, RbacManagerException {
Permission el = permissionsCache.get(permissionName);
if (el != null) {
return el;
}
Exception lastException = null;
for (RBACManager rbacManager : rbacManagersPerId.values()) {
try {
Permission p = rbacManager.getPermission(permissionName);
if (p != null) {
permissionsCache.put(permissionName, p);
return p;
}
} catch (Exception e) {
lastException = e;
}
}
if (lastException != null) {
throw new RbacManagerException(lastException.getMessage(), lastException);
}
return null;
}
use of org.apache.archiva.redback.rbac.RBACManager in project archiva by apache.
the class DefaultRedbackRuntimeConfigurationService method getRbacManagerImplementationInformations.
@Override
public List<RBACManagerImplementationInformation> getRbacManagerImplementationInformations() throws ArchivaRestServiceException {
Map<String, RBACManager> beans = applicationContext.getBeansOfType(RBACManager.class);
if (beans.isEmpty()) {
return Collections.emptyList();
}
List<RBACManagerImplementationInformation> informations = new ArrayList<>(beans.size());
for (Map.Entry<String, RBACManager> entry : beans.entrySet()) {
RBACManager rbacManager = applicationContext.getBean(entry.getKey(), RBACManager.class);
if (rbacManager.isFinalImplementation()) {
RBACManagerImplementationInformation information = new RBACManagerImplementationInformation();
information.setBeanId(StringUtils.substringAfter(entry.getKey(), "#"));
information.setDescriptionKey(rbacManager.getDescriptionKey());
information.setReadOnly(rbacManager.isReadOnly());
informations.add(information);
}
}
return informations;
}
Aggregations