aQute.lib.settings
Class Settings

java.lang.Object
  extended by aQute.lib.settings.Settings
All Implemented Interfaces:
Map<String,String>

public class Settings
extends Object
implements Map<String,String>

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
static class Settings.Data
           
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
Settings()
           
Settings(String where)
           
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set<Map.Entry<String,String>> entrySet()
           
 void generate()
           
 void generate(char[] password)
           
 String get(Object key)
           
 String getEmail()
           
 String getName()
           
 byte[] getPrivateKey()
          Return an encoded private RSA key.
 byte[] getPublicKey()
          Return an encoded public RSA key.
 boolean isDirty()
           
 boolean isEmpty()
           
 Set<String> keySet()
           
 boolean load()
           
 boolean load(char[] password)
           
 String put(String key, String value)
           
 void putAll(Map<? extends String,? extends String> v)
           
 String remove(Object key)
           
 void save()
           
 void save(char[] password)
           
 void setEmail(String email)
           
 void setKeyPair(byte[] id, byte[] secret)
           
 void setName(String v)
           
 byte[] sign(byte[] con)
          Sign a byte array
 int size()
           
 String toString()
           
 Collection<String> values()
           
 boolean verify(byte[] con)
          Verify a signed byte array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

Settings

public Settings()

Settings

public Settings(String where)
Method Detail

load

public boolean load()

load

public boolean load(char[] password)

save

public void save()

save

public void save(char[] password)

generate

public void generate()
              throws Exception
Throws:
Exception

generate

public void generate(char[] password)
              throws Exception
Throws:
Exception

getEmail

public String getEmail()

setEmail

public void setEmail(String email)

setKeyPair

public void setKeyPair(byte[] id,
                       byte[] secret)
                throws Exception
Throws:
Exception

setName

public void setName(String v)

getName

public String getName()

getPublicKey

public byte[] getPublicKey()
                    throws Exception
Return an encoded public RSA key. this key can be decoded with an X509EncodedKeySpec

Returns:
an encoded public key.
Throws:
Exception

getPrivateKey

public byte[] getPrivateKey()
                     throws Exception
Return an encoded private RSA key. this key can be decoded with an PKCS8EncodedKeySpec

Returns:
an encoded private key.
Throws:
Exception

sign

public byte[] sign(byte[] con)
            throws Exception
Sign a byte array

Throws:
Exception

verify

public boolean verify(byte[] con)
               throws Exception
Verify a signed byte array

Throws:
Exception

clear

public void clear()
Specified by:
clear in interface Map<String,String>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<String,String>

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<String,String>

entrySet

public Set<Map.Entry<String,String>> entrySet()
Specified by:
entrySet in interface Map<String,String>

get

public String get(Object key)
Specified by:
get in interface Map<String,String>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<String,String>

keySet

public Set<String> keySet()
Specified by:
keySet in interface Map<String,String>

put

public String put(String key,
                  String value)
Specified by:
put in interface Map<String,String>

putAll

public void putAll(Map<? extends String,? extends String> v)
Specified by:
putAll in interface Map<String,String>

remove

public String remove(Object key)
Specified by:
remove in interface Map<String,String>

size

public int size()
Specified by:
size in interface Map<String,String>

values

public Collection<String> values()
Specified by:
values in interface Map<String,String>

isDirty

public boolean isDirty()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014 aQute SARL. All rights reserved.