Search in sources :

Example 1 with ClientVersionInfo

use of net.kano.joscar.snaccmd.auth.ClientVersionInfo in project Openfire by igniterealtime.

the class LoginConnection method handleSnacResponse.

@Override
@SuppressWarnings("unchecked")
protected void handleSnacResponse(SnacResponseEvent e) {
    SnacCommand cmd = e.getSnacCommand();
    if (cmd instanceof KeyResponse) {
        Log.debug("Handling AIM-style auth.");
        KeyResponse kr = (KeyResponse) cmd;
        ByteBlock authkey = kr.getKey();
        //            ClientVersionInfo version = new ClientVersionInfo(
        //                        "AOL Instant Messenger, version 5.5.3415/WIN32",
        //                        -1, 5, 5, 0, 3415, 239);
        ClientVersionInfo version = new ClientVersionInfo("Apple iChat", 0x311a, 1, 0, 0, 0x0184, 0xc6);
        String pass = getMainSession().getRegistration().getPassword();
        if (getMainSession().getTransport().getType().equals(TransportType.icq)) {
            if (pass.length() > 8) {
                pass = pass.substring(0, 8);
            }
        }
        request(new AuthRequest(getMainSession().getRegistration().getUsername(), pass, version, Locale.US, authkey));
    } else if (cmd instanceof AuthResponse) {
        Log.debug("Got auth response!");
        AuthResponse ar = (AuthResponse) cmd;
        int error = ar.getErrorCode();
        if (error != -1) {
            String errormsg;
            switch(error) {
                case (AuthResponse.ERROR_ACCOUNT_DELETED):
                    {
                        errormsg = LocaleUtils.getLocalizedString("gateway.oscar.accountdeleted", "kraken");
                        getMainSession().setFailureStatus(ConnectionFailureReason.USERNAME_OR_PASSWORD_INCORRECT);
                        break;
                    }
                case (AuthResponse.ERROR_BAD_INPUT):
                    {
                        errormsg = LocaleUtils.getLocalizedString("gateway.oscar.badinput", "kraken");
                        getMainSession().setFailureStatus(ConnectionFailureReason.USERNAME_OR_PASSWORD_INCORRECT);
                        break;
                    }
                case (AuthResponse.ERROR_BAD_PASSWORD):
                    {
                        errormsg = LocaleUtils.getLocalizedString("gateway.oscar.badpassword", "kraken");
                        getMainSession().setFailureStatus(ConnectionFailureReason.USERNAME_OR_PASSWORD_INCORRECT);
                        break;
                    }
                case (AuthResponse.ERROR_CLIENT_TOO_OLD):
                    {
                        errormsg = LocaleUtils.getLocalizedString("gateway.oscar.oldclient", "kraken");
                        getMainSession().setFailureStatus(ConnectionFailureReason.LOCKED_OUT);
                        break;
                    }
                case (AuthResponse.ERROR_CONNECTING_TOO_MUCH_A):
                case (AuthResponse.ERROR_CONNECTING_TOO_MUCH_B):
                    {
                        errormsg = LocaleUtils.getLocalizedString("gateway.oscar.connectedtoomuch", "kraken");
                        getMainSession().setFailureStatus(ConnectionFailureReason.LOCKED_OUT);
                        break;
                    }
                case (AuthResponse.ERROR_INVALID_SN_OR_PASS_A):
                case (AuthResponse.ERROR_INVALID_SN_OR_PASS_B):
                    {
                        errormsg = LocaleUtils.getLocalizedString("gateway.oscar.baduserorpass", "kraken");
                        getMainSession().setFailureStatus(ConnectionFailureReason.USERNAME_OR_PASSWORD_INCORRECT);
                        break;
                    }
                case (AuthResponse.ERROR_SIGNON_BLOCKED):
                    {
                        errormsg = LocaleUtils.getLocalizedString("gateway.oscar.accountsuspended", "kraken");
                        getMainSession().setFailureStatus(ConnectionFailureReason.LOCKED_OUT);
                        break;
                    }
                default:
                    {
                        errormsg = LocaleUtils.getLocalizedString("gateway.oscar.unknownerror", "kraken", Arrays.asList(error, ar.getErrorUrl()));
                        getMainSession().setFailureStatus(ConnectionFailureReason.UNKNOWN);
                    }
            }
            getMainSession().sessionDisconnectedNoReconnect(errormsg);
        } else {
            Log.debug("Got something else?");
            getMainSession().setLoginStatus(TransportLoginStatus.LOGGED_IN);
            getMainSession().startBosConn(ar.getServer(), ar.getPort(), ar.getCookie());
            Log.debug("OSCAR connection to " + ar.getServer() + ":" + ar.getPort());
        }
        disconnect();
    }
}
Also used : AuthRequest(net.kano.joscar.snaccmd.auth.AuthRequest) KeyResponse(net.kano.joscar.snaccmd.auth.KeyResponse) ByteBlock(net.kano.joscar.ByteBlock) ClientVersionInfo(net.kano.joscar.snaccmd.auth.ClientVersionInfo) SnacCommand(net.kano.joscar.flapcmd.SnacCommand) AuthResponse(net.kano.joscar.snaccmd.auth.AuthResponse)

Aggregations

ByteBlock (net.kano.joscar.ByteBlock)1 SnacCommand (net.kano.joscar.flapcmd.SnacCommand)1 AuthRequest (net.kano.joscar.snaccmd.auth.AuthRequest)1 AuthResponse (net.kano.joscar.snaccmd.auth.AuthResponse)1 ClientVersionInfo (net.kano.joscar.snaccmd.auth.ClientVersionInfo)1 KeyResponse (net.kano.joscar.snaccmd.auth.KeyResponse)1