Example #1
0
 /**
  * Convert to AuthData.xml format
  *
  * @return String - auth config data
  */
 protected String toConfigXML() {
   StringBuffer buf = new StringBuffer();
   buf.append("<Identity name=\"...\" domain=\"...\">\n");
   buf.append(prvKey.toConfigXML());
   buf.append("\n");
   buf.append(cert.toConfigXML());
   buf.append("\n<Certificate name=\"${signer}\" ... />\n");
   buf.append("<DHparam>\n<Alpha>");
   buf.append(ContentHandler.toBase64(dhParam.alpha));
   buf.append("</Alpha>\n<P>");
   buf.append(ContentHandler.toBase64(dhParam.p));
   buf.append("</P>\n</DHparam>\n</Identity>\n");
   return buf.toString();
 }
Example #2
0
  /**
   * Write AuthSet data to a Plan9/Inferno keyring file.
   *
   * @param auth AuthSet - authentication data
   * @return StringBuffer - content buffer
   */
  public static StringBuffer toKeyringFile(AuthSet auth) {
    StringBuffer buf = new StringBuffer();

    // Section 1: public key of signer
    buf.append(auth.cert.pubSigner.toContent());
    // Section 2: Signature
    buf.append(auth.cert.toContent());
    // Section 3: private key of certificate holder
    buf.append(auth.prvKey.toContent());
    // Section 4: Diffie-Hellman parameter "alpha"
    buf.append(
        ContentHandler.createSection(new String[] {ContentHandler.toBase64(auth.dhParam.alpha)}));
    // Section 5: Diffie-Hellman parameter "p"
    buf.append(
        ContentHandler.createSection(new String[] {ContentHandler.toBase64(auth.dhParam.p)}));
    return buf;
  }