Package com.maverick.util

Examples of com.maverick.util.ByteArrayWriter


                }

                log.debug("SSH signature is " + str);
            }

            ByteArrayWriter baw = new ByteArrayWriter();
            baw.writeString(getAlgorithmName());
            baw.writeBinaryString(decoded);

            return baw.toByteArray();
        } catch (Exception e) {
            throw new InvalidSignatureException(e);
        }
    }
View Full Code Here


        this.requestData = requestData;
    }

    public Request(String requestName, Object[] values) throws IOException {
        this.requestName = requestName;
        ByteArrayWriter writer = new ByteArrayWriter();
        for (int index = 0; index < values.length; index++) {
            Object value = values[index];
            if (value instanceof BigInteger) {
                writer.writeBigInteger((BigInteger) value);
            } else if (value instanceof Integer) {
                writer.writeInt(((Integer) value).intValue());
            } else if (value instanceof Long) {
                writer.writeUINT64(((Long) value).longValue());
            } else if (value instanceof Short) {
                writer.writeShort(((Short) value).shortValue());
            } else if (value instanceof Boolean) {
                writer.writeBoolean(((Boolean) value).booleanValue());
            } else if (value instanceof Date) {
                writer.writeUINT64(((Date) value).getTime());
            } else {
                writer.writeString(value.toString());
            }
        }
        requestData = writer.toByteArray();
    }
View Full Code Here

     * (non-Javadoc)
     *
     * @see com.maverick.multiplex.Channel#create()
     */
    public byte[] create() throws IOException {
        ByteArrayWriter baw = new ByteArrayWriter();
        baw.writeBoolean(initiator);
        baw.writeString(id);
        return baw.toByteArray();
    }
View Full Code Here

  public LocalForwardingChannel() {
    this(CHANNEL_TYPE);
  }
 
  public byte[] create() throws IOException {
    ByteArrayWriter msg = new ByteArrayWriter();
    msg.writeString(hostname);
    msg.writeInt(port);
   
    return msg.toByteArray();
  }
View Full Code Here

  /* (non-Javadoc)
   * @see com.maverick.multiplex.MultiplexChannel#create()
   */
  public byte[] create() throws IOException {

    ByteArrayWriter msg = new ByteArrayWriter();
    msg.writeString(hostname);
    msg.writeInt(port);
    return msg.toByteArray();
  }
View Full Code Here

      // Process destination host and port for replacement variables
      VariableReplacement r = new VariableReplacement();
      r.setLaunchSession(launchSession);
      String destHost = r.replace(tunnel.getDestination().getHost());
     
        ByteArrayWriter msg = new ByteArrayWriter();
        msg.writeString(launchSession == null ? "" : launchSession.getId());
        msg.writeInt(tunnel.getResourceId());
        msg.writeString(tunnel.getResourceName());
        msg.writeInt(tunnel.getType());
        msg.writeString(tunnel.getTransport());
        msg.writeString(tunnel.getSourceInterface());       
        msg.writeInt(tunnel.getSourcePort());
        msg.writeInt(tunnel.getDestination().getPort());
        msg.writeString(destHost);
        Request req = new Request(START_LOCAL_TUNNEL, msg.toByteArray());
        return req;

    }
View Full Code Here

        CoreException e = null;

        for (Tunnel tunnel : tunnels) {
            try {
                ByteArrayWriter msg = new ByteArrayWriter();
                msg.writeInt(tunnel.getResourceId());
                if (!agent.sendRequest(new Request(STOP_LOCAL_TUNNEL, msg.toByteArray()), false) && e == null) {
                    e = new TunnelException(TunnelException.AGENT_REFUSED_LOCAL_TUNNEL_STOP, (Throwable)null);
                }
            } catch (IOException ex) {
                throw new TunnelException(TunnelException.INTERNAL_ERROR, ex);
            }
View Full Code Here

   * @throws CoreException on any error
   */
  public int openURL(AgentTunnel agent, URL url, LaunchSession launchSession) throws CoreException {

    try {
      ByteArrayWriter msg = new ByteArrayWriter();
      msg.writeString(url.toExternalForm());
      msg.writeString(launchSession.getId());
      Request request = new Request("openURL", msg.toByteArray());
      if (agent.sendRequest(request, true)) {
        if(request.getRequestData()!=null) {
        ByteArrayReader rdr = new ByteArrayReader(request.getRequestData());
        return (int) rdr.readInt();
        }
View Full Code Here

    public RemoteTunnel getRemoteTunnel() {
        return remoteTunnel;
    }

    public byte[] create() throws IOException {
        ByteArrayWriter msg = new ByteArrayWriter();
        msg.writeString(launchSession == null ? "" : launchSession.getId());
        msg.writeInt(tunnel.getResourceId());
        msg.writeString(tunnel.getResourceName());
        msg.writeInt(tunnel.getType());
        msg.writeString(tunnel.getTransport());
        msg.writeString(tunnel.getSourceInterface());
        msg.writeInt(tunnel.getSourcePort());
        msg.writeInt(tunnel.getDestination().getPort());
        msg.writeString(tunnel.getDestination().getHost());
        msg.writeBoolean(false);
        return msg.toByteArray();
    }
View Full Code Here

      // Process destination host and port for replacement variables
      VariableReplacement r = new VariableReplacement();
      r.setLaunchSession(launchSession);
      String destHost = r.replace(tunnel.getDestination().getHost());
     
      ByteArrayWriter msg = new ByteArrayWriter();
     
      try {
       
        msg.writeInt(tunnel.getResourceId());
        msg.writeString(tunnel.getSourceInterface());
        msg.writeString(launchSession.getId());
        msg.writeString(tunnel.getSourceInterface());
        msg.writeInt(tunnel.getSourcePort());
        msg.writeString(destHost);
        msg.writeInt(tunnel.getDestination().getPort());
       
       
        Request request = new Request(TunnelingService.START_REMOTE_TUNNEL, msg.toByteArray());
        agent.sendRequest(request, false);
       
      } catch(IOException ex) {
        ex.printStackTrace();
      }
     
        running = true;
        if (log.isInfoEnabled())
            log.info("Starting remote listener on " + tunnel.getSourcePort());
        try {
            while (running) {
                try {
                    Socket s = listeningSocket.accept();
                    if (log.isInfoEnabled())
                        log.info("Received new connection on " + tunnel.getSourcePort() + " from " + s.getInetAddress());
                    RemoteForwardingChannel channel = new RemoteForwardingChannel(this, s, tunnel, launchSession);
                    try {
                        agent.openChannel(channel);
                    } catch (ChannelOpenException e) {
                        log.error("Error opening channel. Remote tunnel remaining open but closing connection.", e);
                        try {
                            s.close();
                        } catch (IOException ioe) {
                        }
                    }
                } catch (IOException e) {
                    if (running) {
                        log.error("IO error waiting for connection, stopping remote tunnel.", e);
                    }
                }
            }
        } finally {
         
        Request request = new Request(TunnelingService.STOP_REMOTE_TUNNEL, msg.toByteArray());
        try {
        agent.sendRequest(request, false);
      } catch (IOException e) {
      }
       
View Full Code Here

TOP

Related Classes of com.maverick.util.ByteArrayWriter

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.