From: <fc...@us...> - 2008-02-20 15:27:37
|
Revision: 660 http://openutils.svn.sourceforge.net/openutils/?rev=660&view=rev Author: fcarone Date: 2008-02-20 07:27:43 -0800 (Wed, 20 Feb 2008) Log Message: ----------- getClassName utility method added Modified Paths: -------------- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/SecurityRuleUtils.java Modified: trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/SecurityRuleUtils.java =================================================================== --- trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/SecurityRuleUtils.java 2008-02-20 15:26:27 UTC (rev 659) +++ trunk/openutils-hibernate-security/src/main/java/it/openutils/hibernate/security/filter/SecurityRuleUtils.java 2008-02-20 15:27:43 UTC (rev 660) @@ -39,7 +39,7 @@ * @return True if any of the rules matches the given config attribute, false otherwise. */ @SuppressWarnings("unchecked") - protected boolean checkPermissions(List<SecurityRule> rules, ConfigAttributeDefinition config) + public boolean checkPermissions(List<SecurityRule> rules, ConfigAttributeDefinition config) { log.debug("Evaluation permissions"); Iterator iterator = config.getConfigAttributes(); @@ -67,7 +67,7 @@ * @param argument The object to check the rules against * @return True if any of the rules matches the given object, false otherwise. */ - protected boolean checkRules(List<SecurityRule> rules, Object argument) + public boolean checkRules(List<SecurityRule> rules, Object argument) { log.debug("Evaluating rules."); try @@ -118,7 +118,7 @@ * @param authentication The authentication method * @return The collection of roles contained in the authentication */ - protected List<String> getRolesFromAuthentication(Authentication authentication) + public List<String> getRolesFromAuthentication(Authentication authentication) { List<String> roles = new ArrayList<String>(); for (GrantedAuthority authority : authentication.getAuthorities()) @@ -128,4 +128,19 @@ } return roles; } + + + /** + * @param object The object to get the name from + * @return The object name + */ + public String getClassName(Object object) + { + // is this class a CGLib proxy? + if (StringUtils.contains(object.getClass().getName(), "$$")) + { + return StringUtils.substringBefore(object.getClass().getName(), "$$"); + } + return object.getClass().getName(); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |