public DefaultEntry(String type, String description, String value) { this.type = type; this.description = description; this.value = new SecureString(value); }
private String strValueOf(SecureString def) { if (def == null) return null; return def.value(); }
@Override protected SecureString loadValue(String value) { return new SecureString(value); }
public static String value(SecureString string, KeyPair key) { if (string == null) return null; if (!(string instanceof CryptedString)) return string.value(); return ((CryptedString)string).value(key); }
public CfgSecure(Object owner, String path, String def) { this(owner,path,def == null ? null : new SecureString(def)); }
public String valueAsString() { SecureString v = value(); return v == null ? null : v.value(); }
public CAddress(String currency, String addr, String privKey) { this.address = addr; this.privKey = new SecureString(privKey); this.currency = currency.trim().toUpperCase(); }
public static String encode(METHOD method, SecureString in, String secret) { return encode(method, in.value(), secret); }
public CAddress(CCurrency currency, String addr, String privKey) { this.address = addr; this.privKey = new SecureString(privKey); this.currency = currency.toString(); }
default PemBlock sign(PemPriv key, String text, SecureString passphrase) throws MException { return sign(key, text, passphrase == null ? null : passphrase.value()); }
public FolderVaultSource(File folder, String passphrase) throws IOException { this.passphrase = new SecureString(passphrase); this.folder = folder; if (folder.exists()) doLoad(); else folder.mkdirs(); }
public static String encode(METHOD method, String in, SecureString secret) { return encode(method, in, secret.value()); }
public FileVaultSource(File file, String passphrase) throws IOException { this.passphrase = new SecureString(passphrase); this.file = file; if (file.exists()) doLoad(); }
default String decrypt(PemPriv key, PemBlock encoded, SecureString passphrase) throws MException { return decrypt(key, encoded, passphrase == null ? null : passphrase.value()); };
public FileEntry(int version, ObjectInputStream ois) throws IOException { if (version == 0) { id = UUID.fromString(ois.readUTF()); type = ois.readUTF(); description = ois.readUTF(); value = new SecureString(ois.readUTF()); } else if (version > 0) { int v = ois.readInt(); if (v == 1) { id = UUID.fromString(ois.readUTF()); type = ois.readUTF(); description = ois.readUTF(); try { value = (SecureString)ois.readObject(); } catch (ClassNotFoundException e) { throw new IOException(e); } } } }
protected void saveEntry(VaultEntry entry) throws IOException { File file = new File(folder,entry.getId().toString()); FileOutputStream parent = new FileOutputStream(file); OutputStream os = MCrypt.createCipherOutputStream(parent, passphrase.value()); ObjectOutputStream oos = new ObjectOutputStream(os); oos.writeInt(version); oos.writeUTF(entry.getId().toString()); oos.writeUTF(entry.getType()); oos.writeUTF(entry.getDescription()); oos.writeObject(entry.getValue()); oos.flush(); parent.close(); }
public static SecureString create(String pubKey, String secret) { if (MString.isSet(pubKey)) return new CryptedString(pubKey, secret); return new SecureString(secret); }
@Override public void doSave() throws IOException { FileOutputStream parent = new FileOutputStream(file); OutputStream os = MCrypt.createCipherOutputStream(parent, passphrase.value()); ObjectOutputStream oos = new ObjectOutputStream(os); oos.writeInt(1); // version oos.writeUTF(name); oos.writeInt(entries.size()); for (VaultEntry entry : entries.values()) { oos.writeUTF(entry.getId().toString()); oos.writeUTF(entry.getType()); oos.writeUTF(entry.getDescription()); oos.writeObject(entry.getValue()); } oos.flush(); parent.close(); }
default String importSecret(String groupName, String secret) throws MException { return importSecret(groupName, null, null, new SecretContent(new SecureString(secret), new MProperties()), new MProperties()); }