code: public void decode(InputStream in)
      throws InvalidKeyException
      {
          DerValue        val;
  
          try {
              val = new DerValue(in);
              if (val.tag != DerValue.tag_Sequence)
                  throw new InvalidKeyException("invalid key format");
  
              algid = AlgorithmId.parse(val.data.getDerValue());
              setKey(val.data.getUnalignedBitString());
              parseKeyBits();
              if (val.data.available() != 0)
                  throw new InvalidKeyException ("excess key data");
  
          } catch (IOException e) {
              // e.printStackTrace ();
              throw new InvalidKeyException("IOException: " +
                                            e.getMessage());
          }
      }
docs: Initialize an X509Key object from an input stream.  The data on that
  input stream must be encoded using DER, obeying the X.509
  <code>SubjectPublicKeyInfo</code> format.  That is, the data is a
  sequence consisting of an algorithm ID and a bit string which holds
  the key.  (That bit string is often used to encapsulate another DER
  encoded sequence.)
  
  <P>Subclasses should not normally redefine this method; they should
  instead provide a <code>parseKeyBits</code> method to parse any
  fields inside the <code>key</code> member.
  
  <P>The exception to this rule is that since private keys need not
  be encoded using the X.509 <code>SubjectPublicKeyInfo</code> format,
  private keys may override this method, <code>encode</code>, and
  of course <code>getFormat</code>.
  
  @param in an input stream with a DER-encoded X.509
  SubjectPublicKeyInfo value
  @exception InvalidKeyException on parsing errors.