From 4795b273bb734f04056babe963d8588ffbf50fb0 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Tue, 21 Jul 2015 15:30:40 +0200 Subject: fix MOA-ID-Auth problems --- .../moa/id/commons/utils/KeyValueUtils.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils') diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils/KeyValueUtils.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils/KeyValueUtils.java index f20647fb0..04eb30f72 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils/KeyValueUtils.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils/KeyValueUtils.java @@ -227,4 +227,28 @@ public class KeyValueUtils { return findNextFreeListCounter((String[]) keySet.toArray(), listPrefix); } + + /** + * Normalize a CSV encoded list of value of an key/value pair + * + * This method removes all whitespace at the begin or the + * end of CSV values + * + * @param value CSV encoded input data + * @return normalized CSV encoded data or null if {value} is null or empty + */ + public static String normalizeCSVValueString(String value) { + String normalizedCodes = null; + if (MiscUtil.isNotEmpty(value)) { + String[] codes = value.split(","); + for (String el: codes) { + if (normalizedCodes == null) + normalizedCodes = el.trim(); + else + normalizedCodes += "," + el; + + } + } + return normalizedCodes; + } } -- cgit v1.2.3