public static String toPemRepresentation( Object object ) throws IOException
    {
        final StringWriter result = new StringWriter();
        try ( final PemWriter pemWriter = new PemWriter(result) )
        {
            final PemObjectGenerator objGen = new JcaMiscPEMGenerator ( object );
            pemWriter.writeObject( objGen );
        }
        return result.toString();
    }
Generates a PEM representation of the input argument.

@param object the input argument (cannot be null).
@return PEM representation of the input argument.
@throws IOException When a PEM representation of the input could not be created.
xmppserver/src/main/java/org/jivesoftware/util/CertificateManager.java