Package com.volantis.vdp.scs.protocol

Examples of com.volantis.vdp.scs.protocol.SCPPacket


                                    currentSizeOfPacket,
                                    (totalSizeOfPacket -
                                            currentSizeOfPacket))) > 0 ) {
                                currentSizeOfPacket += size;
                                if(currentSizeOfPacket == totalSizeOfPacket) {
                                    broker.work(new SCPPacket(buffer),
                                                   connection);
                                    break;
                                }
                            }
                        }
View Full Code Here


        try {
            url = new URL(request.getURL());
            if(isSPS(url)) {
                SPSBroker broker =
                    SPSConnectionPool.getConnectionByUrl(url).getBroker();
                SCPPacket packet = new SCPPacket(
                        SCPPacket.HTTP_REQUEST_RESPONSE,
                        reqId,
                        data.getBytes());
                broker.send(packet.getBytes());
                clientBroker.addConnToReqTmManager(reqId);

            } else {
                if(logger.isDebugEnabled()) {
                    logger.debug("HTTP proxing: " + url);
View Full Code Here

            URL url = new URL("https://" + request.getURL());
            if(isSPS(url)) {
                SPSBroker broker =
                    SPSConnectionPool.getConnectionByUrl(url).getBroker();
                RequestManager.getSession(reqId).setSPSBroker(broker);
                SCPPacket packet = new SCPPacket(
                        SCPPacket.HTTPS_REQUEST_RESPONSE,
                        reqId,
                        data.getBytes());
                broker.send(packet.getBytes());
                clientBroker.addConnToReqTmManager(reqId);
            } else {
                if(logger.isDebugEnabled()) {
                    logger.debug("HTTPS proxing: " + request.getURL());
                }
View Full Code Here

    * @param reqId idetifies a SCP packet sent to sps server
     */
    public static void sendHTTPSRequest( byte[] data, int reqId ) {

        SPSBroker spsBroker = RequestManager.getSPSBroker(reqId);
        SCPPacket packet = new SCPPacket(
                SCPPacket.HTTPS_REQUEST_RESPONSE,
                reqId,
                data);
        spsBroker.send(packet.getBytes());

    }
View Full Code Here

        while (running) {
            byte[] dataBlock;
            IConnector connector = null;
            try {
                is.read(requestHeader, 0, SCPPacket.SIZE_OF_HEADER);
                SCPPacket packet = new SCPPacket();
                packet.setHeaderByte(requestHeader);

                int size = packet.getSizeOfDatablock();
                if (size > 0) {
                    dataBlock = new byte[size];
                    for (int i = 1; i < size; i++) {
                        dataBlock[i] = is.readByte();
                    }
                } else {
                    dataBlock = new byte[0];
                }

                if (SCPPacket.KEEP_ALIVE
                        .equals(packet.getRequestTypeIdetifier())) {
                    KeepAliveMonitor.monit();
                } else {
                    if (SCPPacket.HTTP_REQUEST_RESPONSE
                            .equals(packet.getRequestTypeIdetifier())) {
                        KeepAliveMonitor.monit();
                        connector = new HTTPConnector(dataBlock,
                                config.getWebServerURL(),
                                packet.getRequestIdetifier());
                        Thread t = new Thread(connector);
                        t.start();
                    } else if (SCPPacket.HTTPS_REQUEST_RESPONSE
                            .equals(packet.getRequestTypeIdetifier())) {
                        KeepAliveMonitor.monit();

                        Iterator it = httpsRequestsList.iterator();

                        // Serch for conection with id equals requestID
                        while (it.hasNext()) {
                            WorkConnectionThreads workThread;
                            connector = null;
                            workThread = (WorkConnectionThreads) it.next();
                            if (workThread.getRequestIdentifier() ==
                                    packet.getRequestIdetifier()) {
                                connector = workThread.getConnector();
                                ((HTTPSConnector) connector)
                                        .setRequestData(dataBlock);
                                workThread.start();
                            }
                        }

                        // remove timeouted threads.
                        it = httpsRequestsList.iterator();
                        while (it.hasNext()) {
                            WorkConnectionThreads workThread =
                                    (WorkConnectionThreads) it.next();
                            if (workThread.isTimeOuted() ||
                                    !workThread.isConnected()) {
                                ((HTTPSConnector) workThread.getConnector())
                                        .close();
                                httpsRequestsList.remove(workThread);
                            }
                        }

                        // if not found then ceate new connection and run as
                        // thread
                        if (connector == null) {
                            try {
                                connector = new HTTPSConnector(dataBlock,
                                        config.getWebServerURL(),
                                        packet.getRequestIdetifier());
                                connector.setWriter(this.writer);
                                Thread t = new Thread(connector);
                                t.start();
                                httpsRequestsList
                                        .add(new WorkConnectionThreads(t,
View Full Code Here

     * @param requestId     - reuest identifier same as request identifier
     * @param requestTypeId - request type ID
     */
    synchronized public void write(byte[] dataBlock, int requestId,
                                   byte[] requestTypeId) {
        SCPPacket packet = new SCPPacket(new String(requestTypeId), requestId, dataBlock);
        try {
            os.write(packet.getBytes());
            os.flush();
        } catch (IOException ex) {
            LOGGER.error("Error writting to Secure Connection Server");
        }
    }
View Full Code Here

     *         if any other error, method
     *         return SecurePublisher.LOGIN_FAILED_NETWORK_ERROR
     */
    public int auth() {
        AUPacket authRequest = new AUPacket(this.userid, this.password);
        SCPPacket authResponse = new SCPPacket();

        try {
            oStream.write(authRequest.getBytes());
            boolean run = true;
            byte[] responseHeader;
            while(run) {
                int size = iStream.available();
                if( size > 0 ) {
                    responseHeader = new byte[size];
                    iStream.read(responseHeader);
                    authResponse = new SCPPacket(responseHeader);
                    run = false;
                }
            }

            System.out.println(authResponse.toString());
            if (SCPPacket.AUTHENTICATION
                    .equals(authResponse.getRequestTypeIdetifier())) {
                if (authResponse.getSizeOfDatablock() == 1) {
                 /*   String baseUrl = new String(responseContent, 1,
                            responseContent.length - 1);*/
                    // @todo can't set url, ISPSConfigure no setter getWebServerURL()
                    //System.out.println(new String(authResponse.getDatablock()));
                    return 0;
View Full Code Here

TOP

Related Classes of com.volantis.vdp.scs.protocol.SCPPacket

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.