Package org.xulfactory.gliese

Examples of org.xulfactory.gliese.SSHException


    ByteArrayInputStream in = new ByteArrayInputStream(key);
    try {
      String format = Utils.decodeString(in);
      if (!format.equals(NAME)) {
        GlieseLogger.LOGGER.error("Invalid host key algorithm: " + format);
        throw new SSHException("Invalid host key algorithm: " + format);
      }
      e = Utils.decodeBigInt(in);
      n = Utils.decodeBigInt(in);
    } catch (IOException ioe) {
      GlieseLogger.LOGGER.error("Host key invalid encoding", ioe);
      throw new SSHException("Host key invalid encoding", ioe);
    }
  }
View Full Code Here


      Signature sig = Signature.getInstance("SHA1withRSA");
      sig.initVerify(k);
      return sig;
    } catch (NoSuchAlgorithmException nsae) {
      GlieseLogger.LOGGER.error("Signature verifier creation failed", nsae);
      throw new SSHException("Signature verifier creation failed", nsae);
    } catch (InvalidKeySpecException ikse) {
      GlieseLogger.LOGGER.error("Signature verifier creation failed", ikse);
      throw new SSHException("Signature verifier creation failed", ikse);
    } catch (InvalidKeyException ike) {
      GlieseLogger.LOGGER.error("Signature verifier creation failed", ike);
      throw new SSHException("Signature verifier creation failed", ike);
    }
  }
View Full Code Here

    ByteArrayInputStream in = new ByteArrayInputStream(key);
    try {
      String format = Utils.decodeString(in);
      if (!format.equals(NAME)) {
        GlieseLogger.LOGGER.error("Invalid host key algorithm: " + format);
        throw new SSHException("Invalid host key algorithm: " + format);
      }
      p = Utils.decodeBigInt(in);
      q = Utils.decodeBigInt(in);
      g = Utils.decodeBigInt(in);
      y = Utils.decodeBigInt(in);
    } catch (IOException ioe) {
      GlieseLogger.LOGGER.error("Host key invalid encoding", ioe);
      throw new SSHException("Host key invalid encoding", ioe);
    }
  }
View Full Code Here

      Signature sig = Signature.getInstance("SHA1withDSA");
      sig.initVerify(k);
      return sig;
    } catch (NoSuchAlgorithmException nsae) {
      GlieseLogger.LOGGER.error("Signature verifier creation failed", nsae);
      throw new SSHException("Signature verifier creation failed", nsae);
    } catch (InvalidKeySpecException ikse) {
      GlieseLogger.LOGGER.error("Signature verifier creation failed", ikse);
      throw new SSHException("Signature verifier creation failed", ikse);
    } catch (InvalidKeyException ike) {
      GlieseLogger.LOGGER.error("Signature verifier creation failed", ike);
      throw new SSHException("Signature verifier creation failed", ike);
    }
  }
View Full Code Here

    BigInteger f = reply.getF();
    k = f.modPow(x, p);

    byte[] ks = reply.getKS();
    if (!hv.isTrusted(transport, reply.getKeyFormat(), ks)) {
      throw new SSHException("Server host key not trusted");
    }
    SSHPublicKey pubkey = pkf.decode(ks);
    Signature verifier = pubkey.getVerifier();

    dg.reset();
    dg.update(Utils.encodeBytes(transport.getVC()));
    dg.update(Utils.encodeBytes(transport.getVS()));
    dg.update(Utils.encodeBytes(transport.getIC()));
    dg.update(Utils.encodeBytes(transport.getIS()));
    dg.update(Utils.encodeBytes(reply.getKS()));
    dg.update(Utils.encodeBigInt(e));
    dg.update(Utils.encodeBigInt(f));
    dg.update(Utils.encodeBigInt(k));
    h = dg.digest();
    try {
      verifier.update(h);
      if(!verifier.verify(reply.getSigBlob())) {
        GlieseLogger.LOGGER.warn("Server authentication failed.");
        throw new SSHException("Server authentication failed.");
      }
    } catch (SignatureException se) {
      // FIXME
    }
    dg.reset();
View Full Code Here

      klass = map.get(id);
    }
    if (klass == null && namespace != null) {
      return getMessageClass(id, null);
    } else if (klass == null) {
      throw new SSHException(String.format("Unsupported message type: %d", id));
    }
    return klass;
  }
View Full Code Here

      int padlen = Utils.decodeByte(in) & 0xff;
      int msgType = Utils.decodeByte(in);
      Class<? extends SSHMessage> klass
        = getMessageClass(msgType, namespace);
      if (klass == null) {
        throw new SSHException("Unsupported message type: " + msgType);
      }
      SSHMessage msg;
      try {
        msg = klass.newInstance();
        PayloadInputStream pin = new PayloadInputStream(in, plen - padlen - 2);
        msg.decode(pin);
        pin.flush();
      } catch (IllegalAccessException iae) {
        throw new SSHException("Unable to create message", iae);
      } catch (InstantiationException ie) {
        throw new SSHException("Unable to create message", ie);
      }
      Utils.decodeBytes(in, padlen);
      if (!in.checkMac()) {
        GlieseLogger.LOGGER.error("Invalid MAC on message: " + msg);
        try {
          writeMessage(new DisconnectMessage(
            DisconnectMessage.MAC_ERROR,
            "Bad MAC on input", ""));
        } catch (SSHException se) {
          // ignore exception
        }
        throw new SSHException("Bad MAC on input");
      }
      in.notifyAll();
      return msg;
    }
  }
View Full Code Here

  {
    try {
      writePacket(msg);
      GlieseLogger.LOGGER.debug("Sent message: " + msg);
    } catch (IOException ioe) {
      throw new SSHException("I/O exception on write", ioe);
    }
  }
View Full Code Here

    try {
      SSHMessage m = readPacket(namespace);
      GlieseLogger.LOGGER.debug("Received message: " + m);
      return m;
    } catch (IOException ioe) {
      throw new SSHException("I/O error on read", ioe);
    }
  }
View Full Code Here

TOP

Related Classes of org.xulfactory.gliese.SSHException

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.