You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oltu.apache.org by as...@apache.org on 2016/02/19 10:22:19 UTC

svn commit: r1731209 - in /oltu/trunk/jose/jwe/src/main/java/org/apache/oltu/jose/jwe/io: JWEReader.java JWEWriter.java

Author: asanso
Date: Fri Feb 19 09:22:19 2016
New Revision: 1731209

URL: http://svn.apache.org/viewvc?rev=1731209&view=rev
Log:
OLTU-80 - Implement JWE support for JWT

Added:
    oltu/trunk/jose/jwe/src/main/java/org/apache/oltu/jose/jwe/io/JWEReader.java
    oltu/trunk/jose/jwe/src/main/java/org/apache/oltu/jose/jwe/io/JWEWriter.java

Added: oltu/trunk/jose/jwe/src/main/java/org/apache/oltu/jose/jwe/io/JWEReader.java
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jwe/src/main/java/org/apache/oltu/jose/jwe/io/JWEReader.java?rev=1731209&view=auto
==============================================================================
--- oltu/trunk/jose/jwe/src/main/java/org/apache/oltu/jose/jwe/io/JWEReader.java (added)
+++ oltu/trunk/jose/jwe/src/main/java/org/apache/oltu/jose/jwe/io/JWEReader.java Fri Feb 19 09:22:19 2016
@@ -0,0 +1,37 @@
+/*
+ * 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.jwe.io;
+
+import org.apache.oltu.commons.encodedtoken.TokenReader;
+import org.apache.oltu.jose.jwe.JWE;
+
+public class JWEReader extends TokenReader<JWE>{
+
+    @Override
+    protected JWE build(String rawString, String decodedHeader,
+            String decodedBody, String encodedSignature) {
+        final JWE.Builder jweBuilder = new JWE.Builder();
+        
+        new JWEHeaderParser(jweBuilder).read(decodedHeader);
+        
+        return jweBuilder
+                .setPayload(decodedBody)
+                //.setSignature(encodedSignature) //TODO
+                .build();
+    }
+
+}

Added: oltu/trunk/jose/jwe/src/main/java/org/apache/oltu/jose/jwe/io/JWEWriter.java
URL: http://svn.apache.org/viewvc/oltu/trunk/jose/jwe/src/main/java/org/apache/oltu/jose/jwe/io/JWEWriter.java?rev=1731209&view=auto
==============================================================================
--- oltu/trunk/jose/jwe/src/main/java/org/apache/oltu/jose/jwe/io/JWEWriter.java (added)
+++ oltu/trunk/jose/jwe/src/main/java/org/apache/oltu/jose/jwe/io/JWEWriter.java Fri Feb 19 09:22:19 2016
@@ -0,0 +1,40 @@
+/*
+ * 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.jwe.io;
+
+import org.apache.oltu.commons.encodedtoken.TokenWriter;
+import org.apache.oltu.jose.jwe.JWE;
+
+public class JWEWriter extends TokenWriter<JWE>{
+
+    @Override
+    protected String writeHeader(JWE token) {
+        return new JWEHeaderWriter().write(token.getHeader());
+    }
+
+    @Override
+    protected String writeBody(JWE token) {
+        return token.getPayload();
+    }
+
+    @Override
+    protected String writeSignature(JWE token) {
+        // TODO
+        return null;
+    }
+
+}