[
https://issues.apache.org/jira/browse/ARTEMIS-604?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15383379#comment-15383379
]
ASF GitHub Bot commented on ARTEMIS-604:
----------------------------------------
Github user gaohoward commented on a diff in the pull request:
https://github.com/apache/activemq-artemis/pull/632#discussion_r71255851
--- Diff:
artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ObjectInputStreamWithClassLoader.java
---
@@ -25,23 +25,110 @@
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
public class ObjectInputStreamWithClassLoader extends ObjectInputStream {
// Constants
------------------------------------------------------------------------------------
+ /**
+ * Value used to indicate that all classes should be white or black
listed,
+ */
+ public static final String CATCH_ALL_WILDCARD = "*";
+
+ public static final String WHITELIST_PROPERTY =
"org.apache.activemq.artemis.jms.deserialization.whitelist";
+ public static final String BLACKLIST_PROPERTY =
"org.apache.activemq.artemis.jms.deserialization.blacklist";
+
// Attributes
-----------------------------------------------------------------------------------
+ private List<String> whiteList = new ArrayList<>();
+ private List<String> blackList = new ArrayList<>();
+
// Static
---------------------------------------------------------------------------------------
// Constructors
---------------------------------------------------------------------------------
public ObjectInputStreamWithClassLoader(final InputStream in) throws
IOException {
super(in);
+ String whiteList = System.getProperty(WHITELIST_PROPERTY, null);
+ setWhiteList(whiteList);
+
+ String blackList = System.getProperty(BLACKLIST_PROPERTY, null);
+ setBlackList(blackList);
}
// Public
---------------------------------------------------------------------------------------
+ /**
+ * @return the whiteList configured on this policy instance.
+ */
+ public String getWhiteList() {
+ Iterator<String> entries = whiteList.iterator();
+ StringBuilder builder = new StringBuilder();
+
+ while (entries.hasNext()) {
+ builder.append(entries.next());
+ if (entries.hasNext()) {
+ builder.append(",");
+ }
+ }
+ return builder.toString();
+ }
+
+ /**
+ * @return the blackList configured on this policy instance.
+ */
+ public String getBlackList() {
+ Iterator<String> entries = blackList.iterator();
+ StringBuilder builder = new StringBuilder();
+
+ while (entries.hasNext()) {
+ builder.append(entries.next());
+ if (entries.hasNext()) {
+ builder.append(",");
+ }
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * Replaces the currently configured whiteList with a comma separated
+ * string containing the new whiteList. Null or empty string denotes
+ * no whiteList entries, {@value #CATCH_ALL_WILDCARD} indicates that
+ * all classes are whiteListed.
+ *
+ * @param whiteList the whiteList that this policy is configured to
recognize.
+ */
+ public void setWhiteList(String whiteList) {
+ ArrayList<String> list = new ArrayList<>();
+ if (whiteList != null && !whiteList.isEmpty()) {
+ list.addAll(Arrays.asList(whiteList.split(",")));
+ }
+
+ this.whiteList = list;
+ }
+
+ /**
+ * Replaces the currently configured blackList with a comma separated
+ * string containing the new blackList. Null or empty string denotes
+ * no blacklist entries, {@value #CATCH_ALL_WILDCARD} indicates that
+ * all classes are blacklisted.
+ *
+ * @param blackList the blackList that this policy is configured to
recognize.
+ */
+ public void setBlackList(String blackList) {
+ ArrayList<String> list = new ArrayList<>();
+ if (blackList != null && !blackList.isEmpty()) {
+ list.addAll(Arrays.asList(blackList.split(",")));
+ }
+
+ this.blackList = list;
+ }
+
--- End diff --
+1. I'll make the changes.
> Message Serialization Improvement
> ---------------------------------
>
> Key: ARTEMIS-604
> URL: https://issues.apache.org/jira/browse/ARTEMIS-604
> Project: ActiveMQ Artemis
> Issue Type: Improvement
> Components: Broker
> Affects Versions: 1.3.0
> Reporter: Howard Gao
> Assignee: Howard Gao
> Fix For: 1.4.0
>
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)