Package hamsam.protocol.aim.util

Examples of hamsam.protocol.aim.util.TLV


            case CONNECTING :

                if (cmd.getChannel() == FlapConstants.FLAP_CHANNEL_DISCONNECT) {

                    // get the server and cookie from the command tlv
                    TLV tlvServer = cmd.getTLV(TLVConstants.TLV_TYPE_SERVER);
                    TLV tlvCookie = cmd.getTLV(TLVConstants.TLV_TYPE_COOKIE);
                    TLV tlvError = cmd.getTLV(TLVConstants.TLV_TYPE_ERROR_CODE);

                    if ((tlvServer != null) && (tlvCookie != null)) {
                        // hack the port to 22 now that work firewall blocks real port
                        int port =  5190;// 22;

                        try {
                            String server = null;
                            String serverCookie = tlvServer.getStringValue();
                            int pos = serverCookie.indexOf(':');

                            if (pos != -1) {
                                server = serverCookie.substring(0, pos);
                                port = Integer.parseInt(serverCookie.substring(pos+1));
                            } else {
                                server = serverCookie;
                            }

                            reconnect(server, port);
                        } catch (IllegalStateException e) {
                            e.printStackTrace();
                        }

                        // Login to BOS Server with Cookie
                        state = BOS_CONNECTING;
                        sendToWriterThread(new BOSLoginCmd(tlvCookie.getValue()));
                    } else if (tlvError != null) {
                        log.severe("Authentication error - error code=0x" + ByteUtils.toHexString(tlvError.getValue()));
                    }
                }
                break;

            case BOS_CONNECTING :
View Full Code Here


     * Constructor
     * @param cookie authorization cookie from the server
     */
    public BOSLoginCmd(byte[] cookie) {
        flapHdr = new FlapHeader(FlapConstants.FLAP_CHANNEL_CONNECT, 2);
        addTLV( new TLV(TLVConstants.TLV_TYPE_COOKIE, cookie) )
    }
View Full Code Here

    private static final byte[]  MINOR_VER  = MAJOR_VER;

    public LoginCmd(String screenName, String password)  {
        flapHdr = new FlapHeader(FlapConstants.FLAP_CHANNEL_CONNECT, 1);
   
        addTLV( new TLV(TLVConstants.TLV_TYPE_SCREEN_NAME, screenName) )
        addTLV( new TLV(TLVConstants.TLV_TYPE_ROASTED_PASSWORD, ByteUtils.roast(password)) )
        addTLV( new TLV(TLVConstants.TLV_TYPE_CLIENT_ID_STRING, "HAMSAM Test Client"));
        addTLV( new TLV(TLVConstants.TLV_TYPE_CLIENT_ID, MAJOR_VER));
        addTLV( new TLV(TLVConstants.TLV_TYPE_CLIENT_MAJOR_VERSION, MAJOR_VER));
        addTLV( new TLV(TLVConstants.TLV_TYPE_CLIENT_MINOR_VERSION, MINOR_VER));
        addTLV( new TLV(TLVConstants.TLV_TYPE_CLIENT_LESSOR_VERSION, MINOR_VER));
        addTLV( new TLV(TLVConstants.TLV_TYPE_CLIENT_BUILD_NUMBER, MINOR_VER));
        addTLV( new TLV(TLVConstants.TLV_TYPE_DISTRIBUTION_NUMBER, ID_NUMBER));
        addTLV( new TLV(TLVConstants.TLV_TYPE_CLIENT_LANGUAGE, "en"));
        addTLV( new TLV(TLVConstants.TLV_TYPE_CLIENT_COUNTRY, "us"));
       
    }
View Full Code Here

    public String getMessageText() {
        String msg = null;
        if (tlvList != null && !tlvList.isEmpty()) {
            outer : for (Iterator iter = tlvList.iterator(); iter.hasNext();) {
                TLV tlv = (TLV)iter.next();
                if (tlv.getType() == TLV_MSG_DATA) {
                    byte[] innerTlvs = tlv.getValue();
                    List list = TLV.getTLVs(innerTlvs, 0);
                    if (list != null && !list.isEmpty()) {
                        for (Iterator iterator = list.iterator(); iterator.hasNext();) {
                            TLV element = (TLV)iterator.next();
                            if (element.getType() == TLV_MSG_TEXT) {
                                byte[] temp = element.getValue();
                                byte[] text = new byte[temp.length-4];
                                System.arraycopy(temp, 4, text, 0, temp.length - 4);
                                msg = new String(text);
                                break outer;
                            }
View Full Code Here

     * Get the TLV for the type requested from the Command
     * @param tlvid TLV type id
     * @return TLV object or null if matching TLV type not found
     */
    public TLV getTLV(int tlvid) {
        TLV tlv = null;
        if (tlvList != null && !tlvList.isEmpty() ) {
            for (Iterator iter = tlvList.iterator(); iter.hasNext();) {
                TLV element = (TLV)iter.next();
                if (tlvid == element.getType()) {
                    tlv = element;
                    break;
                }
            }   
        }
View Full Code Here

        flapHdr = new FlapHeader(FlapConstants.FLAP_CHANNEL_SNAC, seqNum);
        snacPacket = new SNACPacket(SNACConstants.SNAC_FAMILY_GENERIC_SERVICE_CONTROLS, SNACConstants.CLIENT_STATUS);

        statusFlags |= statusflag;
        byte[] flags = ByteUtils.getUInt( modeFlags | statusFlags );
        addTLV( new TLV(TLVConstants.TLV_TYPE_USER_STATUS_FLAGS, flags ) );

        // allocate bytes for the DC Info block
        byte[] dcinfo = new byte[ 0x25 ];

        InetAddress addr;
        try {
            addr = InetAddress.getLocalHost();
            byte[] ipAddr = addr.getAddress();
            System.arraycopy(ipAddr, 0, dcinfo, 0, ipAddr.length);
        } catch (UnknownHostException e) {
            // TODO Auto-generated catch block
        }
       
       
        dcinfo[8] = 0x04; // dc_type_normal
        System.arraycopy(unknownFields, 0, dcinfo, 9, unknownFields.length);

        addTLV( new TLV(TLVConstants.TLV_TYPE_DC_INFO, dcinfo) );


    }
View Full Code Here

TOP

Related Classes of hamsam.protocol.aim.util.TLV

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.