From: <fc...@us...> - 2008-02-25 09:23:21
|
Revision: 690 http://openutils.svn.sourceforge.net/openutils/?rev=690&view=rev Author: fcarone Date: 2008-02-25 01:23:12 -0800 (Mon, 25 Feb 2008) Log Message: ----------- new config variable for denyIfNoRulesFound added Modified Paths: -------------- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/SecurityRuleAfterInvocationHandler.java trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/SecurityRulePredicate.java Modified: trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/SecurityRuleAfterInvocationHandler.java =================================================================== --- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/SecurityRuleAfterInvocationHandler.java 2008-02-25 09:19:55 UTC (rev 689) +++ trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/SecurityRuleAfterInvocationHandler.java 2008-02-25 09:23:12 UTC (rev 690) @@ -36,6 +36,7 @@ { private SecurityRuleManager securityRuleManager; + private boolean denyIfNoRulesFound = true; /** * {@inheritDoc} @@ -49,6 +50,7 @@ return null; } SecurityRulePredicate predicate = new SecurityRulePredicate(authentication, config, securityRuleManager); + predicate.setDenyIfNoRulesFound(denyIfNoRulesFound ); if (returnedObject instanceof Collection) { @@ -76,4 +78,14 @@ this.securityRuleManager = securityRuleManager; } + + /** + * Sets the denyIfNoRulesFound. + * @param denyIfNoRulesFound the denyIfNoRulesFound to set + */ + public void setDenyIfNoRulesFound(boolean denyIfNoRulesFound) + { + this.denyIfNoRulesFound = denyIfNoRulesFound; + } + } Modified: trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/SecurityRulePredicate.java =================================================================== --- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/SecurityRulePredicate.java 2008-02-25 09:19:55 UTC (rev 689) +++ trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/SecurityRulePredicate.java 2008-02-25 09:23:12 UTC (rev 690) @@ -1,5 +1,17 @@ /* - * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it + * Copyright Openmind http://www.openmindonline.it + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package it.openutils.hibernate.security.filter; @@ -31,6 +43,8 @@ private SecurityRuleUtils ruleUtils = new SecurityRuleUtils(); + private boolean denyIfNoRulesFound = true; + /** * @param authentication The current authentication * @param configAttribute The config attribute of the current method invocation interceptor @@ -59,13 +73,19 @@ // denyAll by default if (rules == null || rules.isEmpty()) { - return false; + if (denyIfNoRulesFound ) + { + return false; + } + else + { + return true; + } } return (ruleUtils.checkPermissions(rules, configAttribute) && ruleUtils.checkRules(rules, object)); } @SuppressWarnings("unchecked") - // @todo: needs unit test methods private List<SecurityRule> findAllRules(Object object, List<String> roles) { List<SecurityRule> result = new ArrayList<SecurityRule>(); @@ -82,4 +102,14 @@ return result; } + + /** + * Sets the denyIfNoRulesFound. + * @param denyIfNoRulesFound the denyIfNoRulesFound to set + */ + public void setDenyIfNoRulesFound(boolean denyIfNoRulesFound) + { + this.denyIfNoRulesFound = denyIfNoRulesFound; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |