Examples of ByteArrayReader


Examples of com.maverick.util.ByteArrayReader

  public boolean processRequest(Request request, MultiplexedConnection connection) {
    AgentTunnel agent = (AgentTunnel) connection;
    if (request.getRequestName().equals(SETUP_AND_LAUNCH_NETWORK_PLACE) && request.getRequestData()!=null) {
      try {
        ByteArrayReader reader = new ByteArrayReader(request.getRequestData());
        int id = (int)reader.readInt();
        NetworkPlace resource = (NetworkPlace)NetworkPlacePlugin.NETWORK_PLACE_RESOURCE_TYPE.getResourceById(id);
        if (resource == null) {
          throw new Exception("No resource with ID " + id);
        }
        Policy policy = LaunchSessionManager.getLaunchRequestPolicy(null, agent.getSession(), resource);
View Full Code Here

Examples of com.maverick.util.ByteArrayReader

     * @throws InvalidKeyException
     */
    public static SshPrivateKey decodePrivateKey(byte[] encoded)
        throws InvalidKeyException {
        try {
            ByteArrayReader bar = new ByteArrayReader(encoded);
            String algorithm = bar.readString();

            if (supportsKey(algorithm)) {
                SshKeyPair pair = newInstance(algorithm);

                return pair.decodePrivateKey(encoded);
View Full Code Here

Examples of com.maverick.util.ByteArrayReader

     * @throws InvalidKeyException
     */
    public static SshPublicKey decodePublicKey(byte[] encoded)
        throws InvalidKeyException {
        try {
            ByteArrayReader bar = new ByteArrayReader(encoded);
            String algorithm = bar.readString();

            if (supportsKey(algorithm)) {
                SshKeyPair pair = newInstance(algorithm);

                return pair.decodePublicKey(encoded);
View Full Code Here

Examples of com.maverick.util.ByteArrayReader

     *
     * @return String
     */
    public String getAlgorithm() {
      try {
      ByteArrayReader r = new ByteArrayReader(keyblob);
      return r.readString();
    } catch (IOException e) {
      return null;
    }
    }
View Full Code Here

Examples of com.maverick.util.ByteArrayReader

     * @return SshPublicKey
     *
     * @throws IOException
     */
    public SshPublicKey toPublicKey() throws IOException, InvalidKeyException {
        ByteArrayReader bar = new ByteArrayReader(keyblob);
        String type = bar.readString();
        SshKeyPair pair = SshKeyPairFactory.newInstance(type);

        return pair.decodePublicKey(keyblob);
    }
View Full Code Here

Examples of com.maverick.util.ByteArrayReader

     * @param raw
     * @return String
     */
    private String getAlgorithm(byte[] raw) {
        try {
      ByteArrayReader r = new ByteArrayReader(raw);
      return r.readString();
    } catch (IOException e) {
      return null;
    }
    }
View Full Code Here

Examples of com.maverick.util.ByteArrayReader

    public SshDssPublicKey(byte[] key) throws InvalidKeyException {
        try {
            DSAPublicKeySpec dsaKey;

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

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

            BigInteger p = bar.readBigInteger();
            BigInteger q = bar.readBigInteger();
            BigInteger g = bar.readBigInteger();
            BigInteger y = bar.readBigInteger();
            dsaKey = new DSAPublicKeySpec(y, p, q, g);

            KeyFactory kf = KeyFactory.getInstance("DSA");
           
            pubkey = (DSAPublicKey) kf.generatePublic(dsaKey);
View Full Code Here

Examples of com.maverick.util.ByteArrayReader

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

                //if (log.isDebugEnabled()) {log.debug("Signature blob is " + new String(sig));}
                String header = new String(sig);
                if (log.isDebugEnabled())
                  log.debug("Header is " + header);

                if (!header.equals("ssh-dss")) {
                    throw new InvalidSignatureException();
                }

                signature = bar.readBinaryString();

                //if (log.isDebugEnabled()) {log.debug("Read signature from blob: " + new String(signature));}
            }

            // Using a SimpleASNWriter
View Full Code Here

Examples of com.maverick.util.ByteArrayReader

    public SshDssPrivateKey(byte[] key) throws InvalidKeyException {
        try {
            DSAPrivateKeySpec dsaKey;

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

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

            BigInteger p = bar.readBigInteger();
            BigInteger q = bar.readBigInteger();
            BigInteger g = bar.readBigInteger();
            BigInteger x = bar.readBigInteger();
            dsaKey = new DSAPrivateKeySpec(x, p, q, g);

            KeyFactory kf = KeyFactory.getInstance("DSA");
            prvkey = (DSAPrivateKey) kf.generatePrivate(dsaKey);
        } catch (Exception e) {
View Full Code Here

Examples of com.maverick.util.ByteArrayReader

      }
      }
  }

  public byte[] open(byte[] data) throws IOException, ChannelOpenException {
    ByteArrayReader msg = new ByteArrayReader(data);
    this.hostname = msg.readString();
    this.port = (int) msg.readInt();
        this.socket = MultiplexedSocketFactory.getDefault().createSocket(hostname, port);
    return null;
  }
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.