code: public void encode(OutputStream out, boolean isExplicit)
      throws CRLException {
          try {
              DerOutputStream extOut = new DerOutputStream();
              Collection<Extension> allExts = map.values();
              Object[] objs = allExts.toArray();
  
              for (int i = 0; i < objs.length; i++) {
                  if (objs[i] instanceof CertAttrSet)
                      ((CertAttrSet)objs[i]).encode(extOut);
                  else if (objs[i] instanceof Extension)
                      ((Extension)objs[i]).encode(extOut);
                  else
                      throw new CRLException("Illegal extension object");
              }
  
              DerOutputStream seq = new DerOutputStream();
              seq.write(DerValue.tag_Sequence, extOut);
  
              DerOutputStream tmp = new DerOutputStream();
              if (isExplicit)
                  tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT,
                                               true, (byte)0), seq);
              else
                  tmp = seq;
  
              out.write(tmp.toByteArray());
          } catch (IOException e) {
              throw new CRLException("Encoding error: " + e.toString());
          } catch (CertificateException e) {
              throw new CRLException("Encoding error: " + e.toString());
          }
      }
docs: Encode the extensions in DER form to the stream.
  
  @param out the DerOutputStream to marshal the contents to.
  @param isExplicit the tag indicating whether this is an entry
  extension (false) or a CRL extension (true).
  @exception CRLException on encoding errors.