directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From plusplusjia...@apache.org
Subject directory-kerby git commit: DIRKRB-439 Refactor the TokenEncoder and TokenDecoder.
Date Thu, 29 Oct 2015 03:30:50 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master 487043cec -> 8ee7c599f


DIRKRB-439 Refactor the TokenEncoder and TokenDecoder.


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/8ee7c599
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/8ee7c599
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/8ee7c599

Branch: refs/heads/master
Commit: 8ee7c599fd970dce4622873e76d8001b8d77ed32
Parents: 487043c
Author: plusplusjiajia <jiajia.li@intel.com>
Authored: Thu Oct 29 11:36:50 2015 +0800
Committer: plusplusjiajia <jiajia.li@intel.com>
Committed: Thu Oct 29 11:36:50 2015 +0800

----------------------------------------------------------------------
 .../kerberos/kerb/provider/TokenDecoder.java    | 37 +++++++++++++++
 .../kerberos/kerb/provider/TokenEncoder.java    | 30 +++++++++++++
 .../provider/token/JwtTokenDecoder.java         | 28 ++++++------
 .../provider/token/JwtTokenEncoder.java         | 47 +++++++++-----------
 4 files changed, 102 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8ee7c599/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/provider/TokenDecoder.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/provider/TokenDecoder.java
b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/provider/TokenDecoder.java
index e52a9b3..88bcd0c 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/provider/TokenDecoder.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/provider/TokenDecoder.java
@@ -22,6 +22,8 @@ package org.apache.kerby.kerberos.kerb.provider;
 import org.apache.kerby.kerberos.kerb.spec.base.AuthToken;
 
 import java.io.IOException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
 
 /**
  * An AuthToken decoder.
@@ -43,4 +45,39 @@ public interface TokenDecoder {
      * @throws IOException e
      */
     AuthToken decodeFromString(String content) throws IOException;
+
+    /**
+     * set the verify key
+     *
+     * @param key a public key
+     */
+    void setVerifyKey(PublicKey key);
+
+    /**
+     * set the verify key
+     *
+     * @param key a byte[] key
+     */
+    void setVerifyKey(byte[] key);
+
+    /**
+     * Set the decryption key
+     *
+     * @param key a private key
+     */
+    void setDecryptionKey(PrivateKey key);
+
+    /**
+     * Set the decryption key
+     *
+     * @param key a secret key
+     */
+    void setDecryptionKey(byte[] key);
+
+    /**
+     * The token signed or not
+     *
+     * @return signed or not signed
+     */
+    boolean isSigned();
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8ee7c599/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/provider/TokenEncoder.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/provider/TokenEncoder.java
b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/provider/TokenEncoder.java
index 90d06be..0f6cc6b 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/provider/TokenEncoder.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/provider/TokenEncoder.java
@@ -22,6 +22,9 @@ package org.apache.kerby.kerberos.kerb.provider;
 import org.apache.kerby.kerberos.kerb.KrbException;
 import org.apache.kerby.kerberos.kerb.spec.base.AuthToken;
 
+import java.security.PrivateKey;
+import java.security.PublicKey;
+
 /**
  * An AuthToken encoder.
  */
@@ -43,5 +46,32 @@ public interface TokenEncoder {
      */
     String encodeAsString(AuthToken token) throws KrbException;
 
+    /**
+     * set the encryption key
+     *
+     * @param key a public key
+     */
+    void setEncryptionKey(PublicKey key);
+
+    /**
+     * set the encryption key
+     *
+     * @param key a secret key
+     */
+    void setEncryptionKey(byte[] key);
+
+    /**
+     * set the sign key
+     *
+     * @param key a private key
+     */
+    void setSignKey(PrivateKey key);
+
+    /**
+     * set the sign key
+     *
+     * @param key a secret key
+     */
+    void setSignKey(byte[] key);
 
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8ee7c599/kerby-provider/token-provider/src/main/java/org/apache/kerby/kerberos/provider/token/JwtTokenDecoder.java
----------------------------------------------------------------------
diff --git a/kerby-provider/token-provider/src/main/java/org/apache/kerby/kerberos/provider/token/JwtTokenDecoder.java
b/kerby-provider/token-provider/src/main/java/org/apache/kerby/kerberos/provider/token/JwtTokenDecoder.java
index b42dd86..7c34bf1 100644
--- a/kerby-provider/token-provider/src/main/java/org/apache/kerby/kerberos/provider/token/JwtTokenDecoder.java
+++ b/kerby-provider/token-provider/src/main/java/org/apache/kerby/kerberos/provider/token/JwtTokenDecoder.java
@@ -164,19 +164,17 @@ public class JwtTokenDecoder implements TokenDecoder {
     }
 
     /**
-     * Set the decryption key
-     *
-     * @param key a private key
+     * {@inheritDoc}
      */
+    @Override
     public void setDecryptionKey(PrivateKey key) {
         decryptionKey = key;
     }
-    
+
     /**
-     * Set the decryption key
-     *
-     * @param key a secret key
+     * {@inheritDoc}
      */
+    @Override
     public void setDecryptionKey(byte[] key) {
         decryptionKey = key;
     }
@@ -212,19 +210,17 @@ public class JwtTokenDecoder implements TokenDecoder {
     }
 
     /**
-     * set the verify key
-     *
-     * @param key a public key
+     * {@inheritDoc}
      */
+    @Override
     public void setVerifyKey(PublicKey key) {
         verifyKey = key;
     }
-    
+
     /**
-     * set the verify key
-     *
-     * @param key a byte[] key
+     * {@inheritDoc}
      */
+    @Override
     public void setVerifyKey(byte[] key) {
         verifyKey = key;
     }
@@ -278,6 +274,10 @@ public class JwtTokenDecoder implements TokenDecoder {
         return valid;
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
     public boolean isSigned() {
         return signed;
     }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8ee7c599/kerby-provider/token-provider/src/main/java/org/apache/kerby/kerberos/provider/token/JwtTokenEncoder.java
----------------------------------------------------------------------
diff --git a/kerby-provider/token-provider/src/main/java/org/apache/kerby/kerberos/provider/token/JwtTokenEncoder.java
b/kerby-provider/token-provider/src/main/java/org/apache/kerby/kerberos/provider/token/JwtTokenEncoder.java
index 44ef6e5..0d129f4 100644
--- a/kerby-provider/token-provider/src/main/java/org/apache/kerby/kerberos/provider/token/JwtTokenEncoder.java
+++ b/kerby-provider/token-provider/src/main/java/org/apache/kerby/kerberos/provider/token/JwtTokenEncoder.java
@@ -19,18 +19,6 @@
  */
 package org.apache.kerby.kerberos.provider.token;
 
-import java.nio.charset.Charset;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.interfaces.ECPrivateKey;
-import java.security.interfaces.RSAPrivateKey;
-import java.security.interfaces.RSAPublicKey;
-import java.text.ParseException;
-
-import org.apache.kerby.kerberos.kerb.KrbException;
-import org.apache.kerby.kerberos.kerb.provider.TokenEncoder;
-import org.apache.kerby.kerberos.kerb.spec.base.AuthToken;
-
 import com.nimbusds.jose.EncryptionMethod;
 import com.nimbusds.jose.JOSEException;
 import com.nimbusds.jose.JWEAlgorithm;
@@ -49,6 +37,17 @@ import com.nimbusds.jose.crypto.RSASSASigner;
 import com.nimbusds.jwt.EncryptedJWT;
 import com.nimbusds.jwt.JWT;
 import com.nimbusds.jwt.SignedJWT;
+import org.apache.kerby.kerberos.kerb.KrbException;
+import org.apache.kerby.kerberos.kerb.provider.TokenEncoder;
+import org.apache.kerby.kerberos.kerb.spec.base.AuthToken;
+
+import java.nio.charset.Charset;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.interfaces.ECPrivateKey;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
+import java.text.ParseException;
 
 /**
  * JWT token encoder, implemented using Nimbus JWT library.
@@ -172,37 +171,33 @@ public class JwtTokenEncoder implements TokenEncoder {
     }
 
     /**
-     * set the encryption key
-     *
-     * @param key a public key
+     * {@inheritDoc}
      */
+    @Override
     public void setEncryptionKey(PublicKey key) {
         encryptionKey = key;
     }
-    
+
     /**
-     * set the encryption key
-     *
-     * @param key a secret key
+     * {@inheritDoc}
      */
+    @Override
     public void setEncryptionKey(byte[] key) {
         encryptionKey = key;
     }
 
     /**
-     * set the sign key
-     *
-     * @param key a private key
+     * {@inheritDoc}
      */
+    @Override
     public void setSignKey(PrivateKey key) {
         signKey = key;
     }
-    
+
     /**
-     * set the sign key
-     *
-     * @param key a secret key
+     * {@inheritDoc}
      */
+    @Override
     public void setSignKey(byte[] key) {
         signKey = key;
     }


Mime
View raw message