Package aQute.lib.settings
Class Settings
java.lang.Object
aQute.lib.settings.Settings
Maintains persistent settings for bnd (or other apps). The default is
~/.bnd/settings.json). The settings are normal string properties but it
specially maintains a public/private key pair and it provides a method to
sign a byte array with this pair.
Why not keystore and preferences? Well, keystore is hard to use (you can only
store a private key when you have a certificate, but you cannot create a
certificate without using com.sun classes) and preferences are not editable.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static JSONCodec
(package private) Settings.Data
private boolean
private boolean
private char[]
private PrivateKey
private PublicKey
private final File
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
check()
void
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
void
generate()
void
generate
(char[] password) getEmail()
getName()
byte[]
Return an encoded private RSA key.byte[]
Return an encoded public RSA key.private void
initKeys()
boolean
isDirty()
boolean
isEmpty()
keySet()
boolean
load()
boolean
load
(char[] password) void
void
save()
void
save
(char[] password) void
void
setKeyPair
(byte[] id, byte[] secret) void
byte[]
sign
(byte[] con) Sign a byte arrayint
size()
toString()
values()
boolean
verify
(byte[] con) Verify a signed byte arrayMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
codec
-
where
-
publicKey
-
privateKey
-
loaded
private boolean loaded -
dirty
private boolean dirty -
data
Settings.Data data -
password
private char[] password
-
-
Constructor Details
-
Settings
public Settings() -
Settings
-
-
Method Details
-
load
public boolean load() -
load
public boolean load(char[] password) -
check
private void check() -
save
public void save() -
save
public void save(char[] password) -
generate
- Throws:
Exception
-
generate
- Throws:
Exception
-
getEmail
-
setEmail
-
setKeyPair
- Throws:
Exception
-
setName
-
getName
-
getPublicKey
Return an encoded public RSA key. this key can be decoded with an X509EncodedKeySpec- Returns:
- an encoded public key.
- Throws:
Exception
-
getPrivateKey
Return an encoded private RSA key. this key can be decoded with an PKCS8EncodedKeySpec- Returns:
- an encoded private key.
- Throws:
Exception
-
initKeys
- Throws:
Exception
-
sign
Sign a byte array- Throws:
Exception
-
verify
Verify a signed byte array- Throws:
Exception
-
clear
public void clear() -
containsKey
- Specified by:
containsKey
in interfaceMap<String,
String>
-
containsValue
- Specified by:
containsValue
in interfaceMap<String,
String>
-
entrySet
-
get
-
isEmpty
public boolean isEmpty() -
keySet
-
put
-
putAll
-
remove
-
size
public int size() -
values
-
isDirty
public boolean isDirty() -
toString
-