From 7c7f3233bb1b9d7b2d25aee2f557205b4fcd0ed3 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 22 Feb 2013 16:04:52 +0000 Subject: [PATCH] make sure rbacmanager is not readonly before chaining write actions git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1449090 13f79535-47bb-0310-9956-ffa450edef68 --- ...faultRedbackRuntimeConfigurationAdmin.java | 5 ++- .../web/security/ArchivaRbacManager.java | 43 +++++++++++++------ 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java index e582f628e..1a2481398 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java @@ -145,8 +145,9 @@ public class DefaultRedbackRuntimeConfigurationAdmin ldapConfiguration.setUseRoleNameAsGroup( userConfiguration.getBoolean( UserConfigurationKeys.LDAP_GROUPS_USE_ROLENAME, false ) ); - ldapConfiguration.setBindAuthenticatorEnabled( - userConfiguration.getBoolean( UserConfigurationKeys.LDAP_BIND_AUTHENTICATOR_ENABLED, false ) ); + boolean ldapBindAuthenticatorEnabled = + userConfiguration.getBoolean( UserConfigurationKeys.LDAP_BIND_AUTHENTICATOR_ENABLED, false ); + ldapConfiguration.setBindAuthenticatorEnabled( ldapBindAuthenticatorEnabled ); redbackRuntimeConfiguration.setMigratedFromRedbackConfiguration( true ); diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java index fd24898bf..e5b144be9 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java @@ -144,8 +144,11 @@ public class ArchivaRbacManager { try { - role = rbacManager.saveRole( role ); - allFailed = false; + if ( !rbacManager.isReadOnly() ) + { + role = rbacManager.saveRole( role ); + allFailed = false; + } } catch ( Exception e ) { @@ -168,8 +171,11 @@ public class ArchivaRbacManager { try { - rbacManager.saveRoles( roles ); - allFailed = false; + if ( !rbacManager.isReadOnly() ) + { + rbacManager.saveRoles( roles ); + allFailed = false; + } } catch ( Exception e ) { @@ -294,8 +300,11 @@ public class ArchivaRbacManager { try { - permission = rbacManager.savePermission( permission ); - allFailed = false; + if ( rbacManager.isReadOnly() ) + { + permission = rbacManager.savePermission( permission ); + allFailed = false; + } } catch ( Exception e ) { @@ -416,8 +425,11 @@ public class ArchivaRbacManager { try { - operation = rbacManager.saveOperation( operation ); - allFailed = false; + if ( !rbacManager.isReadOnly() ) + { + operation = rbacManager.saveOperation( operation ); + allFailed = false; + } } catch ( Exception e ) { @@ -537,9 +549,11 @@ public class ArchivaRbacManager { try { - resource = rbacManager.saveResource( resource ); - - allFailed = false; + if ( !rbacManager.isReadOnly() ) + { + resource = rbacManager.saveResource( resource ); + allFailed = false; + } } catch ( Exception e ) { @@ -659,8 +673,11 @@ public class ArchivaRbacManager { try { - userAssignment = rbacManager.saveUserAssignment( userAssignment ); - allFailed = false; + if ( !rbacManager.isReadOnly() ) + { + userAssignment = rbacManager.saveUserAssignment( userAssignment ); + allFailed = false; + } } catch ( Exception e ) { -- 2.39.5