Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ibcalpha/ibc/IbcTws.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ private static List<WindowHandler> createWindowHandlers() {
windowHandlers.add(new ExitConfirmationDialogHandler());
windowHandlers.add(new TradingLoginHandoffDialogHandler());
windowHandlers.add(new LoginFailedDialogHandler());
windowHandlers.add(new UnrecognizedUsernameOrPasswordDialogHandler());
windowHandlers.add(new TooManyFailedLoginAttemptsDialogHandler());
windowHandlers.add(new ShutdownProgressDialogHandler());
windowHandlers.add(new BidAskLastSizeDisplayUpdateDialogHandler());
Expand Down
55 changes: 55 additions & 0 deletions src/ibcalpha/ibc/UnrecognizedUsernameOrPasswordDialogHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// This file is part of IBC.
// Copyright (C) 2004 Steven M. Kearns (skearns23@yahoo.com )
// Copyright (C) 2004 - 2020 Richard L King (rlking@aultan.com)
// For conditions of distribution and use, see copyright notice in COPYING.txt

// IBC is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// IBC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with IBC. If not, see <http://www.gnu.org/licenses/>.

package ibcalpha.ibc;

import java.awt.Window;
import java.awt.event.WindowEvent;
import javax.swing.JDialog;

public class UnrecognizedUsernameOrPasswordDialogHandler implements WindowHandler {
final String DIALOG_TITLE = "Unrecognized Username or Password";

@Override
public boolean filterEvent(Window window, int eventId) {
switch (eventId) {
case WindowEvent.WINDOW_OPENED:
return true;
default:
return false;
}
}

@Override
public void handleWindow(Window window, int eventID) {
Utils.logToConsole("Unrecognized Username or Password");
Utils.logToConsole("Cold restart in progress");
MyCachedThreadPool.getInstance().execute(new StopTask(null, true, "Cold restart after Unrecognized Username or Password dialog encountered"));

if (! SwingUtils.clickButton(window, "OK")) {
Utils.logError("could not dismiss Unrecognized Username or Password dialog because we could not find the OK button");
}
}

@Override
public boolean recogniseWindow(Window window) {
if (! (window instanceof JDialog)) return false;

return (SwingUtils.titleContains(window, DIALOG_TITLE));
}
}