Search in sources :

Example 6 with SnacCommand

use of net.kano.joscar.flapcmd.SnacCommand 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)

Example 7 with SnacCommand

use of net.kano.joscar.flapcmd.SnacCommand in project Openfire by igniterealtime.

the class ServiceConnection method handleSnacResponse.

@Override
protected void handleSnacResponse(SnacResponseEvent e) {
    super.handleSnacResponse(e);
    SnacCommand cmd = e.getSnacCommand();
    if (cmd instanceof RateInfoCmd) {
        // this is all we need.
        clientReady();
    }
}
Also used : RateInfoCmd(net.kano.joscar.snaccmd.conn.RateInfoCmd) SnacCommand(net.kano.joscar.flapcmd.SnacCommand)

Aggregations

SnacCommand (net.kano.joscar.flapcmd.SnacCommand)7 ByteBlock (net.kano.joscar.ByteBlock)3 ServerReadyCmd (net.kano.joscar.snaccmd.conn.ServerReadyCmd)3 List (java.util.List)2 ClientVersionsCmd (net.kano.joscar.snaccmd.conn.ClientVersionsCmd)2 RateInfoCmd (net.kano.joscar.snaccmd.conn.RateInfoCmd)2 RateInfoRequest (net.kano.joscar.snaccmd.conn.RateInfoRequest)2 SnacFamilyInfo (net.kano.joscar.snaccmd.conn.SnacFamilyInfo)2 SnacError (net.kano.joscar.snaccmd.error.SnacError)2 AuthReplyCmd (net.kano.joscar.snaccmd.ssi.AuthReplyCmd)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MessageDigest (java.security.MessageDigest)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 SnacRequestAdapter (net.kano.joscar.snac.SnacRequestAdapter)1 SnacRequestTimeoutEvent (net.kano.joscar.snac.SnacRequestTimeoutEvent)1 SnacResponseEvent (net.kano.joscar.snac.SnacResponseEvent)1 ExtraInfoBlock (net.kano.joscar.snaccmd.ExtraInfoBlock)1 ExtraInfoData (net.kano.joscar.snaccmd.ExtraInfoData)1