cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Adding a couple of jose exception classes
Date Thu, 06 Aug 2015 13:03:45 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 77d3c7e8a -> 38e25eda5


Adding a couple of jose exception classes


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

Branch: refs/heads/3.0.x-fixes
Commit: 38e25eda578c8884e7f25ecbb16129bd5e642631
Parents: 77d3c7e
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Aug 6 14:02:09 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Aug 6 14:03:30 2015 +0100

----------------------------------------------------------------------
 .../cxf/rs/security/jose/jwk/JwkException.java  | 35 ++++++++++++++++++++
 .../cxf/rs/security/jose/jwk/JwkUtils.java      |  8 ++---
 .../jose/jwt/AbstractJoseJwtConsumer.java       |  5 ++-
 .../jose/jwt/AbstractJoseJwtProducer.java       |  3 +-
 .../cxf/rs/security/jose/jwt/JwtException.java  | 35 ++++++++++++++++++++
 .../cxf/rs/security/jose/jwt/JwtUtils.java      |  4 +--
 6 files changed, 79 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/38e25eda/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkException.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkException.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkException.java
new file mode 100644
index 0000000..44e9535
--- /dev/null
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkException.java
@@ -0,0 +1,35 @@
+/**
+ * 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.rs.security.jose.jwk;
+
+import org.apache.cxf.rs.security.jose.JoseException;
+
+public class JwkException extends JoseException {
+
+    private static final long serialVersionUID = 4118589816228511524L;
+    public JwkException() {
+
+    }
+    public JwkException(String error) {
+        super(error);
+    }
+    public JwkException(Throwable cause) {
+        super(cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/38e25eda/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
index b70a01c..e1f161c 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
@@ -278,11 +278,11 @@ public final class JwkUtils {
             try {
                 InputStream is = ResourceUtils.getResourceStream(keyStoreLoc, bus);
                 if (is == null) {
-                    throw new SecurityException("Error in loading keystore location: " +
keyStoreLoc);
+                    throw new JwkException("Error in loading keystore location: " + keyStoreLoc);
                 }
                 keyContent = IOUtils.readStringFromStream(is);
             } catch (Exception ex) {
-                throw new SecurityException(ex);
+                throw new JwkException(ex);
             }
         } else {
             keyContent = props.getProperty(RSSEC_KEY_STORE_JWKSET);
@@ -469,7 +469,7 @@ public final class JwkUtils {
     }
     public static JsonWebKey fromSecretKey(SecretKey secretKey, String algo) {
         if (!AlgorithmUtils.isOctet(algo)) {
-            throw new SecurityException("Invalid algorithm");
+            throw new JwkException("Invalid algorithm");
         }
         JsonWebKey jwk = new JsonWebKey();
         jwk.setKeyType(KeyType.OCTET);
@@ -491,7 +491,7 @@ public final class JwkUtils {
     }
     private static JsonWebKey prepareRSAJwk(BigInteger modulus, String algo) {
         if (!AlgorithmUtils.isRsa(algo)) {
-            throw new SecurityException("Invalid algorithm");
+            throw new JwkException("Invalid algorithm");
         }
         JsonWebKey jwk = new JsonWebKey();
         jwk.setKeyType(KeyType.RSA);

http://git-wip-us.apache.org/repos/asf/cxf/blob/38e25eda/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/AbstractJoseJwtConsumer.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/AbstractJoseJwtConsumer.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/AbstractJoseJwtConsumer.java
index 0708cac..608f09e 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/AbstractJoseJwtConsumer.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/AbstractJoseJwtConsumer.java
@@ -19,7 +19,6 @@
 package org.apache.cxf.rs.security.jose.jwt;
 
 import org.apache.cxf.rs.security.jose.AbstractJoseConsumer;
-import org.apache.cxf.rs.security.jose.JoseException;
 import org.apache.cxf.rs.security.jose.jwe.JweDecryptionProvider;
 import org.apache.cxf.rs.security.jose.jwe.JweJwtCompactConsumer;
 import org.apache.cxf.rs.security.jose.jws.JwsJwtCompactConsumer;
@@ -31,7 +30,7 @@ public abstract class AbstractJoseJwtConsumer extends AbstractJoseConsumer
{
     
     protected JwtToken getJwtToken(String wrappedJwtToken) {
         if (!isJwsRequired() && !isJweRequired()) {
-            throw new JoseException("Unable to process JWT");
+            throw new JwtException("Unable to process JWT");
         }
         JweDecryptionProvider jweDecryptor = getInitializedDecryptionProvider(isJweRequired());
         if (jweDecryptor != null) {
@@ -45,7 +44,7 @@ public abstract class AbstractJoseJwtConsumer extends AbstractJoseConsumer
{
         JwtToken jwt = jwtConsumer.getJwtToken();
         JwsSignatureVerifier theSigVerifier = getInitializedSignatureVerifier(jwt);
         if (!jwtConsumer.verifySignatureWith(theSigVerifier)) {
-            throw new SecurityException("Invalid Signature");
+            throw new JwtException("Invalid Signature");
         }
         validateToken(jwt);
         return jwt; 

http://git-wip-us.apache.org/repos/asf/cxf/blob/38e25eda/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/AbstractJoseJwtProducer.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/AbstractJoseJwtProducer.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/AbstractJoseJwtProducer.java
index 6ec4b44..b90b386 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/AbstractJoseJwtProducer.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/AbstractJoseJwtProducer.java
@@ -20,7 +20,6 @@ package org.apache.cxf.rs.security.jose.jwt;
 
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.rs.security.jose.AbstractJoseProducer;
-import org.apache.cxf.rs.security.jose.JoseException;
 import org.apache.cxf.rs.security.jose.jwe.JweEncryptionProvider;
 import org.apache.cxf.rs.security.jose.jwe.JweJwtCompactProducer;
 import org.apache.cxf.rs.security.jose.jws.JwsJwtCompactProducer;
@@ -32,7 +31,7 @@ public abstract class AbstractJoseJwtProducer extends AbstractJoseProducer
{
     
     protected String processJwt(JwtToken jwt) {
         if (!isJwsRequired() && !isJweRequired()) {
-            throw new JoseException("Unable to secure JWT");
+            throw new JwtException("Unable to secure JWT");
         }
         String data = null;
         JweEncryptionProvider theEncProvider = getInitializedEncryptionProvider(isJweRequired());

http://git-wip-us.apache.org/repos/asf/cxf/blob/38e25eda/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtException.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtException.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtException.java
new file mode 100644
index 0000000..84314bd
--- /dev/null
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtException.java
@@ -0,0 +1,35 @@
+/**
+ * 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.rs.security.jose.jwt;
+
+import org.apache.cxf.rs.security.jose.JoseException;
+
+public class JwtException extends JoseException {
+
+    private static final long serialVersionUID = 4118589816228511524L;
+    public JwtException() {
+
+    }
+    public JwtException(String error) {
+        super(error);
+    }
+    public JwtException(Throwable cause) {
+        super(cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/38e25eda/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtUtils.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtUtils.java
index 302d9c0..c846659 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtUtils.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtUtils.java
@@ -42,7 +42,7 @@ public final class JwtUtils {
         Long expiryTimeInSecs = claims.getExpiryTime();
         if (expiryTimeInSecs == null && claimsRequired 
             || expiryTimeInSecs != null && currentTimeInSecs > expiryTimeInSecs)
{
-            throw new SecurityException("The token expired");
+            throw new JwtException("The token expired");
         }
         Long issuedAtInSecs = claims.getIssuedAt();
         if (clockOffset <= 0) {
@@ -51,7 +51,7 @@ public final class JwtUtils {
         if (issuedAtInSecs == null && claimsRequired 
             || issuedAtInSecs != null && (issuedAtInSecs - clockOffset > currentTimeInSecs
|| issuedAtRange > 0
             && issuedAtInSecs < currentTimeInSecs - issuedAtRange)) {
-            throw new SecurityException("Invalid issuedAt");
+            throw new JwtException("Invalid issuedAt");
         }
     }
     


Mime
View raw message