/** * Fetches the trusted keys for the current instance. * We could sort it but don't bother. * * @return A <code>String</code> containing the trusted keys, * delimited by CR LF line breaks. */ public String getTrustedKeysString() { StringBuilder buf = new StringBuilder(1024); for (SigningPublicKey spk : _trustedKeys.keySet()) { // If something already buffered, first add line break. if (buf.length() > 0) buf.append("\r\n"); buf.append(spk.toBase64()); } return buf.toString(); }
/** * @since 0.9.8 */ @Override public String toString() { StringBuilder buf = new StringBuilder(64); buf.append("[SigningPublicKey ").append((_type != null) ? _type.toString() : "unknown type").append(' '); int length = length(); if (_data == null) { buf.append("null"); } else if (length <= 32) { buf.append(toBase64()); } else { buf.append("size: ").append(length); } buf.append(']'); return buf.toString(); }
/** * Set the offline signing data. * Does NOT validate the signature. * Must be called AFTER setOptions(). Will throw ISE otherwise. * Side effect - modifies options. * * @throws IllegalStateException * @since 0.9.38 */ public void setOfflineSignature(long expires, SigningPublicKey transientSPK, Signature offlineSig) { if (_options == null) throw new IllegalStateException(); _options.setProperty(PROP_OFFLINE_EXPIRATION, Long.toString(expires / 1000)); _options.setProperty(PROP_TRANSIENT_KEY, transientSPK.getType().getCode() + ":" + transientSPK.toBase64()); _options.setProperty(PROP_OFFLINE_SIGNATURE, offlineSig.toBase64()); }
System.out.println("\r\nPublic key: " + signingPublicKey.toBase64() + "\r\n"); } catch (IOException e) { System.err.println("Error writing keys:");
long begin = System.currentTimeMillis(); System.out.println("Starting hashcash generation now..."); String resource = this.dest.getPublicKey().toBase64() + this.dest.getSigningPublicKey().toBase64(); HashCash hc; try {
Map<String, String> rv = new HashMap<String, String>(3); rv.put(OPT_NAME, family); rv.put(OPT_KEY, _pubkey.getType().getCode() + ":" + _pubkey.toBase64()); rv.put(OPT_SIG, sig.toBase64()); return rv;
return false; hcs = hcs.substring(0, end1) + _publicKey.toBase64() + _signingKey.toBase64() + hcs.substring(start2); HashCash hc; try {
@Test public void testBase64Constructor() throws Exception{ SigningPublicKey publicKey = new SigningPublicKey(); byte data[] = new byte[SigningPublicKey.KEYSIZE_BYTES]; for (int i = 0; i < data.length; i++) data[i] = (byte)(i%56); publicKey.setData(data); SigningPublicKey key2 = new SigningPublicKey(publicKey.toBase64()); assertEquals(publicKey, key2); }