Search in sources :

Example 1 with ByteBlock

use of net.kano.joscar.ByteBlock in project Openfire by igniterealtime.

the class BOSConnection method handleSnacResponse.

@Override
protected void handleSnacResponse(SnacResponseEvent e) {
    super.handleSnacResponse(e);
    //        Log.debug("OSCAR bos snac response received: "+e);
    SnacCommand cmd = e.getSnacCommand();
    if (cmd instanceof LocRightsCmd) {
        request(new SetInfoCmd(new InfoData("oscargateway", null, getMainSession().getCapabilities(), null)));
        request(new MyInfoRequest());
    } else if (cmd instanceof ParamInfoCmd) {
        ParamInfoCmd pic = (ParamInfoCmd) cmd;
        ParamInfo info = pic.getParamInfo();
        request(new SetParamInfoCmd(new ParamInfo(0, info.getFlags() | ParamInfo.FLAG_TYPING_NOTIFICATION, 8000, info.getMaxSenderWarning(), info.getMaxReceiverWarning(), 0)));
    } else if (cmd instanceof ServiceRedirect) {
        ServiceRedirect sr = (ServiceRedirect) cmd;
        getMainSession().connectToService(sr.getSnacFamily(), sr.getRedirectHost(), sr.getCookie());
    } else if (cmd instanceof SsiDataCmd) {
        SsiDataCmd sdc = (SsiDataCmd) cmd;
        List<SsiItem> items = sdc.getItems();
        for (SsiItem item : items) {
            SsiItemObj obj = itemFactory.getItemObj(item);
            if (obj instanceof BuddyItem) {
                BuddyItem bi = (BuddyItem) obj;
                Log.debug("OSCAR: got buddy item " + bi);
                getMainSession().getSsiHierarchy().gotBuddy(bi);
            } else if (obj instanceof GroupItem) {
                GroupItem gi = (GroupItem) obj;
                Log.debug("OSCAR: got group item " + gi);
                getMainSession().getSsiHierarchy().gotGroup(gi);
            } else if (obj instanceof IconItem) {
                IconItem ii = (IconItem) obj;
                Log.debug("OSCAR: got icon item " + ii);
                getMainSession().getSsiHierarchy().gotIconItem(ii);
            } else if (obj instanceof VisibilityItem) {
                VisibilityItem vi = (VisibilityItem) obj;
                Log.debug("OSCAR: got visibility item " + vi);
                getMainSession().getSsiHierarchy().gotVisibilityItem(vi);
            } else {
                Log.debug("OSCAR: got item we're not handling " + obj);
            }
        }
        if (sdc.getLastModDate() != 0) {
            request(new ActivateSsiCmd());
            clientReady();
            getMainSession().setLoginStatus(TransportLoginStatus.LOGGED_IN);
            getMainSession().gotCompleteSSI();
        }
    } else if (cmd instanceof OfflineMsgIcqCmd) {
        OfflineMsgIcqCmd omic = (OfflineMsgIcqCmd) cmd;
        String sn = String.valueOf(omic.getFromUIN());
        Date whenSent = omic.getDate();
        ByteBlock block = omic.getIcqData();
        final int len = LEBinaryTools.getUShort(block, 12) - 1;
        String msg = OscarTools.getString(block.subBlock(14, len), null);
        msg = StringUtils.unescapeFromXML(OscarTools.stripHtml(msg));
        // TODO: Translate offline message note
        getMainSession().getTransport().sendOfflineMessage(getMainSession().getJID(), getMainSession().getTransport().convertIDToJID(sn), msg, whenSent, "Offline Message");
    } else if (cmd instanceof OfflineMsgDoneCmd) {
        request(new OfflineMsgIcqAckCmd(getMainSession().getUIN(), (int) getMainSession().nextIcqId()));
    } else if (cmd instanceof MetaShortInfoCmd) {
    //            MetaShortInfoCmd msic = (MetaShortInfoCmd)cmd;
    //            Log.debug("RECEIVED META SHORT INFO: "+msic);
    //            getMainSession().updateRosterNickname(String.valueOf(msic.getUIN()), msic.getNickname());
    } else if (cmd instanceof AuthReplyCmd) {
        AuthReplyCmd ar = (AuthReplyCmd) cmd;
        if (ar.isAccepted()) {
            Presence p = new Presence();
            p.setType(Presence.Type.subscribed);
            p.setTo(getMainSession().getJID());
            p.setFrom(getMainSession().getTransport().convertIDToJID(ar.getSender()));
            getMainSession().getTransport().sendPacket(p);
        } else {
            Presence p = new Presence();
            p.setType(Presence.Type.unsubscribed);
            p.setTo(getMainSession().getJID());
            p.setFrom(getMainSession().getTransport().convertIDToJID(ar.getSender()));
            getMainSession().getTransport().sendPacket(p);
        }
    } else if (cmd instanceof AuthFutureCmd) {
        AuthFutureCmd af = (AuthFutureCmd) cmd;
        Presence p = new Presence();
        p.setType(Presence.Type.subscribe);
        p.setTo(getMainSession().getJID());
        p.setFrom(getMainSession().getTransport().convertIDToJID(af.getUin()));
        getMainSession().getTransport().sendPacket(p);
    } else if (cmd instanceof SnacError) {
        SnacError se = (SnacError) cmd;
        if (se.getErrorCode() == SnacError.CODE_REFUSED_BY_CLIENT) {
            getMainSession().getTransport().sendMessage(getMainSession().getJID(), getMainSession().getTransport().getJID(), LocaleUtils.getLocalizedString("gateway.aim.msgrefused", "kraken"));
        }
    //TODO: Tons more errors that can be caught.  Gotta catch 'em all!  =)  (please don't sue me Nintendo)
    }
}
Also used : MyInfoRequest(net.kano.joscar.snaccmd.conn.MyInfoRequest) OfflineMsgIcqCmd(net.kano.joscar.snaccmd.icq.OfflineMsgIcqCmd) MetaShortInfoCmd(net.kano.joscar.snaccmd.icq.MetaShortInfoCmd) SetInfoCmd(net.kano.joscar.snaccmd.loc.SetInfoCmd) SsiItem(net.kano.joscar.snaccmd.ssi.SsiItem) VisibilityItem(net.kano.joscar.ssiitem.VisibilityItem) IconItem(net.kano.joscar.ssiitem.IconItem) ByteBlock(net.kano.joscar.ByteBlock) Presence(org.xmpp.packet.Presence) List(java.util.List) GroupItem(net.kano.joscar.ssiitem.GroupItem) SetParamInfoCmd(net.kano.joscar.snaccmd.icbm.SetParamInfoCmd) ParamInfo(net.kano.joscar.snaccmd.icbm.ParamInfo) SsiDataCmd(net.kano.joscar.snaccmd.ssi.SsiDataCmd) OfflineMsgIcqAckCmd(net.kano.joscar.snaccmd.icq.OfflineMsgIcqAckCmd) LocRightsCmd(net.kano.joscar.snaccmd.loc.LocRightsCmd) ParamInfoCmd(net.kano.joscar.snaccmd.icbm.ParamInfoCmd) SetParamInfoCmd(net.kano.joscar.snaccmd.icbm.SetParamInfoCmd) OfflineMsgDoneCmd(net.kano.joscar.snaccmd.icq.OfflineMsgDoneCmd) AuthReplyCmd(net.kano.joscar.snaccmd.ssi.AuthReplyCmd) Date(java.util.Date) ActivateSsiCmd(net.kano.joscar.snaccmd.ssi.ActivateSsiCmd) BuddyItem(net.kano.joscar.ssiitem.BuddyItem) AuthFutureCmd(net.kano.joscar.snaccmd.ssi.AuthFutureCmd) SnacError(net.kano.joscar.snaccmd.error.SnacError) InfoData(net.kano.joscar.snaccmd.InfoData) SnacCommand(net.kano.joscar.flapcmd.SnacCommand) ServiceRedirect(net.kano.joscar.snaccmd.conn.ServiceRedirect) SsiItemObj(net.kano.joscar.ssiitem.SsiItemObj)

