ItemListener
, Serializable
, Cloneable
, Iterable<CertificatePair>
, Collection<CertificatePair>
, EventListener
, List<CertificatePair>
, RandomAccess
, ListModel
public class CertificateStoreWithDefault extends CertificateStore
CertificateStore
which has the notion of a default certificate.
The default ~/.globus
directory generally has key and certificate
files that are used Globus and related tools. They do not support multiple
certificates. To give a user a possibility to use multiple certificates
anyway, the CertificateStore
stores all certificates as
subdirectories. This class adds the notion that one of these can be
the default certificate, which means that they are copied/linked in
~/.globus
.
Only if the user only has one certificate, we rather don't bother creating
subdirectories, as it would only confuse the user when seeing non-standard
stuff in ~/.globus
.
This class handles this transparently for the developer, so that there is
just a CertificateStore
of which one can be the default.
~/.globus/userkey.pem
and ~/.globus/usercert.pem
. This is an entry in this store, and
is called the default certificate. This class was designed to
allow multiple certificates to be present, and to be able to select one
of them as the default, and switch between them easily.
A new item is added according to the following rules:
setDefault(nl.nikhef.jgridstart.CertificatePair)
for the behaviour
when the default certificate is changed, this is directly related to this.
This behaviour satisfies the following situations:
~/.globus
, or it is empty.modCount
listeners, source
defaultCert, logger, path, pwcache, userCertPrefix
Constructor | Description |
---|---|
CertificateStoreWithDefault() |
new empty certificate store
|
CertificateStoreWithDefault(File path) |
new certificate store and load from path as File
|
CertificateStoreWithDefault(String path) |
new certificate store and load from path
|
Modifier and Type | Method | Description |
---|---|---|
protected boolean |
compareDefaultCertificate(CertificatePair other) |
Return whether the supplied CertificatePair is equal to the default certificate.
|
protected CertificatePair |
findDefaultCertificate() |
Find the
CertificatePair that is equal to the default certificate, if any. |
CertificatePair |
getDefault() |
Return the default certificate.
|
String |
getPath() |
Return the default path.
|
void |
itemStateChanged(ItemEvent e) |
Catch it when a renewed certificate becomes available.
|
void |
load(File f) |
Load certificates from store path
|
protected File |
newItem() |
|
void |
setDefault(CertificatePair c) |
Make a
CertificatePair the default certificate. |
containsAll, toString
equals, hashCode
addAll, addAll, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, removeAll, removeIf, replaceAll, retainAll, size, sort, spliterator, subList, toArray, toArray, trimToSize
add, add, addListDataListener, clear, getElementAt, getSize, notifyChanged, remove, remove, removeListDataListener, removeRange, set
certificateInStore, delete, delete, deletePath, generateRenewal, generateRenewal, generateRenewal, generateRenewal, generateRequest, generateRequest, importFrom, importFrom, importFrom, importFrom, load, load, newItem, notifyAdded, notifyRemoved, refresh, sort, tryAdd
parallelStream, stream
containsAll, equals, hashCode
public CertificateStoreWithDefault()
public CertificateStoreWithDefault(String path)
public CertificateStoreWithDefault(File path)
public String getPath()
The default certificate is located in ~/.globus
(or the platform's equivalent).
null
if not presentpublic void load(File f)
All subdirectories of the supplied path that start with
CertificateStore.userCertPrefix
are loaded as separate certificates; in
addition to this, the directory itself is loaded as well.
Also, the default certificate is loaded from the store's path when it is not found in another entry in the store.
load
in class CertificateStore
f
- Directory to load certificates fromprotected File newItem() throws IOException
The very first entry in the store is the default certificate.
newItem
in class CertificateStore
IOException
public CertificatePair getDefault() throws IOException
The default certificate is the one in ~/.globus
(or the platform's equivalent).
This can be called pretty often, so the result is cached. Updates outside of this program will not be picked up as a result while running.
null
if not presentIOException
public void setDefault(CertificatePair c) throws IOException
CertificatePair
the default certificate.
This copies the files from a CertificatePair's subdirectory
to the store's path (~/.globus
by default, so that Globus tools
use that one).
If the default certificate (the one before it is updated) is not present in a subdirectory of this store, its files are moved to a subdirectory. This includes all ordinary files present in the store directory, but not subdirectories.
When the supplied CertificatePair is already the default, nothing happens.
See also section The default certificate.
IOException
protected CertificatePair findDefaultCertificate() throws IOException
CertificatePair
that is equal to the default certificate, if any.
The files present in the default certificate location must be present in the store location, and they must be equal. So the store location may contain more files than the default certificate location, but not less.
In addition to this, a valid key must be present in the certificate location that is checked.
null
if not foundIOException
protected boolean compareDefaultCertificate(CertificatePair other) throws IOException
IOException
findDefaultCertificate()
public void itemStateChanged(ItemEvent e)
If the parent is the current default, make the renewed certificate the default instead.
itemStateChanged
in interface ItemListener
itemStateChanged
in class CertificateStore
Copyright © 2010-2018 Nikhef / Stichting FOM. All Rights Reserved.