The standard CCNx mechanisms try to generate a keystore for each user that uses them. More...
Public Member Functions | |
CreateUserData (ContentName userKeyStorePrefix, String[] userNames, int userCount, boolean storeInRepo, char[] password) throws ConfigurationException, IOException, InvalidKeyException | |
Read/write constructor to write keystores as CCN data. | |
CreateUserData (ContentName userKeyStorePrefix, int userCount, boolean storeInRepo, char[] password) throws ConfigurationException, IOException, InvalidKeyException | |
Backwards compatibility constructor. | |
CreateUserData (ContentName userKeystoreDataPrefix, char[] password, CCNHandle handle) throws IOException, ConfigurationException, InvalidKeyException | |
General read constructor. | |
CreateUserData (File userKeystoreDirectory, String[] userNames, int userCount, char[] password, boolean clearSavedState) throws ConfigurationException, IOException, InvalidKeyException | |
Read/write constructor to write keystores as files. | |
CreateUserData (File userKeystoreDirectory, String[] userNames, int userCount, char[] password) throws ConfigurationException, IOException, InvalidKeyException | |
void | closeAll () |
void | publishUserKeysToRepository () throws IOException |
PublicKeyObject[] | publishUserKeysToRepository (ContentName userNamespace) throws IOException, InvalidKeyException |
Publishes self-referential key objects under user namespace prefix. | |
PublicKeyObject[] | publishUserKeysToRepositorySetLocators (ContentName userNamespace) throws InvalidKeyException, IOException |
boolean | hasUser (String friendlyName) |
BasicKeyManager | getUser (String friendlyName) |
File | getUserDirectory (String friendlyName) |
CCNHandle | getHandleForUser (String friendlyName) throws IOException |
Set< String > | friendlyNames () |
int | count () |
Static Public Member Functions | |
static KeyManager | loadKeystoreFile (File userKeystoreFileOrDirectory, String friendlyName, char[] password) throws ConfigurationException, IOException, InvalidKeyException |
For writing apps that run "as" a particular user. | |
static CreateUserData | readUserDataDirectory (File userDirectory, char[] keystorePassword) throws ConfigurationException, IOException, InvalidKeyException |
Load a set of user data from an existing generated set of file directories. | |
static Tuple< Integer, CCNHandle > | handleAs (String[] args, int offset) throws ConfigurationException, IOException, InvalidKeyException |
Helper method for other programs that want to use TestUserData. | |
static Tuple< Integer, KeyManager > | keyManagerAs (String[] args, int offset) throws ConfigurationException, IOException, InvalidKeyException |
static KeyManager | keyManagerAs (String keystoreFileOrDirectoryPath, String friendlyName) throws InvalidKeyException, ConfigurationException, IOException |
static void | usage () |
static void | main (String[] args) |
Command-line driver to generate key data. | |
Static Public Attributes | |
static final String[] | USER_NAMES |
Our users are named, in order, from this list, with 1 attached the first time, and 2 the second, and so on. | |
Protected Attributes | |
HashMap< String, ContentName > | _userContentNames = new HashMap<String,ContentName>() |
HashMap< String, File > | _userKeystoreDirectories = new HashMap<String,File>() |
HashMap< String, BasicKeyManager > | _userKeyManagers = new HashMap<String, BasicKeyManager>() |
The standard CCNx mechanisms try to generate a keystore for each user that uses them.
This tool allows you to make keys for additional users, on the command line or programmatically. It is primarily useful for tests, and for generating credentials that will be prepared offline and then given to their intended users.
Creates and loads a set of simulated users. Will store them into a repository if asked, or to files and then will reload them from there the next time.
As long as you are careful to create your CCNHandle objects pointing at these users' keystores, you can create data as any of these users.
org.ccnx.ccn.utils.CreateUserData.CreateUserData | ( | ContentName | userKeyStorePrefix, | |
String[] | userNames, | |||
int | userCount, | |||
boolean | storeInRepo, | |||
char[] | password | |||
) | throws ConfigurationException, IOException, InvalidKeyException |
Read/write constructor to write keystores as CCN data.
Makes extra new users if necessary. Expects names to come as above. Will incur timeouts the first time, as it checks for data first, and will take time to generate keys. TODO eventually use this "for real" with real passwords.
userKeyStorePrefix | ||
userNames | list of user names to use, if null uses built-in list | |
userCount | ||
storeInRepo | ||
password |
IOException | ||
ConfigurationException | ||
InvalidKeyException |
org.ccnx.ccn.utils.CreateUserData.CreateUserData | ( | ContentName | userKeystoreDataPrefix, | |
char[] | password, | |||
CCNHandle | handle | |||
) | throws IOException, ConfigurationException, InvalidKeyException |
General read constructor.
Expects names to be available in repo, and so enumerable. i.e. something must be there. Uses NetworkKeyManager to read them out, though.
IOException | ||
ConfigurationException | ||
InvalidKeyException |
org.ccnx.ccn.utils.CreateUserData.CreateUserData | ( | File | userKeystoreDirectory, | |
String[] | userNames, | |||
int | userCount, | |||
char[] | password, | |||
boolean | clearSavedState | |||
) | throws ConfigurationException, IOException, InvalidKeyException |
Read/write constructor to write keystores as files.
Makes extra new users if necessary. Expects names to come as above. Will incur timeouts the first time, as it checks for data first, and will take time to generate keys. TODO eventually use this "for real" with real passwords.
userKeystoreDirectory | a directory under which to put each user's information; segregated into subdirectories by user name, e.g. <userKeystoreDirectory>/<userName>. | |
userNames | list of user names to use, if null uses built-in list | |
userCount | ||
storeInRepo | ||
password | ||
handle |
IOException | ||
ConfigurationException | ||
IOException | ||
ConfigurationException | ||
InvalidKeyException | ||
InvalidKeyException |
static Tuple<Integer, CCNHandle> org.ccnx.ccn.utils.CreateUserData.handleAs | ( | String[] | args, | |
int | offset | |||
) | throws ConfigurationException, IOException, InvalidKeyException [static] |
Helper method for other programs that want to use TestUserData.
Takes an args array, and an offset int it, at which it expects to find (optionally) [-as keystoreDirectoryorFilePath [-name friendlyName]]. If the latter refers to a file, it takes it as the keystore file. If it refers to a directory, it looks for the default keystore file name under that directory. If the friendly name argument is given, it uses that as the friendly name, otherwise it uses the last component of the keystoreDirectoryOrFilePath. It returns a Tuple of a handle opened under that user, and the count of arguments read, or null if the argument at offset was not -as.
static KeyManager org.ccnx.ccn.utils.CreateUserData.loadKeystoreFile | ( | File | userKeystoreFileOrDirectory, | |
String | friendlyName, | |||
char[] | password | |||
) | throws ConfigurationException, IOException, InvalidKeyException [static] |
For writing apps that run "as" a particular user.
userKeystoreDirectory | This is the path to this particular user's keystore directory, not the path above it where a bunch of users might have been generated. Assumes keystore file has default name in that directory. If you give it a path that doesn't exist, it takes it as a directory and makes a keystore there making the parent directories if necessary. |
IOException | ||
ConfigurationException | ||
InvalidKeyException |
PublicKeyObject [] org.ccnx.ccn.utils.CreateUserData.publishUserKeysToRepository | ( | ContentName | userNamespace | ) | throws IOException, InvalidKeyException |
Publishes self-referential key objects under user namespace prefix.
userNamespace |
IOException | ||
InvalidKeyException |
static CreateUserData org.ccnx.ccn.utils.CreateUserData.readUserDataDirectory | ( | File | userDirectory, | |
char[] | keystorePassword | |||
) | throws ConfigurationException, IOException, InvalidKeyException [static] |
Load a set of user data from an existing generated set of file directories.
Don't force user to know names or count, enumerate them.
IOException | ||
ConfigurationException | ||
InvalidKeyException |
final String [] org.ccnx.ccn.utils.CreateUserData.USER_NAMES [static] |
{"Alice", "Bob", "Carol", "Dave", "Oswald", "Binky", "Spot", "Fred", "Eve", "Harold", "Barack", "Newt", "Allison", "Zed", "Walter", "Gizmo", "Nick", "Michael", "Nathan", "Rebecca", "Diana", "Jim", "Van", "Teresa", "Russ", "Tim", "Sharon", "Jessica", "Elaine", "Mark", "Weasel", "Ralph", "Junior", "Beki", "Darth", "Cauliflower", "Pico", "Eric", "Eric", "Eric", "Erik", "Richard"}
Our users are named, in order, from this list, with 1 attached the first time, and 2 the second, and so on.
This allows them to be enumerated without requiring them to be stored in a repo.