Example 2 with ByteBlock

use of net.kano.joscar.ByteBlock in project Openfire by igniterealtime.

the class BasicFlapConnection method handleSnacPacket.

@Override
protected void handleSnacPacket(SnacPacketEvent e) {
    Log.debug("OSCAR snac packet received: " + e);
    SnacCommand cmd = e.getSnacCommand();
    if (cmd instanceof ServerReadyCmd) {
        ServerReadyCmd src = (ServerReadyCmd) cmd;
        setSnacFamilies(src.getSnacFamilies());
        Collection<SnacFamilyInfo> familyInfos = SnacFamilyInfoFactory.getDefaultFamilyInfos(src.getSnacFamilies());
        setSnacFamilyInfos(familyInfos);
        getMainSession().registerSnacFamilies(this);
        request(new ClientVersionsCmd(familyInfos));
        request(new RateInfoRequest());
    } else if (cmd instanceof RecvImIcbm) {
        RecvImIcbm icbm = (RecvImIcbm) cmd;
        String sn = icbm.getSenderInfo().getScreenname();
        InstantMessage message = icbm.getMessage();
        String msg = StringUtils.convertFromHtml(message.getMessage());
        getMainSession().getTransport().sendMessage(getMainSession().getJID(), getMainSession().getTransport().convertIDToJID(sn), msg);
    } else if (cmd instanceof OldIcbm) {
        OldIcbm oicbm = (OldIcbm) cmd;
        if (oicbm.getMessageType() == OldIcbm.MTYPE_PLAIN) {
            String uin = String.valueOf(oicbm.getSender());
            String msg = StringUtils.convertFromHtml(oicbm.getReason());
            Log.debug("Got ICBM message " + uin + " with " + msg + "\n" + oicbm);
            //                InstantMessage message = oicbm.getMessage();
            //                Log.debug("Got ICBM message "+uin+" with "+message+"\n"+oicbm);
            //                String msg = StringUtils.unescapeFromXML(OscarTools.stripHtml(message.getMessage()));
            getMainSession().getTransport().sendMessage(getMainSession().getJID(), getMainSession().getTransport().convertIDToJID(uin), msg);
        }
    } else if (cmd instanceof WarningNotification) {
        WarningNotification wn = (WarningNotification) cmd;
        MiniUserInfo warner = wn.getWarner();
        if (warner == null) {
            getMainSession().getTransport().sendMessage(getMainSession().getJID(), getMainSession().getTransport().getJID(), LocaleUtils.getLocalizedString("gateway.aim.warninganon", "kraken", Arrays.asList(wn.getNewLevel().toString())), Message.Type.headline);
        } else {
            Log.debug("*** " + warner.getScreenname() + " warned you up to " + wn.getNewLevel() + "%");
            getMainSession().getTransport().sendMessage(getMainSession().getJID(), getMainSession().getTransport().getJID(), LocaleUtils.getLocalizedString("gateway.aim.warningdirect", "kraken", Arrays.asList(warner.getScreenname(), wn.getNewLevel().toString())), Message.Type.headline);
        }
    } else if (cmd instanceof ExtraInfoAck) {
        ExtraInfoAck eia = (ExtraInfoAck) cmd;
        List<ExtraInfoBlock> extraInfo = eia.getExtraInfos();
        if (extraInfo != null) {
            for (ExtraInfoBlock i : extraInfo) {
                ExtraInfoData data = i.getExtraData();
                final byte[] pendingAvatar = getMainSession().getSsiHierarchy().getPendingAvatarData();
                if (JiveGlobals.getBooleanProperty("plugin.gateway." + getMainSession().getTransport().getType() + ".avatars", true) && (data.getFlags() & ExtraInfoData.FLAG_UPLOAD_ICON) != 0 && pendingAvatar != null) {
                    Log.debug("OSCAR: Server has indicated that it wants our icon.");
                    request(new UploadIconCmd(ByteBlock.wrap(pendingAvatar)), new SnacRequestAdapter() {

                        @Override
                        public void handleResponse(SnacResponseEvent e) {
                            SnacCommand cmd = e.getSnacCommand();
                            if (cmd instanceof UploadIconAck && pendingAvatar != null) {
                                UploadIconAck iconAck = (UploadIconAck) cmd;
                                if (iconAck.getCode() == UploadIconAck.CODE_DEFAULT || iconAck.getCode() == UploadIconAck.CODE_SUCCESS) {
                                    ExtraInfoBlock iconInfo = iconAck.getIconInfo();
                                    if (iconInfo == null) {
                                        Log.debug("OSCAR: Got icon ack with no iconInfo: " + iconAck);
                                    }
                                    Log.debug("OSCAR: Successfully set icon.");
                                    try {
                                        MessageDigest md = MessageDigest.getInstance("MD5");
                                        md.update(pendingAvatar);
                                        getMainSession().getAvatar().setLegacyIdentifier(org.jivesoftware.util.StringUtils.encodeHex(md.digest()));
                                    } catch (NoSuchAlgorithmException ee) {
                                        Log.error("No algorithm found for MD5!", ee);
                                    }
                                } else if (iconAck.getCode() == UploadIconAck.CODE_BAD_FORMAT) {
                                    Log.debug("OSCAR: Uploaded icon was not in an unaccepted format.");
                                } else if (iconAck.getCode() == UploadIconAck.CODE_TOO_LARGE) {
                                    Log.debug("OSCAR: Uploaded icon was too large to be accepted.");
                                } else {
                                    Log.debug("OSCAR: Got unknown code from UploadIconAck: " + iconAck.getCode());
                                }
                            } else if (cmd instanceof SnacError) {
                                Log.debug("Got SnacError while setting icon: " + cmd);
                            }
                            // Clear the pending binary data from Krakens memory.
                            getMainSession().getSsiHierarchy().clearPendingAvatar();
                        }
                    });
                }
            }
        }
    } else if (cmd instanceof BuddyStatusCmd) {
        BuddyStatusCmd bsc = (BuddyStatusCmd) cmd;
        FullUserInfo info = bsc.getUserInfo();
        PresenceType pType = PresenceType.available;
        String vStatus = "";
        if (info.getAwayStatus()) {
            pType = PresenceType.away;
        }
        if ((info.getFlags() & FullUserInfo.MASK_WIRELESS) != 0) {
            pType = PresenceType.xa;
            vStatus = "Mobile: ";
        }
        if (getMainSession().getTransport().getType().equals(TransportType.icq) && info.getScreenname().matches("/^\\d+$/")) {
            pType = ((OSCARTransport) getMainSession().getTransport()).convertICQStatusToXMPP(info.getIcqStatus());
        }
        List<ExtraInfoBlock> extraInfo = info.getExtraInfoBlocks();
        if (extraInfo != null) {
            for (ExtraInfoBlock i : extraInfo) {
                ExtraInfoData data = i.getExtraData();
                if (i.getType() == ExtraInfoBlock.TYPE_AVAILMSG) {
                    ByteBlock msgBlock = data.getData();
                    int len = BinaryTools.getUShort(msgBlock, 0);
                    if (len >= 0) {
                        byte[] msgBytes = msgBlock.subBlock(2, len).toByteArray();
                        String msg;
                        try {
                            msg = new String(msgBytes, "UTF-8");
                        } catch (UnsupportedEncodingException e1) {
                            continue;
                        }
                        if (msg.length() > 0) {
                            vStatus = vStatus + msg;
                        }
                    }
                } else if (i.getType() == ExtraInfoBlock.TYPE_ICONHASH && JiveGlobals.getBooleanProperty("plugin.gateway." + getMainSession().getTransport().getType() + ".avatars", true)) {
                    try {
                        OSCARBuddy oscarBuddy = getMainSession().getBuddyManager().getBuddy(getMainSession().getTransport().convertIDToJID(info.getScreenname()));
                        Avatar curAvatar = oscarBuddy.getAvatar();
                        if (curAvatar == null || !curAvatar.getLegacyIdentifier().equals(org.jivesoftware.util.StringUtils.encodeHex(i.getExtraData().getData().toByteArray()))) {
                            IconRequest req = new IconRequest(info.getScreenname(), i.getExtraData());
                            request(req, new SnacRequestAdapter() {

                                @Override
                                public void handleResponse(SnacResponseEvent e) {
                                    SnacCommand cmd = e.getSnacCommand();
                                    if (cmd instanceof IconDataCmd) {
                                        IconDataCmd idc = (IconDataCmd) cmd;
                                        if (idc.getIconData().getLength() > 0 && idc.getIconData().getLength() != 90) {
                                            Log.debug("Got icon data: " + idc);
                                            if (getMainSession().getBuddyManager().isActivated()) {
                                                try {
                                                    OSCARBuddy oscarBuddy = getMainSession().getBuddyManager().getBuddy(getMainSession().getTransport().convertIDToJID(idc.getScreenname()));
                                                    oscarBuddy.setAvatar(new Avatar(getMainSession().getTransport().convertIDToJID(idc.getScreenname()), org.jivesoftware.util.StringUtils.encodeHex(idc.getIconInfo().getExtraData().getData().toByteArray()), idc.getIconData().toByteArray()));
                                                } catch (NotFoundException ee) {
                                                // Apparently we don't care about this contact.
                                                } catch (IllegalArgumentException ee) {
                                                    Log.debug("OSCAR: Got null avatar, ignoring.");
                                                }
                                            }
                                        }
                                    }
                                }

                                @Override
                                public void handleTimeout(SnacRequestTimeoutEvent e) {
                                    Log.debug("Time out while waiting for icon data.");
                                }
                            });
                        }
                    } catch (NotFoundException ee) {
                    // Apparently we don't care about this contact.
                    }
                }
            }
        }
        if (getMainSession().getBuddyManager().isActivated()) {
            try {
                OSCARBuddy oscarBuddy = getMainSession().getBuddyManager().getBuddy(getMainSession().getTransport().convertIDToJID(info.getScreenname()));
                oscarBuddy.setPresenceAndStatus(pType, vStatus);
            } catch (NotFoundException ee) {
                // Apparently we don't care about this contact.
                Log.debug("OSCAR: Received presense notification for contact we don't care about: " + info.getScreenname());
            }
        } else {
            getMainSession().getBuddyManager().storePendingStatus(getMainSession().getTransport().convertIDToJID(info.getScreenname()), pType, vStatus);
        }
    } else if (cmd instanceof BuddyOfflineCmd) {
        BuddyOfflineCmd boc = (BuddyOfflineCmd) cmd;
        if (getMainSession().getBuddyManager().isActivated()) {
            try {
                OSCARBuddy oscarBuddy = getMainSession().getBuddyManager().getBuddy(getMainSession().getTransport().convertIDToJID(boc.getScreenname()));
                oscarBuddy.setPresence(PresenceType.unavailable);
            } catch (NotFoundException ee) {
            // Apparently we don't care about this contact.
            }
        } else {
            getMainSession().getBuddyManager().storePendingStatus(getMainSession().getTransport().convertIDToJID(boc.getScreenname()), PresenceType.unavailable, null);
        }
    } else if (cmd instanceof TypingCmd) {
        TypingCmd tc = (TypingCmd) cmd;
        String sn = tc.getScreenname();
        final ChatStateEventSource chatStateEventSource = getMainSession().getTransport().getChatStateEventSource();
        final JID receiver = getMainSession().getJID();
        final JID sender = getMainSession().getTransport().convertIDToJID(sn);
        if (tc.getTypingState() == TypingCmd.STATE_TYPING) {
            chatStateEventSource.isComposing(sender, receiver);
        } else if (tc.getTypingState() == TypingCmd.STATE_PAUSED) {
            chatStateEventSource.sendIsPaused(sender, receiver);
        } else if (tc.getTypingState() == TypingCmd.STATE_NO_TEXT) {
            chatStateEventSource.isInactive(sender, receiver);
        }
    }
}
Also used : SnacRequestAdapter(net.kano.joscar.snac.SnacRequestAdapter) PresenceType(net.sf.kraken.type.PresenceType) NotFoundException(org.jivesoftware.util.NotFoundException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) FullUserInfo(net.kano.joscar.snaccmd.FullUserInfo) WarningNotification(net.kano.joscar.snaccmd.conn.WarningNotification) ExtraInfoData(net.kano.joscar.snaccmd.ExtraInfoData) SnacRequestTimeoutEvent(net.kano.joscar.snac.SnacRequestTimeoutEvent) ServerReadyCmd(net.kano.joscar.snaccmd.conn.ServerReadyCmd) ChatStateEventSource(net.sf.kraken.util.chatstate.ChatStateEventSource) ByteBlock(net.kano.joscar.ByteBlock) BuddyOfflineCmd(net.kano.joscar.snaccmd.buddy.BuddyOfflineCmd) List(java.util.List) RateInfoRequest(net.kano.joscar.snaccmd.conn.RateInfoRequest) MessageDigest(java.security.MessageDigest) IconDataCmd(net.kano.joscar.snaccmd.icon.IconDataCmd) RecvImIcbm(net.kano.joscar.snaccmd.icbm.RecvImIcbm) IconRequest(net.kano.joscar.snaccmd.icon.IconRequest) TypingCmd(net.kano.joscar.snaccmd.icbm.TypingCmd) JID(org.xmpp.packet.JID) ClientVersionsCmd(net.kano.joscar.snaccmd.conn.ClientVersionsCmd) InstantMessage(net.kano.joscar.snaccmd.icbm.InstantMessage) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Avatar(net.sf.kraken.avatars.Avatar) BuddyStatusCmd(net.kano.joscar.snaccmd.buddy.BuddyStatusCmd) SnacFamilyInfo(net.kano.joscar.snaccmd.conn.SnacFamilyInfo) ExtraInfoBlock(net.kano.joscar.snaccmd.ExtraInfoBlock) SnacError(net.kano.joscar.snaccmd.error.SnacError) UploadIconCmd(net.kano.joscar.snaccmd.icon.UploadIconCmd) OldIcbm(net.kano.joscar.snaccmd.icbm.OldIcbm) SnacResponseEvent(net.kano.joscar.snac.SnacResponseEvent) UploadIconAck(net.kano.joscar.snaccmd.icon.UploadIconAck) SnacCommand(net.kano.joscar.flapcmd.SnacCommand) MiniUserInfo(net.kano.joscar.snaccmd.MiniUserInfo) ExtraInfoAck(net.kano.joscar.snaccmd.conn.ExtraInfoAck)

Example 3 with ByteBlock

use of net.kano.joscar.ByteBlock 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)3 SnacCommand (net.kano.joscar.flapcmd.SnacCommand)3 List (java.util.List)2 SnacError (net.kano.joscar.snaccmd.error.SnacError)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MessageDigest (java.security.MessageDigest)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)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 FullUserInfo (net.kano.joscar.snaccmd.FullUserInfo)1 InfoData (net.kano.joscar.snaccmd.InfoData)1 MiniUserInfo (net.kano.joscar.snaccmd.MiniUserInfo)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