Repository: knox Updated Branches: refs/heads/master d3cea9608 -> 80dc25512
KNOX-1544 - KnoxTokenCredentialCollector should not call System.exit() Project: http://git-wip-us.apache.org/repos/asf/knox/repo Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/80dc2551 Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/80dc2551 Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/80dc2551 Branch: refs/heads/master Commit: 80dc25512fabf87ed0a9fad0ff78332a2bdf634b Parents: d3cea96 Author: Phil Zampino <[email protected]> Authored: Tue Oct 30 16:49:57 2018 -0400 Committer: Phil Zampino <[email protected]> Committed: Tue Oct 30 17:11:40 2018 -0400 ---------------------------------------------------------------------- .../shell/KnoxTokenCredentialCollector.java | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/knox/blob/80dc2551/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxTokenCredentialCollector.java ---------------------------------------------------------------------- diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxTokenCredentialCollector.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxTokenCredentialCollector.java index cfccccc..c0ade6a 100644 --- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxTokenCredentialCollector.java +++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxTokenCredentialCollector.java @@ -30,12 +30,12 @@ import java.util.Map; import org.apache.knox.gateway.util.JsonUtils; public class KnoxTokenCredentialCollector extends AbstractCredentialCollector { - /** - * - */ - private static final String KNOXTOKENCACHE = ".knoxtokencache"; + public static final String COLLECTOR_TYPE = "KnoxToken"; - public String targetUrl = null; + + private static final String KNOXTOKENCACHE = ".knoxtokencache"; + + private String targetUrl = null; /* (non-Javadoc) * @see CredentialCollector#collect() @@ -54,17 +54,13 @@ public class KnoxTokenCredentialCollector extends AbstractCredentialCollector { targetUrl = attrs.get("target_url"); Date expires = new Date(Long.parseLong(attrs.get("expires_in"))); if (expires.before(new Date())) { - System.out.println("Cached knox token has expired. Please relogin through knoxinit."); - System.exit(1); + throw new CredentialCollectionException("Cached knox token has expired. Please relogin through knoxinit."); } } catch (IOException e) { - System.out.println("Cached knox token cannot be read. Please login through knoxinit."); - System.exit(1); - e.printStackTrace(); + throw new CredentialCollectionException("Cached knox token cannot be read. Please login through knoxinit.", e); } } else { - System.out.println("Cached knox token cannot be found. Please login through knoxinit."); - System.exit(1); + throw new CredentialCollectionException("Cached knox token cannot be found. Please login through knoxinit."); } }
