From 63ad820e63f9b165c70ec4a545e9332b0e6369b8 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 18 Apr 2016 16:01:17 +0200 Subject: [PATCH] use UUID instead of incremental int id --- .../git4idea/http/GitAskPassApp.java | 14 ++++---- .../git4idea/http/GitAskPassXmlRpcClient.java | 10 +++--- .../http/GitAskPassXmlRpcHandler.java | 10 +++--- .../jetbrains/git4idea/ssh/GitSSHHandler.java | 34 ++++++++----------- .../git4idea/ssh/GitSSHXmlRpcClient.java | 30 ++++++++-------- .../org/jetbrains/git4idea/ssh/SSHMain.java | 6 ++-- .../src/git4idea/commands/GitHandler.java | 14 ++++---- .../git4idea/commands/GitHttpAuthService.java | 11 +++--- .../rebase/GitRebaseEditorService.java | 5 +-- .../git4idea/ssh/GitXmlRpcHandlerService.java | 15 ++++---- .../git4idea/ssh/GitXmlRpcSshService.java | 27 ++++++++------- 11 files changed, 86 insertions(+), 90 deletions(-) diff --git a/plugins/git4idea/rt/src/org/jetbrains/git4idea/http/GitAskPassApp.java b/plugins/git4idea/rt/src/org/jetbrains/git4idea/http/GitAskPassApp.java index 8c8e425570a2..8ce927804e52 100644 --- a/plugins/git4idea/rt/src/org/jetbrains/git4idea/http/GitAskPassApp.java +++ b/plugins/git4idea/rt/src/org/jetbrains/git4idea/http/GitAskPassApp.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,16 +56,16 @@ public class GitAskPassApp implements GitExternalApp { boolean usernameNeeded = arguments.getFirst(); String url = arguments.getSecond(); - int handler = Integer.parseInt(getNotNull(GitAskPassXmlRpcHandler.GIT_ASK_PASS_HANDLER_ENV)); + String token = getNotNull(GitAskPassXmlRpcHandler.GIT_ASK_PASS_HANDLER_ENV); int xmlRpcPort = Integer.parseInt(getNotNull(GitAskPassXmlRpcHandler.GIT_ASK_PASS_PORT_ENV)); GitAskPassXmlRpcClient xmlRpcClient = new GitAskPassXmlRpcClient(xmlRpcPort); if (usernameNeeded) { - String username = xmlRpcClient.askUsername(handler, url); + String username = xmlRpcClient.askUsername(token, url); System.out.println(username); } else { - String pass = xmlRpcClient.askPassword(handler, url); + String pass = xmlRpcClient.askPassword(token, url); System.out.println(pass); } } @@ -77,11 +77,11 @@ public class GitAskPassApp implements GitExternalApp { @NotNull private static String getNotNull(@NotNull String env) { - String handlerValue = System.getenv(env); - if (handlerValue == null) { + String value = System.getenv(env); + if (value == null) { throw new IllegalStateException(env + " environment variable is not defined!"); } - return handlerValue; + return value; } @NotNull diff --git a/plugins/git4idea/rt/src/org/jetbrains/git4idea/http/GitAskPassXmlRpcClient.java b/plugins/git4idea/rt/src/org/jetbrains/git4idea/http/GitAskPassXmlRpcClient.java index 5d3f8681f099..85e49697416e 100644 --- a/plugins/git4idea/rt/src/org/jetbrains/git4idea/http/GitAskPassXmlRpcClient.java +++ b/plugins/git4idea/rt/src/org/jetbrains/git4idea/http/GitAskPassXmlRpcClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,9 +38,9 @@ class GitAskPassXmlRpcClient { // Obsolete collection usage because of the XmlRpcClientLite API @SuppressWarnings({"UseOfObsoleteCollectionType", "unchecked"}) - String askUsername(int handler, @NotNull String url) { + String askUsername(String token, @NotNull String url) { Vector parameters = new Vector(); - parameters.add(handler); + parameters.add(token); parameters.add(url); try { @@ -56,9 +56,9 @@ class GitAskPassXmlRpcClient { // Obsolete collection usage because of the XmlRpcClientLite API @SuppressWarnings({"UseOfObsoleteCollectionType", "unchecked"}) - String askPassword(int handler, @NotNull String url) { + String askPassword(String token, @NotNull String url) { Vector parameters = new Vector(); - parameters.add(handler); + parameters.add(token); parameters.add(url); try { diff --git a/plugins/git4idea/rt/src/org/jetbrains/git4idea/http/GitAskPassXmlRpcHandler.java b/plugins/git4idea/rt/src/org/jetbrains/git4idea/http/GitAskPassXmlRpcHandler.java index 36cc365c1d80..9c9900a1f3ca 100644 --- a/plugins/git4idea/rt/src/org/jetbrains/git4idea/http/GitAskPassXmlRpcHandler.java +++ b/plugins/git4idea/rt/src/org/jetbrains/git4idea/http/GitAskPassXmlRpcHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,25 +31,25 @@ public interface GitAskPassXmlRpcHandler { /** * Get the username from the user to access the given URL. - * @param handler XML RPC handler number. + * @param token Access token. * @param url URL which Git tries to access. * @return The Username which should be used for the URL. */ // UnusedDeclaration suppressed: the method is used via XML RPC @SuppressWarnings("UnusedDeclaration") @NotNull - String askUsername(int handler, @NotNull String url); + String askUsername(String token, @NotNull String url); /** * Get the password from the user to access the given URL. * It is assumed that the username either is specified in the URL (http://username@host.com), or has been asked earlier. - * @param handler XML RPC handler number. + * @param token Access token. * @param url URL which Git tries to access. * @return The password which should be used for the URL. */ // UnusedDeclaration suppressed: the method is used via XML RPC @SuppressWarnings("UnusedDeclaration") @NotNull - String askPassword(int handler, @NotNull String url); + String askPassword(String token, @NotNull String url); } diff --git a/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/GitSSHHandler.java b/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/GitSSHHandler.java index 2bc849d83fb0..4ce4ea31b6a2 100644 --- a/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/GitSSHHandler.java +++ b/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/GitSSHHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,16 +29,10 @@ public interface GitSSHHandler { */ @NonNls String GIT_SSH_PREFIX = "git-ssh-"; /** - * Name of environment variable for SSH handler number + * Name of environment variable for SSH handler access token */ @NonNls String SSH_HANDLER_ENV = "GIT4IDEA_SSH_HANDLER"; - /** - * Name of environment variable for SSH handler number - */ @NonNls String SSH_IGNORE_KNOWN_HOSTS_ENV = "GIT4IDEA_SSH_IGNORE_KNOWN_HOSTS"; - /** - * Name of environment variable for SSH handler - */ @NonNls String SSH_PORT_ENV = "GIT4IDEA_SSH_PORT"; /** * Name of environment variable for SSH executable @@ -60,7 +54,7 @@ public interface GitSSHHandler { /** * Verify server host key * - * @param handler a handler identifier + * @param token Access token. * @param hostName a host name * @param port a port number * @param serverHostKeyAlgorithm an algorithm @@ -68,7 +62,7 @@ public interface GitSSHHandler { * @param isNew true if the key is a new, false if the key was changed * @return true the host is verified, false otherwise */ - boolean verifyServerHostKey(int handler, + boolean verifyServerHostKey(String token, String hostName, int port, String serverHostKeyAlgorithm, @@ -78,7 +72,7 @@ public interface GitSSHHandler { /** * Ask passphrase for the key * - * @param handler a handler identifier + * @param token Access token. * @param userName a name of user * @param keyPath a path for the key * @param resetPassword a reset password if one was stored in password database @@ -86,12 +80,12 @@ public interface GitSSHHandler { * @return the passphrase entered by the user */ @Nullable - String askPassphrase(final int handler, final String userName, final String keyPath, boolean resetPassword, final String lastError); + String askPassphrase(String token, final String userName, final String keyPath, boolean resetPassword, final String lastError); /** * Reply to challenge for keyboard-interactive method. Also used for * - * @param handlerNo a handler identifier + * @param token Access token. * @param userName a user name (includes host and port) * @param name name of challenge * @param instruction instruction @@ -103,7 +97,7 @@ public interface GitSSHHandler { */ @SuppressWarnings({"UseOfObsoleteCollectionType"}) @Nullable - Vector replyToChallenge(final int handlerNo, + Vector replyToChallenge(String token, final String userName, final String name, final String instruction, @@ -115,19 +109,19 @@ public interface GitSSHHandler { /** * Ask password for the specified user name * - * @param handlerNo a handler identifier + * @param token Access token. * @param userName a name of user to ask password for * @param resetPassword a reset password if one was stored in password database * @param lastError a last error * @return the password or null if authentication failed. */ @Nullable - String askPassword(final int handlerNo, final String userName, boolean resetPassword, final String lastError); + String askPassword(String token, final String userName, boolean resetPassword, final String lastError); /** * Notify invoker about last successful authentication attempt. * - * @param handlerNo the handler + * @param token the handler * @param userName the user name * @param method the authentication method, the empty string means that authentication failed * @param error the error shown in the case when authentication process failed @@ -135,14 +129,14 @@ public interface GitSSHHandler { * @return The method doesn't return any sensible value, but it is needed here, since the Apache XML-RPC implementation which we use * doesn't allow void methods: "IllegalArgumentException: void return types for handler methods not supported". */ - String setLastSuccessful(final int handlerNo, final String userName, final String method, final String error); + String setLastSuccessful(String token, final String userName, final String method, final String error); /** * Get last successful authentication method * - * @param handlerNo the handler no + * @param token Access token * @param userName the user name * @return the authentication method, the empty string means that last authentication failed */ - String getLastSuccessful(final int handlerNo, final String userName); + String getLastSuccessful(String token, final String userName); } diff --git a/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/GitSSHXmlRpcClient.java b/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/GitSSHXmlRpcClient.java index c4ddd216e1cd..593362a3ee8e 100644 --- a/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/GitSSHXmlRpcClient.java +++ b/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/GitSSHXmlRpcClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public class GitSSHXmlRpcClient implements GitSSHHandler { * {@inheritDoc} */ @SuppressWarnings("unchecked") - public boolean verifyServerHostKey(final int handler, + public boolean verifyServerHostKey(String token, final String hostname, final int port, final String serverHostKeyAlgorithm, @@ -59,7 +59,7 @@ public class GitSSHXmlRpcClient implements GitSSHHandler { return false; } Vector parameters = new Vector(); - parameters.add(handler); + parameters.add(token); parameters.add(hostname); parameters.add(port); parameters.add(serverHostKeyAlgorithm); @@ -91,7 +91,7 @@ public class GitSSHXmlRpcClient implements GitSSHHandler { */ @Nullable @SuppressWarnings("unchecked") - public String askPassphrase(final int handler, + public String askPassphrase(String token, final String username, final String keyPath, final boolean resetPassword, @@ -100,7 +100,7 @@ public class GitSSHXmlRpcClient implements GitSSHHandler { return null; } Vector parameters = new Vector(); - parameters.add(handler); + parameters.add(token); parameters.add(username); parameters.add(keyPath); parameters.add(resetPassword); @@ -121,7 +121,7 @@ public class GitSSHXmlRpcClient implements GitSSHHandler { */ @Nullable @SuppressWarnings("unchecked") - public Vector replyToChallenge(final int handlerNo, + public Vector replyToChallenge(String token, final String username, final String name, final String instruction, @@ -133,7 +133,7 @@ public class GitSSHXmlRpcClient implements GitSSHHandler { return null; } Vector parameters = new Vector(); - parameters.add(handlerNo); + parameters.add(token); parameters.add(username); parameters.add(name); parameters.add(instruction); @@ -157,12 +157,12 @@ public class GitSSHXmlRpcClient implements GitSSHHandler { */ @Nullable @SuppressWarnings("unchecked") - public String askPassword(final int handlerNo, final String username, final boolean resetPassword, final String lastError) { + public String askPassword(String token, final String username, final boolean resetPassword, final String lastError) { if (myClient == null) { return null; } Vector parameters = new Vector(); - parameters.add(handlerNo); + parameters.add(token); parameters.add(username); parameters.add(resetPassword); parameters.add(lastError); @@ -179,12 +179,12 @@ public class GitSSHXmlRpcClient implements GitSSHHandler { @Override @SuppressWarnings("unchecked") - public String setLastSuccessful(int handlerNo, String userName, String method, String error) { + public String setLastSuccessful(String token, String userName, String method, String error) { if (myClient == null) { return ""; } Vector parameters = new Vector(); - parameters.add(handlerNo); + parameters.add(token); parameters.add(userName); parameters.add(method); parameters.add(error); @@ -204,22 +204,22 @@ public class GitSSHXmlRpcClient implements GitSSHHandler { */ @Override @SuppressWarnings("unchecked") - public String getLastSuccessful(int handlerNo, String userName) { + public String getLastSuccessful(String token, String userName) { if (myClient == null) { return ""; } Vector parameters = new Vector(); - parameters.add(handlerNo); + parameters.add(token); parameters.add(userName); try { return (String)myClient.execute(methodName("getLastSuccessful"), parameters); } catch (XmlRpcException e) { - log("getLastSuccessful failed. handlerNo: " + handlerNo + ", userName: " + userName + ", client: " + myClient.getURL()); + log("getLastSuccessful failed. token: " + token + ", userName: " + userName + ", client: " + myClient.getURL()); throw new RuntimeException("Invocation failed " + e.getMessage(), e); } catch (IOException e) { - log("getLastSuccessful failed. handlerNo: " + handlerNo + ", userName: " + userName + ", client: " + myClient.getURL()); + log("getLastSuccessful failed. token: " + token + ", userName: " + userName + ", client: " + myClient.getURL()); throw new RuntimeException("Invocation failed " + e.getMessage(), e); } } diff --git a/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/SSHMain.java b/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/SSHMain.java index b5bc260b9520..67a74b92b0ac 100644 --- a/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/SSHMain.java +++ b/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/SSHMain.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ public class SSHMain implements GitExternalApp { /** * Handler number */ - private final int myHandlerNo; + private final String myHandlerNo; /** * the xml RPC port */ @@ -120,7 +120,7 @@ public class SSHMain implements GitExternalApp { private SSHMain(String host, String username, Integer port, String command) throws IOException { SSHConfig config = SSHConfig.load(); myHost = config.lookup(username, host, port); - myHandlerNo = Integer.parseInt(System.getenv(GitSSHHandler.SSH_HANDLER_ENV)); + myHandlerNo = System.getenv(GitSSHHandler.SSH_HANDLER_ENV); int xmlRpcPort = Integer.parseInt(System.getenv(GitSSHHandler.SSH_PORT_ENV)); myXmlRpcClient = new GitSSHXmlRpcClient(xmlRpcPort, myHost.isBatchMode()); myCommand = command; diff --git a/plugins/git4idea/src/git4idea/commands/GitHandler.java b/plugins/git4idea/src/git4idea/commands/GitHandler.java index ef234be88087..52aec9f6388e 100644 --- a/plugins/git4idea/src/git4idea/commands/GitHandler.java +++ b/plugins/git4idea/src/git4idea/commands/GitHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,8 +89,8 @@ public abstract class GitHandler { private final File myWorkingDirectory; private boolean myEnvironmentCleanedUp = true; // the flag indicating that environment has been cleaned up, by default is true because there is nothing to clean - private int mySshHandler = -1; - private int myHttpHandler = -1; + private UUID mySshHandler; + private UUID myHttpHandler; private Processor myInputProcessor; // The processor for stdin // if true process might be cancelled @@ -463,7 +463,7 @@ public abstract class GitHandler { GitHttpAuthenticator httpAuthenticator = service.createAuthenticator(myProject, myCommand, ObjectUtils.assertNotNull(myUrls)); myHttpHandler = service.registerHandler(httpAuthenticator, myProject); myEnvironmentCleanedUp = false; - myEnv.put(GitAskPassXmlRpcHandler.GIT_ASK_PASS_HANDLER_ENV, Integer.toString(myHttpHandler)); + myEnv.put(GitAskPassXmlRpcHandler.GIT_ASK_PASS_HANDLER_ENV, myHttpHandler.toString()); int port = service.getXmlRcpPort(); myEnv.put(GitAskPassXmlRpcHandler.GIT_ASK_PASS_PORT_ENV, Integer.toString(port)); LOG.debug(String.format("handler=%s, port=%s", myHttpHandler, port)); @@ -475,7 +475,7 @@ public abstract class GitHandler { myEnv.put(GitSSHHandler.GIT_SSH_ENV, ssh.getScriptPath().getPath()); mySshHandler = ssh.registerHandler(new GitSSHGUIHandler(myProject), myProject); myEnvironmentCleanedUp = false; - myEnv.put(GitSSHHandler.SSH_HANDLER_ENV, Integer.toString(mySshHandler)); + myEnv.put(GitSSHHandler.SSH_HANDLER_ENV, mySshHandler.toString()); int port = ssh.getXmlRcpPort(); myEnv.put(GitSSHHandler.SSH_PORT_ENV, Integer.toString(port)); LOG.debug(String.format("handler=%s, port=%s", mySshHandler, port)); @@ -602,10 +602,10 @@ public abstract class GitHandler { if (myEnvironmentCleanedUp) { return; } - if (mySshHandler >= 0) { + if (mySshHandler != null) { ServiceManager.getService(GitXmlRpcSshService.class).unregisterHandler(mySshHandler); } - if (myHttpHandler >= 0) { + if (myHttpHandler != null) { ServiceManager.getService(GitHttpAuthService.class).unregisterHandler(myHttpHandler); } myEnvironmentCleanedUp = true; diff --git a/plugins/git4idea/src/git4idea/commands/GitHttpAuthService.java b/plugins/git4idea/src/git4idea/commands/GitHttpAuthService.java index 6ddbcab22147..7cc1a8deb06c 100644 --- a/plugins/git4idea/src/git4idea/commands/GitHttpAuthService.java +++ b/plugins/git4idea/src/git4idea/commands/GitHttpAuthService.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import org.jetbrains.git4idea.ssh.GitXmlRpcHandlerService; import org.jetbrains.git4idea.util.ScriptGenerator; import java.util.Collection; +import java.util.UUID; /** * Provides the authentication mechanism for Git HTTP connections. @@ -57,14 +58,14 @@ public abstract class GitHttpAuthService extends GitXmlRpcHandlerServiceThe provider of external application scripts called by Git when a remote operation needs communication with the user.

@@ -57,8 +58,7 @@ public abstract class GitXmlRpcHandlerService { @Nullable private File myScriptPath; @NotNull private final Object SCRIPT_FILE_LOCK = new Object(); - @NotNull private final THashMap handlers = new THashMap(); - private int myNextHandlerKey; + @NotNull private final THashMap handlers = new THashMap(); @NotNull private final Object HANDLERS_LOCK = new Object(); /** @@ -111,14 +111,14 @@ public abstract class GitXmlRpcHandlerService { * @param parentDisposable a disposable to unregister the handler if it doesn't get unregistered manually * @return an identifier to pass to the environment variable */ - public int registerHandler(@NotNull T handler, @NotNull Disposable parentDisposable) { + public UUID registerHandler(@NotNull T handler, @NotNull Disposable parentDisposable) { synchronized (HANDLERS_LOCK) { XmlRpcServer xmlRpcServer = XmlRpcServer.SERVICE.getInstance(); if (!xmlRpcServer.hasHandler(myHandlerName)) { xmlRpcServer.addHandler(myHandlerName, createRpcRequestHandlerDelegate()); } - final int key = myNextHandlerKey; + final UUID key = UUID.randomUUID(); handlers.put(key, handler); Disposer.register(parentDisposable, new Disposable() { @Override @@ -126,7 +126,6 @@ public abstract class GitXmlRpcHandlerService { handlers.remove(key); } }); - myNextHandlerKey++; return key; } } @@ -146,7 +145,7 @@ public abstract class GitXmlRpcHandlerService { * @return the registered handler */ @NotNull - protected T getHandler(int key) { + protected T getHandler(UUID key) { synchronized (HANDLERS_LOCK) { T rc = handlers.get(key); if (rc == null) { @@ -161,7 +160,7 @@ public abstract class GitXmlRpcHandlerService { * * @param key the key to unregister */ - public void unregisterHandler(int key) { + public void unregisterHandler(UUID key) { synchronized (HANDLERS_LOCK) { if (handlers.remove(key) == null) { throw new IllegalArgumentException("The handler " + key + " is not registered"); diff --git a/plugins/git4idea/src/org/jetbrains/git4idea/ssh/GitXmlRpcSshService.java b/plugins/git4idea/src/org/jetbrains/git4idea/ssh/GitXmlRpcSshService.java index 5d802d36e065..9b03e6db8c94 100644 --- a/plugins/git4idea/src/org/jetbrains/git4idea/ssh/GitXmlRpcSshService.java +++ b/plugins/git4idea/src/org/jetbrains/git4idea/ssh/GitXmlRpcSshService.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import git4idea.commands.GitSSHGUIHandler; import org.jetbrains.annotations.NotNull; import org.jetbrains.git4idea.util.ScriptGenerator; +import java.util.UUID; import java.util.Vector; /** @@ -49,37 +50,37 @@ public class GitXmlRpcSshService extends GitXmlRpcHandlerService replyToChallenge(int handlerNo, String username, String name, String instruction, int numPrompts, + public Vector replyToChallenge(String token, String username, String name, String instruction, int numPrompts, Vector prompt, Vector echo, String lastError) { - return adjustNull(getHandler(handlerNo).replyToChallenge(username, name, instruction, numPrompts, prompt, echo, lastError)); + return adjustNull(getHandler(UUID.fromString(token)).replyToChallenge(username, name, instruction, numPrompts, prompt, echo, lastError)); } @Override - public String askPassword(int handlerNo, String username, boolean resetPassword, String lastError) { - return adjustNull(getHandler(handlerNo).askPassword(username, resetPassword, lastError)); + public String askPassword(String token, String username, boolean resetPassword, String lastError) { + return adjustNull(getHandler(UUID.fromString(token)).askPassword(username, resetPassword, lastError)); } @Override - public String setLastSuccessful(int handlerNo, String userName, String method, String error) { - getHandler(handlerNo).setLastSuccessful(userName, method, error); + public String setLastSuccessful(String token, String userName, String method, String error) { + getHandler(UUID.fromString(token)).setLastSuccessful(userName, method, error); return ""; } @Override - public String getLastSuccessful(int handlerNo, String userName) { - return getHandler(handlerNo).getLastSuccessful(userName); + public String getLastSuccessful(String token, String userName) { + return getHandler(UUID.fromString(token)).getLastSuccessful(userName); } /**