From: Olivier Lamy Date: Mon, 15 Oct 2012 07:25:40 +0000 (+0000) Subject: simplify code X-Git-Tag: redback-2.1~291 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=cbdc922f7df5e8dc10961a56de121dcb7ce406e2;p=archiva.git simplify code git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1398203 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/redback-configuration/src/main/java/org/apache/archiva/redback/configuration/UserConfiguration.java b/redback-configuration/src/main/java/org/apache/archiva/redback/configuration/UserConfiguration.java index 63e6fcbe9..f6fd48651 100644 --- a/redback-configuration/src/main/java/org/apache/archiva/redback/configuration/UserConfiguration.java +++ b/redback-configuration/src/main/java/org/apache/archiva/redback/configuration/UserConfiguration.java @@ -94,10 +94,8 @@ public class UserConfiguration lookupRegistry = registry.getSubset( PREFIX ); - if ( log.isDebugEnabled() ) - { - log.debug( lookupRegistry.dump() ); - } + log.debug("User configuration {}", lookupRegistry.dump() ); + } private void performLegacyInitialization() diff --git a/redback-rbac/redback-authorization-rbac/src/main/java/org/apache/archiva/redback/authorization/rbac/RbacAuthorizer.java b/redback-rbac/redback-authorization-rbac/src/main/java/org/apache/archiva/redback/authorization/rbac/RbacAuthorizer.java index 5a3c0026d..d00eb56d4 100644 --- a/redback-rbac/redback-authorization-rbac/src/main/java/org/apache/archiva/redback/authorization/rbac/RbacAuthorizer.java +++ b/redback-rbac/redback-authorization-rbac/src/main/java/org/apache/archiva/redback/authorization/rbac/RbacAuthorizer.java @@ -19,10 +19,6 @@ package org.apache.archiva.redback.authorization.rbac; * under the License. */ -import org.apache.archiva.redback.rbac.Permission; -import org.apache.archiva.redback.rbac.RBACManager; -import org.apache.archiva.redback.rbac.RbacManagerException; -import org.apache.archiva.redback.users.UserNotFoundException; import org.apache.archiva.redback.authorization.AuthorizationDataSource; import org.apache.archiva.redback.authorization.AuthorizationException; import org.apache.archiva.redback.authorization.AuthorizationResult; @@ -30,16 +26,19 @@ import org.apache.archiva.redback.authorization.Authorizer; import org.apache.archiva.redback.authorization.NotAuthorizedException; import org.apache.archiva.redback.authorization.rbac.evaluator.PermissionEvaluationException; import org.apache.archiva.redback.authorization.rbac.evaluator.PermissionEvaluator; +import org.apache.archiva.redback.rbac.Permission; +import org.apache.archiva.redback.rbac.RBACManager; +import org.apache.archiva.redback.rbac.RbacManagerException; import org.apache.archiva.redback.rbac.RbacObjectNotFoundException; import org.apache.archiva.redback.users.User; import org.apache.archiva.redback.users.UserManager; +import org.apache.archiva.redback.users.UserNotFoundException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import javax.inject.Inject; import javax.inject.Named; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -47,20 +46,19 @@ import java.util.Map; * RbacAuthorizer: * * @author Jesse McConnell - * */ -@Service( "authorizer#rbac" ) +@Service ( "authorizer#rbac" ) public class RbacAuthorizer implements Authorizer { private Logger log = LoggerFactory.getLogger( getClass() ); @Inject - @Named( value = "rBACManager#cached" ) + @Named ( value = "rBACManager#cached" ) private RBACManager manager; @Inject - @Named( value = "userManager#configurable" ) + @Named ( value = "userManager#configurable" ) private UserManager userManager; @Inject @@ -94,12 +92,10 @@ public class RbacAuthorizer { for ( Permission permission : permissionMap.get( operation.toString() ) ) { - if ( log.isDebugEnabled() ) - { - log.debug( "checking permission {} for operation {} resource {}", - Arrays.asList( permission != null ? permission.getName() : "null", operation, - resource ).toArray() ); - } + + log.debug( "checking permission {} for operation {} resource {}", + ( permission != null ? permission.getName() : "null" ), operation, resource ); + if ( evaluator.evaluate( permission, operation, resource, principal ) ) { return new AuthorizationResult( true, permission, null );