From ea6f673a813f32d507d8ea4c24b7bc1fd5781e0e Mon Sep 17 00:00:00 2001 From: brianmajor Date: Wed, 19 Jan 2022 16:01:01 -0800 Subject: [PATCH] Tokens no longer URIs with base64 prefix --- cadc-util/build.gradle | 2 +- .../java/ca/nrc/cadc/auth/SignedToken.java | 46 +++----- .../auth/encoding/TokenEncoderDecoder.java | 107 ------------------ .../nrc/cadc/auth/encoding/TokenEncoding.java | 76 ------------- 4 files changed, 19 insertions(+), 212 deletions(-) delete mode 100644 cadc-util/src/main/java/ca/nrc/cadc/auth/encoding/TokenEncoderDecoder.java delete mode 100644 cadc-util/src/main/java/ca/nrc/cadc/auth/encoding/TokenEncoding.java diff --git a/cadc-util/build.gradle b/cadc-util/build.gradle index bdf0bde6..c79d4361 100644 --- a/cadc-util/build.gradle +++ b/cadc-util/build.gradle @@ -16,7 +16,7 @@ sourceCompatibility = 1.8 group = 'org.opencadc' -version = '1.5.8' +version = '1.5.9' description = 'OpenCADC core utility library' def git_url = 'https://github.com/opencadc/core' diff --git a/cadc-util/src/main/java/ca/nrc/cadc/auth/SignedToken.java b/cadc-util/src/main/java/ca/nrc/cadc/auth/SignedToken.java index cec79a42..f601150a 100644 --- a/cadc-util/src/main/java/ca/nrc/cadc/auth/SignedToken.java +++ b/cadc-util/src/main/java/ca/nrc/cadc/auth/SignedToken.java @@ -69,8 +69,6 @@ package ca.nrc.cadc.auth; -import ca.nrc.cadc.auth.encoding.TokenEncoderDecoder; -import ca.nrc.cadc.auth.encoding.TokenEncoding; import ca.nrc.cadc.util.Base64; import ca.nrc.cadc.util.RsaSignatureGenerator; import ca.nrc.cadc.util.RsaSignatureVerifier; @@ -112,8 +110,6 @@ public class SignedToken implements Serializable { public static String EXPIRY_LABEL = "expirytime"; public static String SIGNATURE_LABEL = "signature"; - private static final TokenEncoderDecoder TOKEN_ENCODER_DECODER = new TokenEncoderDecoder(); - private Date expiryTime; // expiration time of the delegation (UTC) private URI scope; // resources that are the object of the delegation private List domains; @@ -172,18 +168,6 @@ public SignedToken(Set principals, URI scope, Date expiryTime, List. pas le cas, consultez : - * . - * - * - ************************************************************************ - */ - -package ca.nrc.cadc.auth.encoding; - -import ca.nrc.cadc.auth.InvalidSignedTokenException; -import ca.nrc.cadc.util.Base64; - -import java.io.UnsupportedEncodingException; - - -public class TokenEncoderDecoder { - public byte[] decode(final String value, final TokenEncoding tokenEncoding) - throws InvalidSignedTokenException { - switch (tokenEncoding) { - case BASE64: { - try { - return Base64.decode(value); - } catch (IllegalArgumentException e) { - throw new InvalidSignedTokenException("failed to decode token", e); - } - } - - default: { - throw new InvalidSignedTokenException(String.format("Unsupported encoding '%s'", tokenEncoding)); - } - } - } - - public char[] encode(final byte[] bytes, final TokenEncoding tokenEncoding) throws UnsupportedEncodingException { - switch (tokenEncoding) { - case BASE64: { - return Base64.encode(bytes); - } - - default: { - throw new UnsupportedEncodingException(String.format("Unsupported encoding '%s'", tokenEncoding)); - } - } - } -} diff --git a/cadc-util/src/main/java/ca/nrc/cadc/auth/encoding/TokenEncoding.java b/cadc-util/src/main/java/ca/nrc/cadc/auth/encoding/TokenEncoding.java deleted file mode 100644 index 0984f762..00000000 --- a/cadc-util/src/main/java/ca/nrc/cadc/auth/encoding/TokenEncoding.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - ************************************************************************ - ******************* CANADIAN ASTRONOMY DATA CENTRE ******************* - ************** CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** - * - * (c) 2018. (c) 2018. - * Government of Canada Gouvernement du Canada - * National Research Council Conseil national de recherches - * Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 - * All rights reserved Tous droits réservés - * - * NRC disclaims any warranties, Le CNRC dénie toute garantie - * expressed, implied, or énoncée, implicite ou légale, - * statutory, of any kind with de quelque nature que ce - * respect to the software, soit, concernant le logiciel, - * including without limitation y compris sans restriction - * any warranty of merchantability toute garantie de valeur - * or fitness for a particular marchande ou de pertinence - * purpose. NRC shall not be pour un usage particulier. - * liable in any event for any Le CNRC ne pourra en aucun cas - * damages, whether direct or être tenu responsable de tout - * indirect, special or general, dommage, direct ou indirect, - * consequential or incidental, particulier ou général, - * arising from the use of the accessoire ou fortuit, résultant - * software. Neither the name de l'utilisation du logiciel. Ni - * of the National Research le nom du Conseil National de - * Council of Canada nor the Recherches du Canada ni les noms - * names of its contributors may de ses participants ne peuvent - * be used to endorse or promote être utilisés pour approuver ou - * products derived from this promouvoir les produits dérivés - * software without specific prior de ce logiciel sans autorisation - * written permission. préalable et particulière - * par écrit. - * - * This file is part of the Ce fichier fait partie du projet - * OpenCADC project. OpenCADC. - * - * OpenCADC is free software: OpenCADC est un logiciel libre ; - * you can redistribute it and/or vous pouvez le redistribuer ou le - * modify it under the terms of modifier suivant les termes de - * the GNU Affero General Public la “GNU Affero General Public - * License as published by the License” telle que publiée - * Free Software Foundation, par la Free Software Foundation - * either version 3 of the : soit la version 3 de cette - * License, or (at your option) licence, soit (à votre gré) - * any later version. toute version ultérieure. - * - * OpenCADC is distributed in the OpenCADC est distribué - * hope that it will be useful, dans l’espoir qu’il vous - * but WITHOUT ANY WARRANTY; sera utile, mais SANS AUCUNE - * without even the implied GARANTIE : sans même la garantie - * warranty of MERCHANTABILITY implicite de COMMERCIALISABILITÉ - * or FITNESS FOR A PARTICULAR ni d’ADÉQUATION À UN OBJECTIF - * PURPOSE. See the GNU Affero PARTICULIER. Consultez la Licence - * General Public License for Générale Publique GNU Affero - * more details. pour plus de détails. - * - * You should have received Vous devriez avoir reçu une - * a copy of the GNU Affero copie de la Licence Générale - * General Public License along Publique GNU Affero avec - * with OpenCADC. If not, see OpenCADC ; si ce n’est - * . pas le cas, consultez : - * . - * - * - ************************************************************************ - */ - -package ca.nrc.cadc.auth.encoding; - -/** - * Here to support future encodings. - */ -public enum TokenEncoding { - BASE64 -}