[seam-commits] Seam SVN: r12809 - in modules/security/trunk/impl/src/main/java/org/jboss/seam/security: permission and 1 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Wed May 26 09:26:52 EDT 2010
Author: shane.bryzak at jboss.com
Date: 2010-05-26 09:26:51 -0400 (Wed, 26 May 2010)
New Revision: 12809
Removed:
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/util/TypedBeanProperty.java
Modified:
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/util/AnnotatedBeanProperty.java
Log:
exception messages
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2010-05-26 13:06:16 UTC (rev 12808)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2010-05-26 13:26:51 UTC (rev 12809)
@@ -79,9 +79,8 @@
public EntityProperty(Class<?> cls, Class<IdentityProperty> annotationClass, PropertyType pt)
{
- super();
- this.pt = pt;
- scan(cls, annotationClass);
+ super(cls, annotationClass);
+ this.pt = pt;
}
public boolean isMatch(IdentityProperty p)
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java 2010-05-26 13:06:16 UTC (rev 12808)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java 2010-05-26 13:26:51 UTC (rev 12809)
@@ -83,7 +83,7 @@
}
protected void initProperties()
- {
+ {
recipientProperty = new AnnotatedBeanProperty<PermissionRecipient>(userPermissionClass, PermissionRecipient.class);
targetProperty = new AnnotatedBeanProperty<PermissionTarget>(userPermissionClass, PermissionTarget.class);
actionProperty = new AnnotatedBeanProperty<PermissionAction>(userPermissionClass, PermissionAction.class);
@@ -643,17 +643,17 @@
if (targets != null)
{
- target = identifierCache.get(targetProperty.getValue(permission));
+ //target = identifierCache.get(targetProperty.getValue(permission));
if (target != null)
{
- actionSet = metadata.createActionSet(target.getClass(),
- actionProperty.getValue(permission).toString());
+ //actionSet = metadata.createActionSet(target.getClass(),
+ // actionProperty.getValue(permission).toString());
}
}
else
{
- actionSet = metadata.createActionSet(target.getClass(),
- actionProperty.getValue(permission).toString());
+ //actionSet = metadata.createActionSet(target.getClass(),
+ // actionProperty.getValue(permission).toString());
}
if (target != null && (action == null || (actionSet != null && actionSet.contains(action))))
@@ -702,14 +702,14 @@
target = identifierCache.get(roleTargetProperty.getValue(permission));
if (target != null)
{
- actionSet = metadata.createActionSet(target.getClass(),
- roleActionProperty.getValue(permission).toString());
+ //actionSet = metadata.createActionSet(target.getClass(),
+ // roleActionProperty.getValue(permission).toString());
}
}
else
{
- actionSet = metadata.createActionSet(target.getClass(),
- roleActionProperty.getValue(permission).toString());
+ //actionSet = metadata.createActionSet(target.getClass(),
+ // roleActionProperty.getValue(permission).toString());
}
if (target != null && (action == null || (actionSet != null && actionSet.contains(action))))
@@ -736,8 +736,8 @@
private Principal lookupPrincipal(Map<String,Principal> cache, Object permission, boolean isUser)
{
- Principal principal = resolvePrincipal(isUser ? recipientProperty.getValue(permission) :
- roleProperty.getValue(permission), isUser);
+ Principal principal = null; //resolvePrincipal(isUser ? recipientProperty.getValue(permission) :
+ //roleProperty.getValue(permission), isUser);
String key = (isUser ? "u:" : "r:") + principal.getName();
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/util/AnnotatedBeanProperty.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/util/AnnotatedBeanProperty.java 2010-05-26 13:06:16 UTC (rev 12808)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/util/AnnotatedBeanProperty.java 2010-05-26 13:26:51 UTC (rev 12809)
@@ -268,39 +268,31 @@
}
}
- private Object invokeMethod(Method method, Object obj, Object... args) throws Exception
+ private Object invokeMethod(Method method, Object obj, Object... args)
{
try
{
return method.invoke(obj, args);
}
- catch (Exception e)
+ catch (Exception ex)
{
- if (e instanceof InvocationTargetException)
+ StringBuilder message = new StringBuilder(String.format(
+ "Exception invoking method [%s] on object [%s], using arguments [",
+ method.getName(), obj));
+ if (args != null) for (int i = 0; i < args.length; i++) message.append((i > 0 ? "," : "") + args[i]);
+ message.append("]");
+
+ if (ex instanceof InvocationTargetException) ex = (Exception) ex.getCause();
+
+ if (ex instanceof IllegalAccessException ||
+ ex instanceof IllegalArgumentException ||
+ ex instanceof InvocationTargetException ||
+ ex instanceof NullPointerException ||
+ ex instanceof ExceptionInInitializerException)
{
- InvocationTargetException ite = (InvocationTargetException) e;
- throw (Exception) ite.getCause();
+ throw new RuntimeException(message.toString(), ex);
}
- else if (e instanceof RuntimeException)
- {
- throw (RuntimeException) e;
- }
- else
- {
- StringBuilder sb = null;
- if (args != null)
- {
- sb = new StringBuilder();
- for (Object arg : args)
- {
- sb.append((sb.length() > 0 ? "," : ":") + arg);
- }
- }
- throw new IllegalArgumentException(
- String.format("Exception invoking method [%s] on object [%s], with arguments [%s].",
- method.getName(), obj, sb != null ? sb.toString() : ""));
- }
- }
+ }
}
private Method getSetterMethod(Class<?> clazz, String name)
Deleted: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/util/TypedBeanProperty.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/util/TypedBeanProperty.java 2010-05-26 13:06:16 UTC (rev 12808)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/util/TypedBeanProperty.java 2010-05-26 13:26:51 UTC (rev 12809)
@@ -1,114 +0,0 @@
-package org.jboss.seam.security.util;
-
-import java.beans.Introspector;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-public class TypedBeanProperty
-{
- private Field propertyField;
- private Method propertyGetter;
- private Method propertySetter;
-
- private String name;
-
- private boolean isFieldProperty;
- private boolean set = false;
-
- public TypedBeanProperty(Class<?> cls, Class type)
- {
- // First check declared fields
- for (Field f : cls.getDeclaredFields())
- {
- if (f.getGenericType().equals(type))
- {
- setupFieldProperty(f);
- set = true;
- return;
- }
- }
-
- // Then check public fields, in case it's inherited
- for (Field f : cls.getFields())
- {
- if (f.getGenericType().equals(type))
- {
- setupFieldProperty(f);
- set = true;
- return;
- }
- }
-
- // Then check public methods (we ignore private methods)
- for (Method m : cls.getMethods())
- {
- if (m.getGenericReturnType().equals(type))
- {
- String methodName = m.getName();
-
- if ( m.getName().startsWith("get") )
- {
- this.name = Introspector.decapitalize( m.getName().substring(3) );
- }
- else if ( methodName.startsWith("is") )
- {
- this.name = Introspector.decapitalize( m.getName().substring(2) );
- }
-
- if (this.name != null)
- {
- this.propertyGetter = Reflections.getGetterMethod(cls, this.name);
- this.propertySetter = Reflections.getSetterMethod(cls, this.name);
- isFieldProperty = false;
- set = true;
- }
- else
- {
- throw new IllegalStateException("Invalid accessor method, must start with 'get' or 'is'. " +
- "Method: " + m + " in class: " + cls);
- }
- }
- }
- }
-
- private void setupFieldProperty(Field propertyField)
- {
- this.propertyField = propertyField;
- isFieldProperty = true;
- this.name = propertyField.getName();
- }
-
- public void setValue(Object bean, Object value)
- {
- if (isFieldProperty)
- {
- Reflections.setAndWrap(propertyField, bean, value);
- }
- else
- {
- Reflections.invokeAndWrap(propertySetter, bean, value);
- }
- }
-
- public Object getValue(Object bean)
- {
- if (isFieldProperty)
- {
- return Reflections.getAndWrap(propertyField, bean);
- }
- else
- {
- return Reflections.invokeAndWrap(propertyGetter, bean);
- }
- }
-
- public String getName()
- {
- return name;
- }
-
- public boolean isSet()
- {
- return set;
- }
-}
\ No newline at end of file
More information about the seam-commits
mailing list