Package org.zeromq
Class ZCertStore
- java.lang.Object
-
- org.zeromq.ZCertStore
-
public class ZCertStore extends java.lang.Object
To authenticate new clients using the ZeroMQ CURVE security mechanism, we have to check that the client's public key matches a key we know and accept. There are numerous ways to store accepted client public keys. The mechanism CZMQ implements is "certificates" (plain text files) held in a "certificate store" (a disk directory). This class works with such certificate stores, and lets you easily load them from disk, and check if a given client public key is known or not. TheZCert
class does the work of managing a single certificate.Those files need to be in ZMP-Format which is created by
ZConfig
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ZCertStore.Fingerprinter
static class
ZCertStore.Hasher
private static interface
ZCertStore.IFileVisitor
static class
ZCertStore.Timestamper
-
Field Summary
Fields Modifier and Type Field Description private ZCertStore.Fingerprinter
finger
private java.util.Map<java.io.File,byte[]>
fingerprints
private java.io.File
location
private java.util.Map<java.lang.String,ZMetadata>
publicKeys
-
Constructor Summary
Constructors Constructor Description ZCertStore(java.lang.String location)
Create a Certificate Store at that file system folder locationZCertStore(java.lang.String location, ZCertStore.Fingerprinter fingerprinter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) boolean
checkForChanges()
Check if files in the certificate folders have been added or removed.boolean
containsPublicKey(byte[] publicKey)
Check if a public key is in the certificate store.boolean
containsPublicKey(java.lang.String publicKey)
check if a z85-based public key is in the certificate store.(package private) int
getCertificatesCount()
ZMetadata
getMetadata(java.lang.String publicKey)
private void
loadFiles()
private boolean
modified(byte[] fingerprint, java.io.File path)
(package private) boolean
reloadIfNecessary()
private boolean
traverseDirectory(java.io.File root, ZCertStore.IFileVisitor visitor)
-
-
-
Field Detail
-
location
private final java.io.File location
-
fingerprints
private final java.util.Map<java.io.File,byte[]> fingerprints
-
publicKeys
private final java.util.Map<java.lang.String,ZMetadata> publicKeys
-
finger
private final ZCertStore.Fingerprinter finger
-
-
Constructor Detail
-
ZCertStore
public ZCertStore(java.lang.String location)
Create a Certificate Store at that file system folder location- Parameters:
location
-
-
ZCertStore
public ZCertStore(java.lang.String location, ZCertStore.Fingerprinter fingerprinter)
-
-
Method Detail
-
traverseDirectory
private boolean traverseDirectory(java.io.File root, ZCertStore.IFileVisitor visitor)
-
containsPublicKey
public boolean containsPublicKey(byte[] publicKey)
Check if a public key is in the certificate store.- Parameters:
publicKey
- needs to be a 32 byte array representing the public key
-
containsPublicKey
public boolean containsPublicKey(java.lang.String publicKey)
check if a z85-based public key is in the certificate store. This method will scan the folder for changes on every call- Parameters:
publicKey
-
-
getMetadata
public ZMetadata getMetadata(java.lang.String publicKey)
-
loadFiles
private void loadFiles()
-
getCertificatesCount
int getCertificatesCount()
-
reloadIfNecessary
boolean reloadIfNecessary()
-
checkForChanges
boolean checkForChanges()
Check if files in the certificate folders have been added or removed.
-
modified
private boolean modified(byte[] fingerprint, java.io.File path)
-
-