java.lang.Object
net.i2p.data.PrivateKeyFile
net.i2p.data.router.RouterPrivateKeyFile
Handles router private key files, extending PrivateKeyFile to provide RouterIdentity access instead of Destination. Maintains the same file format as the parent class while adding router-specific functionality.
Field Summary
Fields inherited from class PrivateKeyFile
dest, file, privKey, signingPrivKeyModifier and TypeFieldDescriptionprotected DestinationThe destination.protected final FileThe key file.protected PrivateKeyThe private key.protected SigningPrivateKeyThe signing private key.Constructor Summary
ConstructorsConstructorDescriptionRouterPrivateKeyFile(File file) Constructor with the router private key file path.Method Summary
All MethodsMethods inherited from class PrivateKeyFile
checkSignature, createIfAbsent, createIfAbsent, getDestination, getOfflineExpiration, getOfflineSignature, getPrivKey, getSigningPrivKey, getTransientSigningPrivKey, getTransientSigningPubKey, isOffline, main, open, open, setCertType, setDestination, setKeyCert, setOfflineData, setSignedCert, toString, validateKeyPairs, verifySignature, writeModifier and TypeMethodDescriptionstatic booleancheckSignature(Signature s, byte[] data, SigningPublicKey spk) Check a signature against data with a public key.Create with the default signature type if nonexistent.createIfAbsent(SigType type) Create with the specified signature type if nonexistent.If the destination is not set, read it in from the file.longOffline key expiration time.Offline signature.Private key may be random data or all zeros for Destinations as of 0.9.57.Signing private key.Transient signing private key.Transient signing public key.booleanDoes this session have offline and transient keys?static voidCreate a new PrivateKeyFile, or modify an existing one, with various types of Certificates.open()Open an I2P session.open(Properties opts) Open a session with the given options.setCertType(int t) Change cert type - caller must also callPrivateKeyFile.write().voidDestination for this key file.setKeyCert(SigType type) Change cert type - caller must also call write().voidsetOfflineData(long expires, SigningPublicKey transientPub, Signature sig, SigningPrivateKey transientPriv) Side effect - zeroes out the current signing private key.setSignedCert(PrivateKeyFile pkf2) Sign this dest by dest found in pkf2 - caller must also call write().toString()booleanVerify that the PublicKey matches the PrivateKey, and the SigningPublicKey matches the SigningPrivateKey.static booleanVerify the signature on a destination.voidwrite()Write the keys to the file.
Constructor Details
RouterPrivateKeyFile
Constructor with the router private key file path.- Parameters:
file- the router private key file to read the identity from
Method Details
getRouterIdentity
Read it in from the file. Also sets the local privKey and signingPrivKey.- Returns:
- the router identity
- Throws:
IOException- if the file cannot be opened or its bytes cannot be readDataFormatException- if the identity or either key declares an unknown type, or a key cannot be decoded