Examples of ByteArrayReader


Examples of com.maverick.util.ByteArrayReader

  boolean processLaunchRequest(Request request) throws IOException {

    if(request.getRequestData()==null)
      return true;
   
    ByteArrayReader msg = new ByteArrayReader(request.getRequestData());
   
    // If this was a server side the no further processing is required
    boolean serverSide = msg.readBoolean();
    if(serverSide) {
      // #ifdef DEBUG
      log.info("Server side launch. No further processing required.");
      // #endif
      return false;
    }

    // Get the application name
    String name = msg.readString();
    msg.readInt(); // shortcut id
    String launchId = msg.readString();
    String descriptor = msg.readString();
    Hashtable parameters = new Hashtable();
    parameters.put("launchId", launchId);
    parameters.put("ticket", launchId);

    Application app = launchApplication(name, descriptor, parameters);
View Full Code Here

Examples of com.maverick.util.ByteArrayReader

      return true;
    } else if (request.getRequestName().equals(MESSAGE_REQUEST)) {
      displayMessage(request);
      return true;
    } else if (request.getRequestName().equals(UPDATE_RESOURCES_REQUEST)) {
      final ByteArrayReader bar = new ByteArrayReader(request.getRequestData());
      Thread t = new Thread() {
        public void run() {
          try {
            updateResources((int)bar.readInt());
          }
          catch(IOException e) {       
          }
        }
      };
      t.start();
      return true;
    } else if (request.getRequestName().equals(OPEN_URL_REQUEST)
        && request.getRequestData() != null) {
      try {
        ByteArrayReader msg = new ByteArrayReader(request
            .getRequestData());
        openURL(msg.readString(), msg.readString(), request);
        return true;
      } catch (IOException e) {
        // #ifdef DEBUG
        log.error("Failed to process openURL request", e);
        // #endif
View Full Code Here

Examples of com.maverick.util.ByteArrayReader

  private void displayMessage(Request request) {

    try {
      if (request.getRequestData() != null) {
        ByteArrayReader msg = new ByteArrayReader(request
            .getRequestData());
        String title = msg.readString();
        msg.readInt(); // type
        String message = msg.readString();

        getGUI().popup(
            null,
            MessageFormat.format(Messages
                .getString("Agent.received"), new Object[] {
View Full Code Here

Examples of com.maverick.util.ByteArrayReader

          con.sendRequest(syncRequest, true);
          if (syncRequest.getRequestData() == null)
            throw new IOException(
                "Server failed to return version data");

          ByteArrayReader reader = new ByteArrayReader(syncRequest
              .getRequestData());
          serverVersion = reader.readString();

          /**
           * Initialize the managers. Tunnels are no longer recorded
           * here unless they are active. This simplifies the agent by
           * making it respond to start and stop requests from the new
View Full Code Here

Examples of com.maverick.util.ByteArrayReader

            Request agentRequest = ((ApplicationService) DefaultAgentManager.getInstance().getService(ApplicationService.class)).launchApplication(launchSession);
            AgentTunnel agent = DefaultAgentManager.getInstance().getAgentBySession(launchSession.getSession());
            if (!agent.sendRequest(agentRequest, true, 60000)) {
              throw new ExtensionException(ExtensionException.AGENT_REFUSED_LAUNCH);
            }
            ByteArrayReader baw = new ByteArrayReader(agentRequest.getRequestData());
            try {
              while(true) {
                String name = baw.readString();
                String hostname = baw.readString();
                long port = baw.readInt();
                if(tunnels.length() > 0) {
                  tunnels.append(",");
                }
                tunnels.append(name);
                tunnels.append(":");
View Full Code Here

Examples of com.maverick.util.ByteArrayReader

     *
     * @return
     */
    public boolean isPassphraseProtected(byte[] formattedKey) {
        try {
            ByteArrayReader bar = new ByteArrayReader(getKeyBlob(formattedKey));
            String type = bar.readString();

            if (type.equals("none")) {
                return false;
            }

View Full Code Here

Examples of com.maverick.util.ByteArrayReader

     */
    public byte[] decryptKeyblob(byte[] formattedKey, String passphrase)
        throws InvalidKeyException {
        try {
            byte[] keyblob = getKeyBlob(formattedKey);
            ByteArrayReader bar = new ByteArrayReader(keyblob);
            String type = bar.readString();

            if (type.equalsIgnoreCase("3des-cbc")) {
                // Decrypt the key
                byte[] keydata = makePassphraseKey(passphrase);
                byte[] iv = new byte[8];

                if (type.equals("3DES-CBC")) {
                    bar.read(iv);
                }

                keyblob = bar.readBinaryString();

                Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
                KeySpec keyspec = new DESedeKeySpec(keydata);
                Key key = SecretKeyFactory.getInstance("DESede").generateSecret(keyspec);
                cipher.init(Cipher.DECRYPT_MODE, key,
                    new IvParameterSpec(iv, 0, cipher.getBlockSize()));

                ByteArrayReader data = new ByteArrayReader(cipher.doFinal(
                            keyblob));

                if (data.readInt() == cookie) {
                    keyblob = data.readBinaryString();
                } else {
                    throw new InvalidKeyException(
                        "The host key is invalid, check the passphrase supplied");
                }
            } else {
View Full Code Here

Examples of com.maverick.util.ByteArrayReader

        try {
            //this.hostKey = hostKey;
            RSAPublicKeySpec rsaKey;

            // Extract the key information
            ByteArrayReader bar = new ByteArrayReader(encoded);
            String header = bar.readString();

            if (!header.equals(getAlgorithmName())) {
                throw new InvalidKeyException();
            }

            BigInteger e = bar.readBigInteger();
            BigInteger n = bar.readBigInteger();
            rsaKey = new RSAPublicKeySpec(n, e);

            try {
                KeyFactory kf = KeyFactory.getInstance("RSA");
                pubKey = (RSAPublicKey) kf.generatePublic(rsaKey);
View Full Code Here

Examples of com.maverick.util.ByteArrayReader

    public boolean verifySignature(byte[] signature, byte[] data)
        throws InvalidSignatureException {
        try {
            // Check for older versions of the transport protocol
            if (signature.length != 128) {
                ByteArrayReader bar = new ByteArrayReader(signature);
                byte[] sig = bar.readBinaryString();
                String header = new String(sig);

                if (!header.equals(getAlgorithmName())) {
                    throw new InvalidSignatureException();
                }

                signature = bar.readBinaryString();
            }

            Signature s = Signature.getInstance("SHA1withRSA");
            s.initVerify(pubKey);
            s.update(data);
View Full Code Here

Examples of com.maverick.util.ByteArrayReader

     * @throws InvalidKeyException
     */
    public SshRsaPrivateKey(byte[] encoded) throws InvalidKeyException {
        try {
            // Extract the key information
            ByteArrayReader bar = new ByteArrayReader(encoded);

            // Read the public key
            String header = bar.readString();

            if (!header.equals(getAlgorithmName())) {
                throw new InvalidKeyException();
            }

            BigInteger e = bar.readBigInteger();
            BigInteger n = bar.readBigInteger();

            // Read the private key
            BigInteger p = bar.readBigInteger();
            RSAPrivateKeySpec prvSpec = new RSAPrivateKeySpec(n, p);
            RSAPublicKeySpec pubSpec = new RSAPublicKeySpec(n, e);
            KeyFactory kf = KeyFactory.getInstance("RSA");
            prvKey = (RSAPrivateKey) kf.generatePrivate(prvSpec);
            pubKey = (RSAPublicKey) kf.generatePublic(pubSpec);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.