cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: Simple JSON parser updates
Date Fri, 17 Oct 2014 11:36:44 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 007b6e17b -> 683a2c6b3


Simple JSON parser updates


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/683a2c6b
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/683a2c6b
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/683a2c6b

Branch: refs/heads/master
Commit: 683a2c6b3fc40678f604c0198ec058ae44b00db0
Parents: 007b6e1
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Oct 17 12:36:28 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Fri Oct 17 12:36:28 2014 +0100

----------------------------------------------------------------------
 .../provider/json/AbstractJsonMapObject.java    |  61 ----------
 .../cxf/jaxrs/provider/json/JsonMapObject.java  |  84 +++++++++++++
 .../provider/json/JsonMapObjectProvider.java    |  86 +++++++++++++
 .../json/JsonMapObjectReaderWriter.java         | 120 +++++++++++++------
 .../cxf/rs/security/jose/JoseHeaders.java       |  45 ++-----
 .../security/jose/jwe/JweCompactConsumer.java   |   4 +-
 .../cxf/rs/security/jose/jwk/JsonWebKey.java    |  51 ++++----
 .../cxf/rs/security/jose/jwk/JsonWebKeys.java   |  10 +-
 .../security/jose/jws/JwsCompactConsumer.java   |   4 +-
 .../rs/security/jose/jws/JwsJsonConsumer.java   |   4 +-
 .../cxf/rs/security/jose/jwt/JwtClaims.java     |  18 +--
 11 files changed, 308 insertions(+), 179 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/683a2c6b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/AbstractJsonMapObject.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/AbstractJsonMapObject.java
b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/AbstractJsonMapObject.java
deleted file mode 100644
index d6eef9d..0000000
--- a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/AbstractJsonMapObject.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.jaxrs.provider.json;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-public abstract class AbstractJsonMapObject {
-    protected Map<String, Object> values = new LinkedHashMap<String, Object>();
-    
-    protected AbstractJsonMapObject() {
-        
-    }
-    
-    protected AbstractJsonMapObject(Map<String, Object> values) {
-        this.values = values;
-    }
-    
-    protected void setValue(String name, Object value) {
-        values.put(name, value);
-    }
-    
-    protected Object getValue(String name) {
-        return values.get(name);
-    }
-
-    public Map<String, Object> asMap() {
-        return values;
-    }
-    
-    protected Long getLongDate(String name) {
-        Object object = getValue(name);
-        return object instanceof Long ? (Long)object : Long.valueOf(object.toString());
-    }
-    
-    public int hashCode() { 
-        return values.hashCode();
-    }
-    
-    public boolean equals(Object obj) {
-        return obj instanceof AbstractJsonMapObject && ((AbstractJsonMapObject)obj).values.equals(this.values);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/683a2c6b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JsonMapObject.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JsonMapObject.java
b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JsonMapObject.java
new file mode 100644
index 0000000..efecd88
--- /dev/null
+++ b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JsonMapObject.java
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs.provider.json;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class JsonMapObject {
+    private Map<String, Object> values = new LinkedHashMap<String, Object>();
+    private Map<String, Integer> updateCount;
+    
+    public JsonMapObject() {
+        
+    }
+    
+    public JsonMapObject(Map<String, Object> values) {
+        this.values = values;
+    }
+    
+    public void setProperty(String name, Object value) {
+        if (values.containsKey(name)) {
+            if (updateCount == null) {
+                updateCount = new LinkedHashMap<String, Integer>();
+            }
+            Integer count = updateCount.get(name);
+            count = count == null ? 2 : count++;
+            updateCount.put(name, count);
+        }
+        values.put(name, value);
+    }
+    
+    public Object getProperty(String name) {
+        return values.get(name);
+    }
+
+    public Map<String, Object> asMap() {
+        return values;
+    }
+    public Integer getIntegerProperty(String name) {
+        Object value = getProperty(name);
+        if (value != null) {
+            return value instanceof Integer ? (Integer)value : Integer.parseInt(value.toString());
+        } else {
+            return null;
+        }
+    }
+    public Long getLongProperty(String name) {
+        Object value = getProperty(name);
+        if (value != null) {
+            return value instanceof Long ? (Long)value : Long.parseLong(value.toString());
+        } else {
+            return null;
+        }
+    }
+    
+    public int hashCode() { 
+        return values.hashCode();
+    }
+    
+    public boolean equals(Object obj) {
+        return obj instanceof JsonMapObject && ((JsonMapObject)obj).values.equals(this.values);
+    }
+    public Map<String, Object> getUpdateCount() {
+        return updateCount == null ? null : Collections.<String, Object>unmodifiableMap(updateCount);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/683a2c6b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JsonMapObjectProvider.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JsonMapObjectProvider.java
b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JsonMapObjectProvider.java
new file mode 100644
index 0000000..f8fea4b
--- /dev/null
+++ b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JsonMapObjectProvider.java
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxrs.provider.json;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Type;
+import java.util.Map;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.cxf.helpers.IOUtils;
+
+@Produces({"application/json", "application/*+json" })
+@Consumes({"application/json", "application/*+json" })
+@Provider
+public class JsonMapObjectProvider implements MessageBodyReader<JsonMapObject>, MessageBodyWriter<JsonMapObject>
{
+    private JsonMapObjectReaderWriter handler = new JsonMapObjectReaderWriter();
+    @Override
+    public long getSize(JsonMapObject o, Class<?> cls, Type t, Annotation[] anns, MediaType
mt) {
+        return -1;
+    }
+
+    @Override
+    public boolean isWriteable(Class<?> cls, Type t, Annotation[] anns, MediaType mt)
{
+        return JsonMapObject.class.isAssignableFrom(cls);
+    }
+
+    @Override
+    public void writeTo(JsonMapObject o, Class<?> cls, Type t, Annotation[] anns, MediaType
mt,
+                        MultivaluedMap<String, Object> headers, OutputStream os) throws
IOException,
+        WebApplicationException {
+        handler.toJson(o, os);
+    }
+
+    @Override
+    public boolean isReadable(Class<?> cls, Type t, Annotation[] anns, MediaType mt)
{
+        return JsonMapObject.class.isAssignableFrom(cls);
+    }
+
+    @Override
+    public JsonMapObject readFrom(Class<JsonMapObject> cls, Type t, Annotation[] anns,
MediaType mt,
+                                  MultivaluedMap<String, String> headers, InputStream
is) throws IOException,
+        WebApplicationException {
+        String s = IOUtils.readStringFromStream(is);
+        Map<String, Object> jsonMap = handler.fromJson(s);
+        if (cls == JsonMapObject.class) {
+            return new JsonMapObject(jsonMap);
+        } else {
+            try {
+                Constructor<?> c = cls.getConstructor(Map.class);
+                return (JsonMapObject)c.newInstance(jsonMap);
+            } catch (Exception ex) {
+                throw new IOException(ex);
+            }
+        }
+        
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/683a2c6b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JsonMapObjectReaderWriter.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JsonMapObjectReaderWriter.java
b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JsonMapObjectReaderWriter.java
index de382a0..0c68705 100644
--- a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JsonMapObjectReaderWriter.java
+++ b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JsonMapObjectReaderWriter.java
@@ -18,6 +18,8 @@
  */
 package org.apache.cxf.jaxrs.provider.json;
 
+import java.io.IOException;
+import java.io.OutputStream;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Iterator;
@@ -26,78 +28,92 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.cxf.common.util.StringUtils;
+
 
 
 public class JsonMapObjectReaderWriter {
     private boolean format;
     
-    public String toJson(AbstractJsonMapObject jwt) {
+    public String toJson(JsonMapObject obj) {
+        return toJson(obj.asMap());
+    }
+    
+    public String toJson(Map<String, Object> map) {
         StringBuilder sb = new StringBuilder();
-        toJsonInternal(sb, jwt.asMap());
+        toJsonInternal(new StringBuilderOutput(sb), map);
         return sb.toString();
     }
+    
+    public void toJson(JsonMapObject obj, OutputStream os) {
+        toJson(obj.asMap(), os);
+    }
+    
+    public void toJson(Map<String, Object> map, OutputStream os) {
+        toJsonInternal(new StreamOutput(os), map);
+    }
 
-    protected void toJsonInternal(StringBuilder sb, Map<String, Object> map) {
-        sb.append("{");
+    protected void toJsonInternal(Output out, Map<String, Object> map) {
+        out.append("{");
         for (Iterator<Map.Entry<String, Object>> it = map.entrySet().iterator();
it.hasNext();) {
             Map.Entry<String, Object> entry = it.next();
-            sb.append("\"").append(entry.getKey()).append("\"");
-            sb.append(":");
-            toJsonInternal(sb, entry.getValue(), it.hasNext());
+            out.append("\"").append(entry.getKey()).append("\"");
+            out.append(":");
+            toJsonInternal(out, entry.getValue(), it.hasNext());
         }
-        sb.append("}");
+        out.append("}");
     }
     
-    protected void toJsonInternal(StringBuilder sb, Object[] array) {
-        toJsonInternal(sb, Arrays.asList(array));
+    protected void toJsonInternal(Output out, Object[] array) {
+        toJsonInternal(out, Arrays.asList(array));
     }
     
-    protected void toJsonInternal(StringBuilder sb, Collection<?> coll) {
-        sb.append("[");
-        formatIfNeeded(sb);
+    protected void toJsonInternal(Output out, Collection<?> coll) {
+        out.append("[");
+        formatIfNeeded(out);
         for (Iterator<?> iter = coll.iterator(); iter.hasNext();) {
-            toJsonInternal(sb, iter.next(), iter.hasNext());
+            toJsonInternal(out, iter.next(), iter.hasNext());
         }
-        formatIfNeeded(sb);
-        sb.append("]");
+        formatIfNeeded(out);
+        out.append("]");
     }
     
     @SuppressWarnings("unchecked")
-    protected void toJsonInternal(StringBuilder sb, Object value, boolean hasNext) {
-        if (AbstractJsonMapObject.class.isAssignableFrom(value.getClass())) {
-            sb.append(toJson((AbstractJsonMapObject)value));
+    protected void toJsonInternal(Output out, Object value, boolean hasNext) {
+        if (JsonMapObject.class.isAssignableFrom(value.getClass())) {
+            out.append(toJson((JsonMapObject)value));
         } else if (value.getClass().isArray()) {
-            toJsonInternal(sb, (Object[])value);
+            toJsonInternal(out, (Object[])value);
         } else if (Collection.class.isAssignableFrom(value.getClass())) {
-            toJsonInternal(sb, (Collection<?>)value);
+            toJsonInternal(out, (Collection<?>)value);
         } else if (Map.class.isAssignableFrom(value.getClass())) {
-            toJsonInternal(sb, (Map<String, Object>)value);
+            toJsonInternal(out, (Map<String, Object>)value);
         } else {
             if (value.getClass() == String.class) {
-                sb.append("\"");
+                out.append("\"");
             }
-            sb.append(value);
+            out.append(value.toString());
             if (value.getClass() == String.class) {
-                sb.append("\"");
+                out.append("\"");
             }
         }
         if (hasNext) {
-            sb.append(",");
-            formatIfNeeded(sb);
+            out.append(",");
+            formatIfNeeded(out);
         }
         
     }
     
-    protected void formatIfNeeded(StringBuilder sb) {
+    protected void formatIfNeeded(Output out) {
         if (format) {
-            sb.append("\r\n ");
+            out.append("\r\n ");
         }
     }
         
-    public void fromJson(AbstractJsonMapObject jwt, String json) {
+    public void fromJson(JsonMapObject obj, String json) {
         String theJson = json.trim();
-        JsonObjectSettable joseObject = new JsonObjectSettable(jwt);
-        readJsonObjectAsSettable(joseObject, theJson.substring(1, theJson.length() - 1));
+        JsonObjectSettable settable = new JsonObjectSettable(obj);
+        readJsonObjectAsSettable(settable, theJson.substring(1, theJson.length() - 1));
     }
     
     public Map<String, Object> fromJson(String json) {
@@ -211,14 +227,44 @@ public class JsonMapObjectReaderWriter {
         
     }
     private static class JsonObjectSettable implements Settable {
-        private AbstractJsonMapObject jose;
-        public JsonObjectSettable(AbstractJsonMapObject jose) {
-            this.jose = jose;
+        private JsonMapObject obj;
+        public JsonObjectSettable(JsonMapObject obj) {
+            this.obj = obj;
         }
         public void put(String key, Object value) {
-            jose.setValue(key, value);
+            obj.setProperty(key, value);
         }
     }
-
+    private interface Output {
+        Output append(String str);
+    }
+    private class StringBuilderOutput implements Output {
+        private StringBuilder sb;
+        public StringBuilderOutput(StringBuilder sb) {
+            this.sb = sb;
+        }
+        @Override
+        public Output append(String str) {
+            sb.append(str);
+            return this;
+        }
+        
+    }
+    private class StreamOutput implements Output {
+        private OutputStream os;
+        public StreamOutput(OutputStream os) {
+            this.os = os;
+        }
+        @Override
+        public Output append(String str) {
+            try {
+                os.write(StringUtils.toBytesUTF8(str));
+            } catch (IOException ex) {
+                throw new RuntimeException(ex);
+            }
+            return this;
+        }
+        
+    }
     
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/683a2c6b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/JoseHeaders.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/JoseHeaders.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/JoseHeaders.java
index 15bff4d..60ce970 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/JoseHeaders.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/JoseHeaders.java
@@ -19,17 +19,14 @@
 
 package org.apache.cxf.rs.security.jose;
 
-import java.util.Collections;
-import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.jaxrs.provider.json.AbstractJsonMapObject;
+import org.apache.cxf.jaxrs.provider.json.JsonMapObject;
 import org.apache.cxf.rs.security.jose.jwk.JsonWebKey;
 
-public class JoseHeaders extends AbstractJsonMapObject {
-    private Map<String, Integer> headerUpdateCount;
+public class JoseHeaders extends JsonMapObject {
     public JoseHeaders() {
     }
     
@@ -102,7 +99,7 @@ public class JoseHeaders extends AbstractJsonMapObject {
     }
     
     public String getX509ThumbprintSHA256() {
-        return (String)super.getValue(JoseConstants.HEADER_X509_THUMBPRINT_SHA256);
+        return (String)getHeader(JoseConstants.HEADER_X509_THUMBPRINT_SHA256);
     }
     
     public void setCritical(List<String> crit) {
@@ -118,7 +115,7 @@ public class JoseHeaders extends AbstractJsonMapObject {
     }
     
     public JsonWebKey getJsonWebKey() {
-        Object jsonWebKey = getValue(JoseConstants.HEADER_JSON_WEB_KEY);
+        Object jsonWebKey = getHeader(JoseConstants.HEADER_JSON_WEB_KEY);
         if (jsonWebKey == null || jsonWebKey instanceof JsonWebKey) {
             return (JsonWebKey)jsonWebKey;
         }  
@@ -127,24 +124,12 @@ public class JoseHeaders extends AbstractJsonMapObject {
     }
     
     public JoseHeaders setHeader(String name, Object value) {
-        setValue(name, value);
+        setProperty(name, value);
         return this;
     }
     
-    protected void setValue(String name, Object value) {
-        if (super.values.containsKey(name)) {
-            if (headerUpdateCount == null) {
-                headerUpdateCount = new LinkedHashMap<String, Integer>();
-            }
-            Integer count = headerUpdateCount.get(name);
-            count = count == null ? 2 : count++;
-            headerUpdateCount.put(name, count);
-        }
-        super.setValue(name, value);
-    }
-    
     public Object getHeader(String name) {
-        return getValue(name);
+        return getProperty(name);
     }
     
     public JoseHeaders setIntegerHeader(String name, Integer value) {
@@ -153,12 +138,7 @@ public class JoseHeaders extends AbstractJsonMapObject {
     }
     
     public Integer getIntegerHeader(String name) {
-        Object value = getHeader(name);
-        if (value != null) {
-            return value instanceof Integer ? (Integer)value : Integer.parseInt(value.toString());
-        } else {
-            return null;
-        }
+        return getIntegerProperty(name);
     }
     public JoseHeaders setLongHeader(String name, Long value) {
         setHeader(name, value);
@@ -166,14 +146,7 @@ public class JoseHeaders extends AbstractJsonMapObject {
     }
     
     public Long getLongHeader(String name) {
-        Object value = getHeader(name);
-        if (value != null) {
-            return value instanceof Long ? (Long)value : Long.parseLong(value.toString());
-        } else {
-            return null;
-        }
-    }
-    public Map<String, Object> getHeaderUpdateCount() {
-        return headerUpdateCount == null ? null : Collections.<String, Object>unmodifiableMap(headerUpdateCount);
+        return getLongProperty(name);
     }
+    
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/683a2c6b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweCompactConsumer.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweCompactConsumer.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweCompactConsumer.java
index c2461e3..8673d4d 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweCompactConsumer.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweCompactConsumer.java
@@ -54,8 +54,8 @@ public class JweCompactConsumer {
             encryptedContent = Base64UrlUtility.decode(parts[3]);
             authTag = Base64UrlUtility.decode(parts[4]);
             JoseHeaders joseHeaders = reader.fromJsonHeaders(headersJson);
-            if (joseHeaders.getHeaderUpdateCount() != null) { 
-                throw new SecurityException();
+            if (joseHeaders.getUpdateCount() != null) { 
+                throw new SecurityException("Duplicate headers have been detected");
             }
             jweHeaders = new JweHeaders(joseHeaders);
             

http://git-wip-us.apache.org/repos/asf/cxf/blob/683a2c6b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JsonWebKey.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JsonWebKey.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JsonWebKey.java
index aa4ee13..025b248 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JsonWebKey.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JsonWebKey.java
@@ -22,11 +22,11 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.jaxrs.provider.json.AbstractJsonMapObject;
+import org.apache.cxf.jaxrs.provider.json.JsonMapObject;
 import org.apache.cxf.rs.security.jose.JoseConstants;
 
 
-public class JsonWebKey extends AbstractJsonMapObject {
+public class JsonWebKey extends JsonMapObject {
     
     public static final String KEY_TYPE = "kty";
     public static final String PUBLIC_KEY_USE = "use";
@@ -77,84 +77,85 @@ public class JsonWebKey extends AbstractJsonMapObject {
     }
     
     public void setKeyType(String keyType) {
-        super.setValue(KEY_TYPE, keyType);
+        setProperty(KEY_TYPE, keyType);
     }
 
     public String getKeyType() {
-        return (String)super.getValue(KEY_TYPE);
+        return (String)getProperty(KEY_TYPE);
     }
 
     public void setPublicKeyUse(String use) {
-        super.setValue(PUBLIC_KEY_USE, use);
+        setProperty(PUBLIC_KEY_USE, use);
     }
     
     public String getPublicKeyUse() {
-        return (String)super.getValue(PUBLIC_KEY_USE);
+        return (String)getProperty(PUBLIC_KEY_USE);
     }
 
     public void setKeyOperation(List<String> keyOperation) {
-        super.setValue(KEY_OPERATIONS, keyOperation);
+        setProperty(KEY_OPERATIONS, keyOperation);
     }
 
     public List<String> getKeyOperation() {
-        return CastUtils.cast((List<?>)super.getValue(KEY_OPERATIONS));
+        return CastUtils.cast((List<?>)getProperty(KEY_OPERATIONS));
     }
     
     public void setAlgorithm(String algorithm) {
-        super.setValue(KEY_ALGO, algorithm);
+        setProperty(KEY_ALGO, algorithm);
     }
 
     public String getAlgorithm() {
-        return (String)super.getValue(KEY_ALGO);
+        return (String)getProperty(KEY_ALGO);
     }
     
     public void setKid(String kid) {
-        super.setValue(KEY_ID, kid);
+        setProperty(KEY_ID, kid);
     }
 
     public String getKid() {
-        return (String)super.getValue(KEY_ID);
+        return (String)getProperty(KEY_ID);
     }
     
     public void setX509Url(String x509Url) {
-        super.setValue(X509_URL, x509Url);
+        setProperty(X509_URL, x509Url);
     }
     
     public String getX509Url() {
-        return (String)super.getValue(X509_URL);
+        return (String)getProperty(X509_URL);
     }
 
     public void setX509Chain(String x509Chain) {
-        super.setValue(X509_CHAIN, x509Chain);
+        setProperty(X509_CHAIN, x509Chain);
     }
 
     public String getX509Chain() {
-        return (String)super.getValue(X509_CHAIN);
+        return (String)getProperty(X509_CHAIN);
     }
     
     public void setX509Thumbprint(String x509Thumbprint) {
-        super.setValue(X509_THUMBPRINT, x509Thumbprint);
+        setProperty(X509_THUMBPRINT, x509Thumbprint);
     }
     
     public String getX509Thumbprint() {
-        return (String)super.getValue(X509_THUMBPRINT);
+        return (String)getProperty(X509_THUMBPRINT);
     }
     
     public void setX509ThumbprintSHA256(String x509Thumbprint) {
-        super.setValue(X509_THUMBPRINT_SHA256, x509Thumbprint);
+        setProperty(X509_THUMBPRINT_SHA256, x509Thumbprint);
     }
     
     public String getX509ThumbprintSHA256() {
-        return (String)super.getValue(X509_THUMBPRINT_SHA256);
+        return (String)getProperty(X509_THUMBPRINT_SHA256);
     }
     
-    public JsonWebKey setProperty(String name, Object value) {
-        super.setValue(name, value);
+    public JsonWebKey setKeyProperty(String name, Object value) {
+        setProperty(name, value);
         return this;
     }
-    
-    public Object getProperty(String name) {
-        return super.getValue(name);
+    public Object getKeyProperty(String name) {
+        return getProperty(name);
     }
     
+    
+    
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/683a2c6b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JsonWebKeys.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JsonWebKeys.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JsonWebKeys.java
index 54130d2..29ea88a 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JsonWebKeys.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JsonWebKeys.java
@@ -25,12 +25,12 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.jaxrs.provider.json.AbstractJsonMapObject;
+import org.apache.cxf.jaxrs.provider.json.JsonMapObject;
 
-public class JsonWebKeys extends AbstractJsonMapObject {
+public class JsonWebKeys extends JsonMapObject {
     public static final String KEYS_PROPERTY = "keys";
     public List<JsonWebKey> getKeys() {
-        List<?> list = (List<?>)super.getValue(KEYS_PROPERTY);
+        List<?> list = (List<?>)super.getProperty(KEYS_PROPERTY);
         if (list != null && !list.isEmpty()) {
             Object first = list.get(0);
             if (first instanceof JsonWebKey) {
@@ -38,7 +38,7 @@ public class JsonWebKeys extends AbstractJsonMapObject {
             } else {
                 List<JsonWebKey> keys = new LinkedList<JsonWebKey>();
                 List<Map<String, Object>> listOfMaps = 
-                    CastUtils.cast((List<?>)super.getValue(KEYS_PROPERTY));
+                    CastUtils.cast((List<?>)super.getProperty(KEYS_PROPERTY));
                 for (Map<String, Object> map : listOfMaps) {
                     keys.add(new JsonWebKey(map));
                 }
@@ -50,7 +50,7 @@ public class JsonWebKeys extends AbstractJsonMapObject {
     }
 
     public void setKeys(List<JsonWebKey> keys) {
-        super.setValue(KEYS_PROPERTY, keys);
+        super.setProperty(KEYS_PROPERTY, keys);
     }
     
     public Map<String, JsonWebKey> getKeyIdMap() {

http://git-wip-us.apache.org/repos/asf/cxf/blob/683a2c6b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactConsumer.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactConsumer.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactConsumer.java
index 578c049..a87bc19 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactConsumer.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactConsumer.java
@@ -76,8 +76,8 @@ public class JwsCompactConsumer {
     }
     public JoseHeaders getJoseHeaders() {
         JoseHeaders joseHeaders = reader.fromJsonHeaders(headersJson);
-        if (joseHeaders.getHeaderUpdateCount() != null) { 
-            throw new SecurityException();
+        if (joseHeaders.getUpdateCount() != null) { 
+            throw new SecurityException("Duplicate headers have been detected");
         }
         return joseHeaders;
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/683a2c6b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsJsonConsumer.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsJsonConsumer.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsJsonConsumer.java
index bbc2ac5..45069b3 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsJsonConsumer.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsJsonConsumer.java
@@ -24,7 +24,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.jaxrs.provider.json.AbstractJsonMapObject;
+import org.apache.cxf.jaxrs.provider.json.JsonMapObject;
 import org.apache.cxf.jaxrs.provider.json.JsonMapObjectReaderWriter;
 import org.apache.cxf.rs.security.jose.JoseUtils;
 import org.apache.cxf.rs.security.jose.jwk.JsonWebKey;
@@ -45,7 +45,7 @@ public class JwsJsonConsumer {
     }
 
     private void prepare() {
-        AbstractJsonMapObject jsonObject = new AbstractJsonMapObject() { };
+        JsonMapObject jsonObject = new JsonMapObject();
         new JsonMapObjectReaderWriter().fromJson(jsonObject, jwsSignedDocument);
         this.encodedJwsPayload = (String)jsonObject.asMap().get("payload");
         

http://git-wip-us.apache.org/repos/asf/cxf/blob/683a2c6b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtClaims.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtClaims.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtClaims.java
index 7f6a1e5..871e57a 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtClaims.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtClaims.java
@@ -21,12 +21,12 @@ package org.apache.cxf.rs.security.jose.jwt;
 
 import java.util.Map;
 
-import org.apache.cxf.jaxrs.provider.json.AbstractJsonMapObject;
+import org.apache.cxf.jaxrs.provider.json.JsonMapObject;
 
 
 
 
-public class JwtClaims extends AbstractJsonMapObject {
+public class JwtClaims extends JsonMapObject {
     
     public JwtClaims() {
     }
@@ -40,7 +40,7 @@ public class JwtClaims extends AbstractJsonMapObject {
     }
     
     public String getIssuer() {
-        return (String)getValue(JwtConstants.CLAIM_ISSUER);
+        return (String)getClaim(JwtConstants.CLAIM_ISSUER);
     }
     
     public void setSubject(String subject) {
@@ -64,7 +64,7 @@ public class JwtClaims extends AbstractJsonMapObject {
     }
     
     public Long getExpiryTime() {
-        return getLongDate(JwtConstants.CLAIM_EXPIRY);
+        return getLongProperty(JwtConstants.CLAIM_EXPIRY);
     }
     
     public void setNotBefore(Long notBefore) {
@@ -72,7 +72,7 @@ public class JwtClaims extends AbstractJsonMapObject {
     }
     
     public Long getNotBefore() {
-        return getLongDate(JwtConstants.CLAIM_NOT_BEFORE);
+        return getLongProperty(JwtConstants.CLAIM_NOT_BEFORE);
     }
     
     public void setIssuedAt(Long issuedAt) {
@@ -80,11 +80,11 @@ public class JwtClaims extends AbstractJsonMapObject {
     }
     
     public Long getIssuedAt() {
-        return getLongDate(JwtConstants.CLAIM_ISSUED_AT);
+        return getLongProperty(JwtConstants.CLAIM_ISSUED_AT);
     }
     
     public void setTokenId(String id) {
-        setValue(JwtConstants.CLAIM_JWT_ID, id);
+        setClaim(JwtConstants.CLAIM_JWT_ID, id);
     }
     
     public String getTokenId() {
@@ -92,11 +92,11 @@ public class JwtClaims extends AbstractJsonMapObject {
     }
     
     public JwtClaims setClaim(String name, Object value) {
-        setValue(name, value);
+        setProperty(name, value);
         return this;
     }
     
     public Object getClaim(String name) {
-        return getValue(name);
+        return getProperty(name);
     }
 }


Mime
View raw message