Exemplo n.º 1
0
 private void dumpFailedLaunchInfo(Process process) {
   try {
     dumpStream(process.getErrorStream());
     dumpStream(process.getInputStream());
   } catch (IOException e) {
     MessageOutput.println("Unable to display process output:", e.getMessage());
   }
 }
Exemplo n.º 2
0
 /**
  * Create a new X509CertificatePair from its encoding.
  *
  * <p>For internal use only, external code should use generateCertificatePair.
  */
 private X509CertificatePair(byte[] encoded) throws CertificateException {
   try {
     parse(new DerValue(encoded));
     this.encoded = encoded;
   } catch (IOException ex) {
     throw new CertificateException(ex.toString());
   }
   checkPair();
 }
Exemplo n.º 3
0
 /**
  * Return the DER encoded form of the certificate pair.
  *
  * @return The encoded form of the certificate pair.
  * @throws CerticateEncodingException If an encoding exception occurs.
  */
 public byte[] getEncoded() throws CertificateEncodingException {
   try {
     if (encoded == null) {
       DerOutputStream tmp = new DerOutputStream();
       emit(tmp);
       encoded = tmp.toByteArray();
     }
   } catch (IOException ex) {
     throw new CertificateEncodingException(ex.toString());
   }
   return encoded;
 }
Exemplo n.º 4
0
 /* attach to running target vm */
 private VirtualMachine attachTarget() {
   AttachingConnector attacher = (AttachingConnector) connector;
   try {
     return attacher.attach(connectorArgs);
   } catch (IOException ioe) {
     ioe.printStackTrace();
     MessageOutput.fatalError("Unable to attach to target VM.");
   } catch (IllegalConnectorArgumentsException icae) {
     icae.printStackTrace();
     MessageOutput.fatalError("Internal debugger error.");
   }
   return null; // Shuts up the compiler
 }
Exemplo n.º 5
0
 /* listen for connection from target vm */
 private VirtualMachine listenTarget() {
   ListeningConnector listener = (ListeningConnector) connector;
   try {
     String retAddress = listener.startListening(connectorArgs);
     MessageOutput.println("Listening at address:", retAddress);
     vm = listener.accept(connectorArgs);
     listener.stopListening(connectorArgs);
     return vm;
   } catch (IOException ioe) {
     ioe.printStackTrace();
     MessageOutput.fatalError("Unable to attach to target VM.");
   } catch (IllegalConnectorArgumentsException icae) {
     icae.printStackTrace();
     MessageOutput.fatalError("Internal debugger error.");
   }
   return null; // Shuts up the compiler
 }
Exemplo n.º 6
0
 private void dumpStream(InputStream stream) throws IOException {
   BufferedReader in = new BufferedReader(new InputStreamReader(stream));
   int i;
   try {
     while ((i = in.read()) != -1) {
       MessageOutput.printDirect((char) i); // Special case: use
       //   printDirect()
     }
   } catch (IOException ex) {
     String s = ex.getMessage();
     if (!s.startsWith("Bad file number")) {
       throw ex;
     }
     // else we got a Bad file number IOException which just means
     // that the debuggee has gone away.  We'll just treat it the
     // same as if we got an EOF.
   }
 }
Exemplo n.º 7
0
 /* launch child target vm */
 private VirtualMachine launchTarget() {
   LaunchingConnector launcher = (LaunchingConnector) connector;
   try {
     VirtualMachine vm = launcher.launch(connectorArgs);
     process = vm.process();
     displayRemoteOutput(process.getErrorStream());
     displayRemoteOutput(process.getInputStream());
     return vm;
   } catch (IOException ioe) {
     ioe.printStackTrace();
     MessageOutput.fatalError("Unable to launch target VM.");
   } catch (IllegalConnectorArgumentsException icae) {
     icae.printStackTrace();
     MessageOutput.fatalError("Internal debugger error.");
   } catch (VMStartException vmse) {
     MessageOutput.println("vmstartexception", vmse.getMessage());
     MessageOutput.println();
     dumpFailedLaunchInfo(vmse.process());
     MessageOutput.fatalError("Target VM failed to initialize.");
   }
   return null; // Shuts up the compiler
 }
Exemplo n.º 8
0
  /**
   * Constructs a MessageToken from an InputStream. Bytes will be read on demand and the thread
   * might block if there are not enough bytes to complete the token. Please note there is no
   * accurate way to find out the size of a token, but we try our best to make sure there is enough
   * bytes to construct one.
   *
   * @param tokenId the token id that should be contained in this token as it is read.
   * @param context the Kerberos context associated with this token
   * @param is the InputStream from which to read
   * @param prop the MessageProp structure in which the properties of the token should be stored.
   * @throws GSSException if there is a problem reading from the InputStream or parsing the token
   */
  MessageToken_v2(int tokenId, Krb5Context context, InputStream is, MessageProp prop)
      throws GSSException {
    init(tokenId, context);

    try {
      if (!confState) {
        prop.setPrivacy(false);
      }
      tokenHeader = new MessageTokenHeader(is, prop, tokenId);

      // set key_usage
      if (tokenId == Krb5Token.WRAP_ID_v2) {
        key_usage = (!initiator ? KG_USAGE_INITIATOR_SEAL : KG_USAGE_ACCEPTOR_SEAL);
      } else if (tokenId == Krb5Token.MIC_ID_v2) {
        key_usage = (!initiator ? KG_USAGE_INITIATOR_SIGN : KG_USAGE_ACCEPTOR_SIGN);
      }

      int minSize = 0; // minimal size for token data
      if (tokenId == Krb5Token.WRAP_ID_v2 && prop.getPrivacy()) {
        minSize = CONFOUNDER_SIZE + TOKEN_HEADER_SIZE + cipherHelper.getChecksumLength();
      } else {
        minSize = cipherHelper.getChecksumLength();
      }

      // Read token data
      if (tokenId == Krb5Token.MIC_ID_v2) {
        // The only case we can precisely predict the token data length
        tokenDataLen = minSize;
        tokenData = new byte[minSize];
        readFully(is, tokenData);
      } else {
        tokenDataLen = is.available();
        if (tokenDataLen >= minSize) { // read in one shot
          tokenData = new byte[tokenDataLen];
          readFully(is, tokenData);
        } else {
          byte[] tmp = new byte[minSize];
          readFully(is, tmp);
          // Hope while blocked in the read above, more data would
          // come and is.available() below contains the whole token.
          int more = is.available();
          tokenDataLen = minSize + more;
          tokenData = Arrays.copyOf(tmp, tokenDataLen);
          readFully(is, tokenData, minSize, more);
        }
      }

      if (tokenId == Krb5Token.WRAP_ID_v2) {
        rotate();
      }

      if (tokenId == Krb5Token.MIC_ID_v2
          || (tokenId == Krb5Token.WRAP_ID_v2 && !prop.getPrivacy())) {
        // Read checksum
        int chkLen = cipherHelper.getChecksumLength();
        checksum = new byte[chkLen];
        System.arraycopy(tokenData, tokenDataLen - chkLen, checksum, 0, chkLen);

        // validate EC for Wrap tokens without confidentiality
        if (tokenId == Krb5Token.WRAP_ID_v2 && !prop.getPrivacy()) {
          if (chkLen != ec) {
            throw new GSSException(
                GSSException.DEFECTIVE_TOKEN, -1, getTokenName(tokenId) + ":" + "EC incorrect!");
          }
        }
      }
    } catch (IOException e) {
      throw new GSSException(
          GSSException.DEFECTIVE_TOKEN, -1, getTokenName(tokenId) + ":" + e.getMessage());
    }
  }
Exemplo n.º 9
0
 /*
  * Override Throwable.initCause() to match getCause() by updating
  * _exception as well.
  */
 public Throwable initCause(Throwable cause) {
   super.initCause(cause);
   _exception = cause;
   return this;
 }