java.lang.Object
dev.netcode.security.identity.Identity
Identity instances are meant to contain data about a person, institution
or service which is signed by a trusted authority.
Identities can also be self-signed which does not provide any layer of trust
if not used by a trusted authority. This means trusted authorities must obviously
sign their identities by themselves.
An Identity can be used to encrypt, decrypt and sign data
The class is designed to be safely serializable so instances can easily be stored on disk.
The private parts should be password encrypted.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetHash()Hashes the information contained in the identity using SHA-256booleanbooleanChecks if theSignatureof the identity is valid using a given public key.static IdentityLoads an Identity from a filebooleanSaves the Identity to file at a given path.
Inexistent files will be created.LiketoString()but idents certain parts to make it better readabletoString()Generates a String representation of this identity containing the data that is secure to be sent.booleanUnlocks a loaded identity which makes it possible to use it
-
Constructor Details
-
Identity
Creates an identity from the given data- Parameters:
possessor- name of the person, institution or service that possesses the identitydata- key-value pairs of data containing information about the possessorpassword- which should be used to encrypt the private parts
-
-
Method Details
-
load
Loads an Identity from a file- Parameters:
path- of the identity file- Returns:
- identity instance
-
save
Saves the Identity to file at a given path.
Inexistent files will be created. Existent files will be overridden.- Parameters:
path- of the file to save the Identity to- Returns:
- true if the process was successful
-
unlock
Unlocks a loaded identity which makes it possible to use it- Parameters:
password- to unlock the identity with- Returns:
- true if the unlocking process was successful
-
isValid
Checks if theSignatureof the identity is valid using a given public key.- Parameters:
publicKey- to test the signature against- Returns:
- true if the signature is valid, false otherwise
-
isUnlocked
public boolean isUnlocked()- Returns:
- true if the identity is unlocked and usable
-
getHash
Hashes the information contained in the identity using SHA-256- Returns:
- the hashed information
-
toString
Generates a String representation of this identity containing the data that is secure to be sent. -
toIndentedString
LiketoString()but idents certain parts to make it better readable- Returns:
- idented String representation
-