Log Message
Add InterfaceTypePermission. ExplicitTypePermission also accepts Class.
Modified Paths
Added Paths
Diff
Modified: trunk/xstream/src/java/com/thoughtworks/xstream/security/ExplicitTypePermission.java (2235 => 2236)
--- trunk/xstream/src/java/com/thoughtworks/xstream/security/ExplicitTypePermission.java 2014-01-28 18:04:17 UTC (rev 2235)
+++ trunk/xstream/src/java/com/thoughtworks/xstream/security/ExplicitTypePermission.java 2014-01-29 00:54:38 UTC (rev 2236)
@@ -11,6 +11,7 @@
import java.util.HashSet;
import java.util.Set;
+
/**
* Explicit permission for a type with a name matching one in the provided list.
*
@@ -20,11 +21,27 @@
public class ExplicitTypePermission implements TypePermission {
final Set<String> names;
-
+
/**
* @since upcoming
*/
- public ExplicitTypePermission(String...names) {
+ public ExplicitTypePermission(final Class<?>... types) {
+ this(new Object() {
+ public String[] getNames() {
+ if (types == null)
+ return null;
+ String[] names = new String[types.length];
+ for (int i = 0; i < types.length; ++i)
+ names[i] = types[i].getName();
+ return names;
+ }
+ }.getNames());
+ }
+
+ /**
+ * @since upcoming
+ */
+ public ExplicitTypePermission(String... names) {
this.names = names == null ? Collections.<String>emptySet() : new HashSet<String>(Arrays.asList(names));
}
Added: trunk/xstream/src/java/com/thoughtworks/xstream/security/InterfaceTypePermission.java (0 => 2236)
--- trunk/xstream/src/java/com/thoughtworks/xstream/security/InterfaceTypePermission.java (rev 0)
+++ trunk/xstream/src/java/com/thoughtworks/xstream/security/InterfaceTypePermission.java 2014-01-29 00:54:38 UTC (rev 2236)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2014 XStream Committers.
+ * All rights reserved.
+ *
+ * Created on 27. January 2014 by Joerg Schaible
+ */
+package com.thoughtworks.xstream.security;
+
+/**
+ * Permission for any interface type.
+ *
+ * @author Jörg Schaible
+ * @since upcoming
+ */
+public class InterfaceTypePermission implements TypePermission {
+ /**
+ * @since upcoming
+ */
+ public static final TypePermission INTERFACES = new InterfaceTypePermission();
+
+ @Override
+ public boolean allows(Class<?> type) {
+ return type != null && type.isInterface();
+ }
+
+ @Override
+ public int hashCode() {
+ return 31;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj != null && obj.getClass() == InterfaceTypePermission.class;
+ }
+
+}
Property changes on: trunk/xstream/src/java/com/thoughtworks/xstream/security/InterfaceTypePermission.java
___________________________________________________________________
Added: svn:keywords
Added: svn:eol-style
To unsubscribe from this list please visit:
