oltu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1524395 - in /oltu/trunk/jose: ./ jws/ jws/src/ jws/src/main/ jws/src/main/java/ jws/src/main/java/org/ jws/src/main/java/org/apache/ jws/src/main/java/org/apache/oltu/ jws/src/main/java/org/apache/oltu/jose/ jws/src/main/java/org/apache/o...
Date Wed, 18 Sep 2013 13:09:03 GMT
Author: simonetripodi
Date: Wed Sep 18 13:09:02 2013
New Revision: 1524395

URL: http://svn.apache.org/r1524395
Log:
OLTU-118 - Implement JWS of the JOSE working group

initial checkin of new codebase

Added:
    oltu/trunk/jose/
    oltu/trunk/jose/jws/   (with props)
    oltu/trunk/jose/jws/pom.xml   (with props)
    oltu/trunk/jose/jws/src/
    oltu/trunk/jose/jws/src/main/
    oltu/trunk/jose/jws/src/main/java/
    oltu/trunk/jose/jws/src/main/java/org/
    oltu/trunk/jose/jws/src/main/java/org/apache/
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/Header.java   (with props)
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/JWS.java   (with props)
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/AbstractJWSIO.java   (with props)
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/JWSReader.java   (with props)
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/JWSWriter.java   (with props)
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/package-info.java   (with props)
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/package-info.java   (with props)
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/Key.java   (with props)
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SignatureMethod.java   (with props)
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SigningKey.java   (with props)
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SymetricKey.java   (with props)
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/VerifyingKey.java   (with props)
    oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/package-info.java   (with props)
    oltu/trunk/jose/jws/src/test/
    oltu/trunk/jose/jws/src/test/java/
    oltu/trunk/jose/jws/src/test/java/org/
    oltu/trunk/jose/jws/src/test/java/org/apache/
    oltu/trunk/jose/jws/src/test/java/org/apache/oltu/
    oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/
    oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/
    oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/io/
    oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/io/JWSReaderTestCase.java   (with props)
    oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/io/JWSWriterTestCase.java   (with props)
    oltu/trunk/jose/pom.xml   (with props)

Propchange: oltu/trunk/jose/jws/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Sep 18 13:09:02 2013
@@ -0,0 +1,2 @@
+.settings
+target

Added: oltu/trunk/jose/jws/pom.xml
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jws/pom.xml?rev=1524395&view=auto
==============================================================================
--- oltu/trunk/jose/jws/pom.xml (added)
+++ oltu/trunk/jose/jws/pom.xml Wed Sep 18 13:09:02 2013
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.oltu.jose</groupId>
+    <artifactId>org.apache.oltu.jose.parent</artifactId>
+    <version>1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>org.apache.oltu.jose.jws</artifactId>
+
+  <name>Apache Oltu - JOSE - JWS</name>
+
+  <properties>
+    <oltu.oauth2.version>1.0.0-SNAPSHOT</oltu.oauth2.version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.codehaus.jettison</groupId>
+      <artifactId>jettison</artifactId>
+      <version>1.2</version>
+      <exclusions>
+        <exclusion>
+          <groupId>stax</groupId>
+          <artifactId>stax-api</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+      <version>1.8</version>
+    </dependency>
+  </dependencies>
+
+</project>

Propchange: oltu/trunk/jose/jws/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: oltu/trunk/jose/jws/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: oltu/trunk/jose/jws/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/Header.java
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/Header.java?rev=1524395&view=auto
==============================================================================
--- oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/Header.java (added)
+++ oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/Header.java Wed Sep 18 13:09:02 2013
@@ -0,0 +1,313 @@
+/*
+ * 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.oltu.jose.jws;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+/**
+ * Represents the Header as defined in the section 4 of the JWS specification.
+ *
+ * @see http://tools.ietf.org/html/draft-ietf-jose-json-web-signature-15#section-4
+ */
+public final class Header {
+
+    /**
+     * The {@code alg} JWS Header parameter.
+     */
+    private final String algorithm;
+
+    /**
+     * The {@code jku} JWS Header parameter.
+     */
+    private final String jwkSetUrl;
+
+    /**
+     * The {@code jwk} JWS Header parameter.
+     */
+    private final String jsonWebKey;
+
+    /**
+     * The {@code x5u} JWS Header parameter.
+     */
+    private final String x509url;
+
+    /**
+     * The {@code x5t} JWS Header parameter.
+     */
+    private final String x509CertificateThumbprint;
+
+    /**
+     * The {@code x5c} JWS Header parameter.
+     */
+    private final String x509CertificateChain;
+
+    /**
+     * The {@code kid} JWS Header parameter.
+     */
+    private final String keyId;
+
+    /**
+     * The {@code typ} JWS Header parameter.
+     */
+    private final String type;
+
+    /**
+     * The {@code cty} JWS Header parameter.
+     */
+    private final String contentType;
+
+    /**
+     * The {@code crit} JWS Header parameter.
+     */
+    private final String[] critical;
+
+    /**
+     * The registry that keeps the custom fields.
+     */
+    private final Map<String, Object> customFields;
+
+    Header(String algorithm,
+           String jwkSetUrl,
+           String jsonWebKey,
+           String x509url,
+           String x509CertificateThumbprint,
+           String x509CertificateChain,
+           String keyId,
+           String type,
+           String contentType,
+           String[] critical,
+           Map<String, Object> customFields) {
+        this.algorithm = algorithm;
+        this.jwkSetUrl = jwkSetUrl;
+        this.jsonWebKey = jsonWebKey;
+        this.x509url = x509url;
+        this.x509CertificateThumbprint = x509CertificateThumbprint;
+        this.x509CertificateChain = x509CertificateChain;
+        this.keyId = keyId;
+        this.type = type;
+        this.contentType = contentType;
+        this.critical = critical;
+        this.customFields = customFields;
+    }
+
+    public String getAlgorithm() {
+        return algorithm;
+    }
+
+    public String getJwkSetUrl() {
+        return jwkSetUrl;
+    }
+
+    public String getJsonWebKey() {
+        return jsonWebKey;
+    }
+
+    public String getX509url() {
+        return x509url;
+    }
+
+    public String getX509CertificateThumbprint() {
+        return x509CertificateThumbprint;
+    }
+
+    public String getX509CertificateChain() {
+        return x509CertificateChain;
+    }
+
+    public String getKeyId() {
+        return keyId;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public String getContentType() {
+        return contentType;
+    }
+
+    public String[] getCritical() {
+        return critical;
+    }
+
+    /**
+     * Return the specified custom field value,
+     * {@code null} if the custom field is not present.
+     *
+     * @param name the custom field name, it cannot be null.
+     * @return the specified custom field value,
+     *         {@code null} if the custom field is not present.
+     */
+    public <T> T getCustomField(String name, Class<T> type) {
+        if (name == null) {
+            throw new IllegalArgumentException("Null custom field name not present in the registry.");
+        }
+
+        Object value = customFields.get(name);
+
+        if (value != null) {
+            return type.cast(value);
+        }
+
+        return null;
+    }
+
+    /**
+     * Returns the custom fields stored in the entity.
+     *
+     * @return the custom fields stored in the entity.
+     */
+    public Set<Entry<String, Object>> getCustomFields() {
+        return customFields.entrySet();
+    }
+
+    public static final class Builder {
+
+        /**
+         * The {@code alg} JWS Header parameter.
+         */
+        private String algorithm;
+
+        /**
+         * The {@code jku} JWS Header parameter.
+         */
+        private String jwkSetUrl;
+
+        /**
+         * The {@code jwk} JWS Header parameter.
+         */
+        private String jsonWebKey;
+
+        /**
+         * The {@code x5u} JWS Header parameter.
+         */
+        private String x509url;
+
+        /**
+         * The {@code x5t} JWS Header parameter.
+         */
+        private String x509CertificateThumbprint;
+
+        /**
+         * The {@code x5c} JWS Header parameter.
+         */
+        private String x509CertificateChain;
+
+        /**
+         * The {@code kid} JWS Header parameter.
+         */
+        private String keyId;
+
+        /**
+         * The {@code typ} JWS Header parameter.
+         */
+        private String type;
+
+        /**
+         * The {@code cty} JWS Header parameter.
+         */
+        private String contentType;
+
+        /**
+         * The {@code crit} JWS Header parameter.
+         */
+        private String[] critical;
+
+        /**
+         * The registry that keeps the custom fields.
+         */
+        private final Map<String, Object> customFields = new LinkedHashMap<String, Object>();
+
+        public Builder setAlgorithm(String algorithm) {
+            this.algorithm = algorithm;
+            return this;
+        }
+
+        public Builder setJwkSetUrl(String jwkSetUrl) {
+            this.jwkSetUrl = jwkSetUrl;
+            return this;
+        }
+
+        public Builder setJsonWebKey(String jsonWebKey) {
+            this.jsonWebKey = jsonWebKey;
+            return this;
+        }
+
+        public Builder setX509url(String x509url) {
+            this.x509url = x509url;
+            return this;
+        }
+
+        public Builder setX509CertificateThumbprint(String x509CertificateThumbprint) {
+            this.x509CertificateThumbprint = x509CertificateThumbprint;
+            return this;
+        }
+
+        public Builder setX509CertificateChain(String x509CertificateChain) {
+            this.x509CertificateChain = x509CertificateChain;
+            return this;
+        }
+
+        public Builder setKeyId(String keyId) {
+            this.keyId = keyId;
+            return this;
+        }
+
+        public Builder setType(String type) {
+            this.type = type;
+            return this;
+        }
+
+        public Builder setContentType(String contentType) {
+            this.contentType = contentType;
+            return this;
+        }
+
+        public Builder setCritical(String[] critical) {
+            this.critical = critical;
+            return this;
+        }
+
+        public Builder setCustomField(String key, String value) {
+            if (key == null) {
+                throw new IllegalArgumentException("Null key not allowed.");
+            }
+            if (value != null) {
+                customFields.put(key, value);
+            }
+            return this;
+        }
+
+        public Header build() {
+            return new Header(algorithm,
+                              jwkSetUrl,
+                              jsonWebKey,
+                              x509url,
+                              x509CertificateThumbprint,
+                              x509CertificateChain,
+                              keyId, type,
+                              contentType,
+                              critical,
+                              customFields);
+        }
+
+    }
+
+}

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/Header.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/Header.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/Header.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/JWS.java
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/JWS.java?rev=1524395&view=auto
==============================================================================
--- oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/JWS.java (added)
+++ oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/JWS.java Wed Sep 18 13:09:02 2013
@@ -0,0 +1,233 @@
+/*
+ * 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.oltu.jose.jws;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.apache.oltu.jose.jws.signature.SignatureMethod;
+import org.apache.oltu.jose.jws.signature.SigningKey;
+import org.apache.oltu.jose.jws.signature.SymetricKey;
+import org.apache.oltu.jose.jws.signature.VerifyingKey;
+
+public class JWS {
+
+    /**
+     * The JWS Header.
+     */
+    private final Header header;
+
+    /**
+     * The JWS Payload.
+     */
+    private final String payload;
+
+    /**
+     * The JWS Signature.
+     */
+    private final String signature;
+
+    JWS(Header header, String payload, String signature) {
+        this.header = header;
+        this.payload = payload;
+        this.signature = signature;
+    }
+
+    public Header getHeader() {
+        return header;
+    }
+
+    public String getPayload() {
+        return payload;
+    }
+
+    public String getSignature() {
+        return signature;
+    }
+
+    public static final class Builder {
+
+        /**
+         * The {@code alg} JWS Header parameter.
+         */
+        private String algorithm;
+
+        /**
+         * The {@code jku} JWS Header parameter.
+         */
+        private String jwkSetUrl;
+
+        /**
+         * The {@code jwk} JWS Header parameter.
+         */
+        private String jsonWebKey;
+
+        /**
+         * The {@code x5u} JWS Header parameter.
+         */
+        private String x509url;
+
+        /**
+         * The {@code x5t} JWS Header parameter.
+         */
+        private String x509CertificateThumbprint;
+
+        /**
+         * The {@code x5c} JWS Header parameter.
+         */
+        private String x509CertificateChain;
+
+        /**
+         * The {@code kid} JWS Header parameter.
+         */
+        private String keyId;
+
+        /**
+         * The {@code typ} JWS Header parameter.
+         */
+        private String type;
+
+        /**
+         * The {@code cty} JWS Header parameter.
+         */
+        private String contentType;
+
+        /**
+         * The {@code crit} JWS Header parameter.
+         */
+        private String[] critical;
+
+        /**
+         * The JWS Payload.
+         */
+        private String payload;
+
+        /**
+         * The JWS Signature.
+         */
+        private String signature;
+
+        /**
+         * The registry that keeps the custom fields.
+         */
+        private final Map<String, Object> customFields = new LinkedHashMap<String, Object>();
+
+        public Builder setAlgorithm(String algorithm) {
+            this.algorithm = algorithm;
+            return this;
+        }
+
+        public Builder setJwkSetUrl(String jwkSetUrl) {
+            this.jwkSetUrl = jwkSetUrl;
+            return this;
+        }
+
+        public Builder setJsonWebKey(String jsonWebKey) {
+            this.jsonWebKey = jsonWebKey;
+            return this;
+        }
+
+        public Builder setX509url(String x509url) {
+            this.x509url = x509url;
+            return this;
+        }
+
+        public Builder setX509CertificateThumbprint(String x509CertificateThumbprint) {
+            this.x509CertificateThumbprint = x509CertificateThumbprint;
+            return this;
+        }
+
+        public Builder setX509CertificateChain(String x509CertificateChain) {
+            this.x509CertificateChain = x509CertificateChain;
+            return this;
+        }
+
+        public Builder setKeyId(String keyId) {
+            this.keyId = keyId;
+            return this;
+        }
+
+        public Builder setType(String type) {
+            this.type = type;
+            return this;
+        }
+
+        public Builder setContentType(String contentType) {
+            this.contentType = contentType;
+            return this;
+        }
+
+        public Builder setCritical(String[] critical) {
+            this.critical = critical;
+            return this;
+        }
+
+        public Builder setCustomField(String key, String value) {
+            if (key == null) {
+                throw new IllegalArgumentException("Null key not allowed.");
+            }
+            if (value != null) {
+                customFields.put(key, value);
+            }
+            return this;
+        }
+
+        public Builder setPayload(String payload) {
+            this.payload = payload;
+            return this;
+        }
+
+        public Builder setSignature(String signature) {
+            this.signature = signature;
+            return this;
+        }
+
+        public <SK extends SigningKey, VK extends VerifyingKey> Builder sign(SignatureMethod<SK, VK> method,
+                                                                             SK signingKey) {
+            if (method == null) {
+                throw new IllegalArgumentException("A signature method is required in order to calculate the signature.");
+            }
+            if (signingKey == null) {
+                throw new IllegalArgumentException("A signing key is required in order to calculate the signature.");
+            }
+            setAlgorithm(method.getAlgorithm());
+            return setSignature(method.calculate(signingKey));
+        }
+
+        public <SK extends SymetricKey> Builder sign(SignatureMethod<SK, SK> method,
+                                                     SK signingKey) {
+            return sign(method, signingKey);
+        }
+
+        public JWS build() {
+            return new JWS(new Header(algorithm,
+                                      jwkSetUrl,
+                                      jsonWebKey,
+                                      x509url,
+                                      x509CertificateThumbprint,
+                                      x509CertificateChain,
+                                      keyId, type,
+                                      contentType,
+                                      critical,
+                                      customFields),
+                           payload,
+                           signature);
+        }
+
+    }
+
+}

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/JWS.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/JWS.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/JWS.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/AbstractJWSIO.java
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/AbstractJWSIO.java?rev=1524395&view=auto
==============================================================================
--- oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/AbstractJWSIO.java (added)
+++ oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/AbstractJWSIO.java Wed Sep 18 13:09:02 2013
@@ -0,0 +1,95 @@
+/*
+ * 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.oltu.jose.jws.io;
+
+import java.nio.charset.Charset;
+
+import org.apache.commons.codec.binary.Base64;
+
+abstract class AbstractJWSIO {
+
+    /**
+     * The {@code UTF-8} charset reference.
+     */
+    private static final Charset UTF_8 = Charset.forName("UTF-8");
+
+    // header defined in the JWT specification
+
+    /**
+     * The {@code alg} JWT Header key.
+     */
+    public static final String ALGORITHM = "alg";
+
+    /**
+     * The {@code jku} JWT Header key.
+     */
+    public static final String JWK_SET_URL = "jku";
+
+    /**
+     * The {@code jwk} JWT Header key.
+     */
+    public static final String JSON_WEB_KEY = "jwk";
+
+    /**
+     * The {@code x5u} JWT Header key.
+     */
+    public static final String X509_URL = "x5u";
+
+    /**
+     * The {@code x5t} JWT Header key.
+     */
+    public static final String X509_CERTIFICATE_THUMBPRINT = "x5t";
+
+    /**
+     * The {@code x5c} JWT Header key.
+     */
+    public static final String X509_CERTIFICATE_CHAIN = "x5c";
+
+    /**
+     * The {@code kid} JWT Header key.
+     */
+    public static final String KEY_ID = "kid";
+
+    /**
+     * The {@code typ} JWT Header key.
+     */
+    protected static final String TYPE = "typ";
+
+    /**
+     * The {@code cty} JWT Header key.
+     */
+    public static final String CONTENT_TYPE = "cty";
+
+    /**
+     * The {@code crit} JWT Header key.
+     */
+    public static final String CRITICAL = "crit";
+
+    /**
+     * The BASE64 encoder/decoder.
+     */
+    private final Base64 base64 = new Base64(true);
+
+    protected final String base64Decode(String base64encoded) {
+        return new String(base64.decode(base64encoded), UTF_8);
+    }
+
+    protected final String base64Encode(String input) {
+        return new String(base64.encode(input.getBytes(UTF_8)), UTF_8);
+    }
+
+}

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/AbstractJWSIO.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/AbstractJWSIO.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/AbstractJWSIO.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/JWSReader.java
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/JWSReader.java?rev=1524395&view=auto
==============================================================================
--- oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/JWSReader.java (added)
+++ oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/JWSReader.java Wed Sep 18 13:09:02 2013
@@ -0,0 +1,153 @@
+/*
+ * 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.oltu.jose.jws.io;
+
+import static java.lang.String.format;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.Iterator;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.oltu.jose.jws.JWS;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+
+/**
+ * A {@link JWS} reader.
+ *
+ * TODO understand if JWT can be reused to avoid code duplication!
+ */
+public final class JWSReader extends AbstractJWSIO {
+
+    /**
+     * The Base64 JSON string default separator.
+     */
+    private final Pattern base64JWTPattern = Pattern.compile("([a-zA-Z0-9/+=]+)\\.([a-zA-Z0-9/+=]+)\\.(.+)");
+
+    public JWS read(String base64jsonString) {
+        if (base64jsonString == null || base64jsonString.isEmpty()) {
+            throw new IllegalArgumentException("Impossible to obtain a JWT from a null or empty string");
+        }
+
+        // TODO improve multi-line tokens
+        StringBuilder buffer = new StringBuilder();
+        BufferedReader reader = new BufferedReader(new StringReader(base64jsonString));
+        String line = null;
+        try {
+            while ((line = reader.readLine()) != null) {
+                buffer.append(line);
+            }
+        } catch (IOException e) {
+            // it cannot happen
+        } finally {
+            try {
+                reader.close();
+            } catch (IOException e) {
+                // swallow it
+            }
+        }
+
+        Matcher matcher = base64JWTPattern.matcher(buffer.toString());
+        if (!matcher.matches()) {
+            throw new IllegalArgumentException(base64jsonString
+                                               + "is not a valid JSON Web Signature, it does not match with the pattern: "
+                                               + base64JWTPattern.pattern());
+        }
+
+        JWS.Builder jwsBuilder = new JWS.Builder();
+
+        // HEADER
+
+        String header = matcher.group(1);
+        String decodedHeader = base64Decode(header);
+        JSONObject headerObject;
+
+        try {
+            headerObject = new JSONObject(decodedHeader);
+        } catch (JSONException e) {
+            throw new IllegalArgumentException(format("BASE64 string '%s' (decoded to '%s') is not a valid JSON object representation",
+                                                      header, decodedHeader));
+        }
+
+        for (@SuppressWarnings("unchecked") // it is known that JSON keys are strings
+        Iterator<String> keys = headerObject.keys(); keys.hasNext();) {
+            String key = keys.next();
+
+            if (ALGORITHM.equals(key)) {
+                jwsBuilder.setAlgorithm(getString(headerObject, ALGORITHM));
+            } else if (JWK_SET_URL.equals(key)) {
+                jwsBuilder.setJwkSetUrl(getString(headerObject, ALGORITHM));
+            } else if (JSON_WEB_KEY.equals(key)) {
+                jwsBuilder.setJsonWebKey(getString(headerObject, JSON_WEB_KEY));
+            }  else if (X509_URL.equals(key)) {
+                jwsBuilder.setX509url(getString(headerObject, X509_URL));
+            } else if (X509_CERTIFICATE_THUMBPRINT.equals(key)) {
+                jwsBuilder.setX509CertificateThumbprint(getString(headerObject, X509_CERTIFICATE_THUMBPRINT));
+            } else if (X509_CERTIFICATE_CHAIN.equals(key)) {
+                jwsBuilder.setX509CertificateChain(getString(headerObject, X509_CERTIFICATE_CHAIN));
+            } else if (KEY_ID.equals(key)) {
+                jwsBuilder.setKeyId(getString(headerObject, KEY_ID));
+            } else if (TYPE.equals(key)) {
+                jwsBuilder.setType(getString(headerObject, TYPE));
+            } else if (CONTENT_TYPE.equals(key)) {
+                jwsBuilder.setContentType(getString(headerObject, CONTENT_TYPE));
+            } else if (CRITICAL.equals(key)) {
+                jwsBuilder.setCritical(getStringArray(headerObject, CRITICAL));
+            } else {
+                jwsBuilder.setCustomField(key, getString(headerObject, key));
+            }
+        }
+
+        // PAYLOAD
+        String payload = matcher.group(2);
+        String decodedPayload = base64Decode(payload);
+
+        // SIGNATURE
+        String signature = matcher.group(3);
+        String decodedSignature = base64Decode(signature);
+
+        return jwsBuilder.setPayload(decodedPayload)
+                         .setSignature(decodedSignature)
+                         .build();
+    }
+
+    private static String getString(JSONObject object, String key) {
+        try {
+            return object.getString(key);
+        } catch (JSONException e) {
+            return null;
+        }
+    }
+
+    private static String[] getStringArray(JSONObject object, String key) {
+        try {
+            JSONArray array = object.getJSONArray(key);
+            String[] result = new String[array.length()];
+            for (int i = 0; i < result.length; i++) {
+                result[i] = array.getString(i);
+            }
+            return result;
+        } catch (JSONException e) {
+            return new String[0];
+        }
+    }
+
+}

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/JWSReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/JWSReader.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/JWSReader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/JWSWriter.java
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/JWSWriter.java?rev=1524395&view=auto
==============================================================================
--- oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/JWSWriter.java (added)
+++ oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/JWSWriter.java Wed Sep 18 13:09:02 2013
@@ -0,0 +1,121 @@
+/*
+ * 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.oltu.jose.jws.io;
+
+import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.Map.Entry;
+
+import org.apache.oltu.jose.jws.Header;
+import org.apache.oltu.jose.jws.JWS;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+
+public final class JWSWriter extends AbstractJWSIO {
+
+    public String write(JWS jws) {
+        if (jws == null) {
+            throw new IllegalArgumentException("Impossible to build a Token from a null JWS representation.");
+        }
+
+        String header = write(jws.getHeader());
+        String encodedHeader = base64Encode(header);
+
+        String payload = jws.getPayload();
+        String encodedPayload = base64Encode(payload);
+
+        String signature = jws.getSignature();
+        String encodedSignature = base64Encode(signature);
+
+        return new StringBuilder()
+                   .append(encodedHeader)
+                   .append('.')
+                   .append(encodedPayload)
+                   .append('.')
+                   .append(encodedSignature)
+                   .toString();
+    }
+
+    /**
+     * Serializes the input JWT Header to its correct JSON representation.
+     *
+     * @param header the JWT Header has to be serialized.
+     * @return the JSON string that represents the JWT Header.
+     */
+    public String write(Header header) {
+        if (header == null) {
+            throw new IllegalArgumentException("Null JWT Header cannot be serialized to JSON representation.");
+        }
+
+        JSONObject object = new JSONObject();
+        setString(object, ALGORITHM, header.getAlgorithm());
+        setString(object, JWK_SET_URL, header.getJwkSetUrl());
+        setString(object, JSON_WEB_KEY, header.getJsonWebKey());
+        setString(object, X509_URL, header.getX509url());
+        setString(object, X509_CERTIFICATE_THUMBPRINT, header.getX509CertificateThumbprint());
+        setString(object, X509_CERTIFICATE_CHAIN, header.getX509CertificateChain());
+        setString(object, KEY_ID, header.getKeyId());
+        setString(object, TYPE, header.getType());
+        setString(object, CONTENT_TYPE, header.getContentType());
+        setStringArray(object, CRITICAL, header.getCritical());
+
+        for (Entry<String, Object> customField : header.getCustomFields()) {
+            setObject(object, customField.getKey(), customField.getValue());
+        }
+
+        StringWriter writer = new StringWriter();
+        try {
+            object.write(writer);
+        } catch (JSONException e) {
+            // swallow it, it should be safe enough to write to a StringWriter
+        }
+        return writer.toString();
+    }
+
+    private static void setString(JSONObject object, String key, String value) {
+        if (value != null) {
+            try {
+                object.put(key, value);
+            } catch (JSONException e) {
+                // swallow it, null values are already guarded
+            }
+        }
+    }
+
+    private static void setStringArray(JSONObject object, String key, String[] value) {
+        if (value != null) {
+            JSONArray array = new JSONArray(Arrays.asList(value));
+            try {
+                object.put(key, array);
+            } catch (JSONException e) {
+                // swallow it, null values are already guarded
+            }
+        }
+    }
+
+    private static void setObject(JSONObject object, String key, Object value) {
+        if (value != null) {
+            try {
+                object.put(key, value);
+            } catch (JSONException e) {
+                // swallow it, null values are already guarded
+            }
+        }
+    }
+
+}

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/JWSWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/JWSWriter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/JWSWriter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/package-info.java
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/package-info.java?rev=1524395&view=auto
==============================================================================
--- oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/package-info.java (added)
+++ oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/package-info.java Wed Sep 18 13:09:02 2013
@@ -0,0 +1,21 @@
+/*
+ * 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.oltu.jose.jws.io;

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/io/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/package-info.java
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/package-info.java?rev=1524395&view=auto
==============================================================================
--- oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/package-info.java (added)
+++ oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/package-info.java Wed Sep 18 13:09:02 2013
@@ -0,0 +1,21 @@
+/*
+ * 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.oltu.jose.jws;

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/Key.java
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/Key.java?rev=1524395&view=auto
==============================================================================
--- oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/Key.java (added)
+++ oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/Key.java Wed Sep 18 13:09:02 2013
@@ -0,0 +1,31 @@
+/*
+ * 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.oltu.jose.jws.signature;
+
+/**
+ * A generic key to calculate or verify a signature.
+ */
+public interface Key {
+
+    /**
+     * The algorithms name of supported methods by this key.
+     *
+     * @return the algorithms name of supported methods by this key.
+     */
+    String[] getAlgorithmMethods();
+
+}

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/Key.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/Key.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/Key.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SignatureMethod.java
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SignatureMethod.java?rev=1524395&view=auto
==============================================================================
--- oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SignatureMethod.java (added)
+++ oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SignatureMethod.java Wed Sep 18 13:09:02 2013
@@ -0,0 +1,33 @@
+/*
+ * 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.oltu.jose.jws.signature;
+
+/**
+ * Common definition of OAuth signature method algorithm.
+ *
+ * @param <S> the {@link SigningKey} type.
+ * @param <V> the {@link VerifyingKey} type.
+ */
+public interface SignatureMethod<S extends SigningKey, V extends VerifyingKey> {
+
+    String calculate(S signingKey);
+
+    boolean verify(String signature, V verifyingKey);
+
+    String getAlgorithm();
+
+}

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SignatureMethod.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SignatureMethod.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SignatureMethod.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SigningKey.java
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SigningKey.java?rev=1524395&view=auto
==============================================================================
--- oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SigningKey.java (added)
+++ oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SigningKey.java Wed Sep 18 13:09:02 2013
@@ -0,0 +1,24 @@
+/*
+ * 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.oltu.jose.jws.signature;
+
+/**
+ * A key that marks has to be used for <i>sign</i> operations.
+ */
+public interface SigningKey extends Key {
+
+}

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SigningKey.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SigningKey.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SigningKey.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SymetricKey.java
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SymetricKey.java?rev=1524395&view=auto
==============================================================================
--- oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SymetricKey.java (added)
+++ oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SymetricKey.java Wed Sep 18 13:09:02 2013
@@ -0,0 +1,24 @@
+/*
+ * 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.oltu.jose.jws.signature;
+
+/**
+ * A key that marks can be used for both <i>sign</i> and <i>verify</i> operations.
+ */
+public interface SymetricKey extends SigningKey, VerifyingKey {
+
+}

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SymetricKey.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SymetricKey.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/SymetricKey.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/VerifyingKey.java
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/VerifyingKey.java?rev=1524395&view=auto
==============================================================================
--- oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/VerifyingKey.java (added)
+++ oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/VerifyingKey.java Wed Sep 18 13:09:02 2013
@@ -0,0 +1,24 @@
+/*
+ * 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.oltu.jose.jws.signature;
+
+/**
+ * A key that marks has to be used for <i>verify</i> operations.
+ */
+public interface VerifyingKey extends Key {
+
+}

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/VerifyingKey.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/VerifyingKey.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/VerifyingKey.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/package-info.java
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/package-info.java?rev=1524395&view=auto
==============================================================================
--- oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/package-info.java (added)
+++ oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/package-info.java Wed Sep 18 13:09:02 2013
@@ -0,0 +1,21 @@
+/*
+ * 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.oltu.jose.jws.signature;

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: oltu/trunk/jose/jws/src/main/java/org/apache/oltu/jose/jws/signature/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/io/JWSReaderTestCase.java
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/io/JWSReaderTestCase.java?rev=1524395&view=auto
==============================================================================
--- oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/io/JWSReaderTestCase.java (added)
+++ oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/io/JWSReaderTestCase.java Wed Sep 18 13:09:02 2013
@@ -0,0 +1,38 @@
+/*
+ * 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.oltu.jose.jws.io;
+
+import static junit.framework.Assert.assertEquals;
+
+import org.apache.oltu.jose.jws.JWS;
+import org.junit.Test;
+
+public final class JWSReaderTestCase {
+
+    private JWSReader reader = new JWSReader();
+
+    @Test
+    public void parse() {
+        JWS jws = reader.read("eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk");
+
+        assertEquals("JWT", jws.getHeader().getType());
+        assertEquals("HS256", jws.getHeader().getAlgorithm());
+        assertEquals("{\"iss\":\"joe\",\r\n \"exp\":1300819380,\r\n \"http://example.com/is_root\":true}", jws.getPayload());
+        assertEquals("tߴ���%O�`}ح���%Miֿ�[XXS��y", jws.getSignature());
+    }
+
+}

Propchange: oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/io/JWSReaderTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/io/JWSReaderTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/io/JWSReaderTestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/io/JWSWriterTestCase.java
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/io/JWSWriterTestCase.java?rev=1524395&view=auto
==============================================================================
--- oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/io/JWSWriterTestCase.java (added)
+++ oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/io/JWSWriterTestCase.java Wed Sep 18 13:09:02 2013
@@ -0,0 +1,42 @@
+/*
+ * 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.oltu.jose.jws.io;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.oltu.jose.jws.JWS;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public final class JWSWriterTestCase {
+
+    private final JWSWriter jwsWriter = new JWSWriter();
+
+    @Test
+    @Ignore // FIXME JSON field order makes the function not invertible!!!
+    public void serialize() {
+        JWS jws = new JWS.Builder()
+                         .setAlgorithm("HS256")
+                         .setType("JWT")
+                         .setPayload("{\"iss\":\"joe\",\r\n \"exp\":1300819380,\r\n \"http://example.com/is_root\":true}")
+                         .setSignature("tߴ���%O�`}ح���%Miֿ�[XXS��y")
+                         .build();
+        String actual = jwsWriter.write(jws).replaceAll("\r?\n", "");
+        assertEquals("eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk", actual);
+    }
+
+}

Propchange: oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/io/JWSWriterTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/io/JWSWriterTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: oltu/trunk/jose/jws/src/test/java/org/apache/oltu/jose/jws/io/JWSWriterTestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oltu/trunk/jose/pom.xml
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/pom.xml?rev=1524395&view=auto
==============================================================================
--- oltu/trunk/jose/pom.xml (added)
+++ oltu/trunk/jose/pom.xml Wed Sep 18 13:09:02 2013
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.oltu</groupId>
+    <artifactId>org.apache.oltu.parent</artifactId>
+    <version>1</version>
+    <relativePath>../parent</relativePath>
+  </parent>
+
+  <groupId>org.apache.oltu.jose</groupId>
+  <artifactId>org.apache.oltu.jose.parent</artifactId>
+  <version>1-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <name>Apache Oltu - JOSE - Parent</name>
+
+  <modules>
+    <module>jws</module>
+  </modules>
+
+</project>

Propchange: oltu/trunk/jose/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: oltu/trunk/jose/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: oltu/trunk/jose/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message