Class IsodeBindProfiles
Applications should use
loadIsodeBindProfiles(String, PostUpgradeCallback)
to get a reference
to the Isode bindprofile file. The class can work with an existing
sodium bindprofile file if necessary, so that it is possible to cater
for situations where customers are not yet ready to move away from the
sodium bindprofile setup (e.g. if they're sharing the file with older
versions of Isode).
- Since:
- 14.6
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Allows a callback to be made following the upgrading of a bindprofiles file. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
This variable contains a String with information about any error that has occurred when attempting to derive platform-specific pathnames. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
If a bindprofilefile is "upgraded", then the old file is "archived".static BindProfileList
Get the Bind Profile List that has been loadedstatic String
Returns the file path and name of whatever file will currently exists which contains bind profiles.static String
Return the file path and name of the "current" isode-bindprofiles filestatic String[]
Returns an array of the filenames that have been used for bind profiles, with the "current" filename as the first element of the list, and successively older versions in subsequent positions.static BindProfileList
Open the Isode bind profiles file in read-only mode, without decrypting any passwords.static BindProfileList
loadIsodeBindProfiles
(String bindProfilePassphrase, IsodeBindProfiles.PostUpgradeCallback postUpgradeCallback) Open the Isode bind profiles file, upgrading from an old Sodium bindprofiles file if necessary.static void
This method is for testing only.static void
Discard any existing reference to the Isode Bind Profile List.
-
Field Details
-
localPathsErrors
This variable contains a String with information about any error that has occurred when attempting to derive platform-specific pathnames. If no errors have occurred it will be null.
-
-
Constructor Details
-
IsodeBindProfiles
public IsodeBindProfiles()
-
-
Method Details
-
loadIsodeBindProfiles
public static BindProfileList loadIsodeBindProfiles(String bindProfilePassphrase, IsodeBindProfiles.PostUpgradeCallback postUpgradeCallback) throws EncryptionException, SAXException, IOException Open the Isode bind profiles file, upgrading from an old Sodium bindprofiles file if necessary. Loading a bindProfileList is allowed only once (except in test mode) and any attempt to load it again will throw a RuntimeException unless it has been unloaded using the methodunloadIsodeBindProfiles()
.Therefore, loading of BindprofileList should be done only once and if it needs to be reloaded then it should be unloaded before by calling
unloadIsodeBindProfiles()
. If this function is called multiple times, it should be called as follows:if (
getBindProfileList()
== null) { loadIsodeBindProfiles(...); }The method does the following:
- if the BindProfileList has already been populated, throw a RuntimeException - done.
- if "current" version of profiles files exists, load it and return reference - done.
- check if any of the older versions of profile files exist. If not, create a new empty file of the "current" version, load it and return reference - done
- find the most recent "previous" version of a bind profile file, and create a new "current" file by upgrading that one, after which the old one is renamed
- if postUpgradeCallback is non-null, call it so user can be informed of what's happened
- return a reference to the upgraded file
- done
- Parameters:
bindProfilePassphrase
- the passphrase to be used to protect the file. This should be specified as null only if the existing file is not passphrase protected, and/or the new file to be created is not to be passphrase protected.postUpgradeCallback
- a PostUpgradeCallback object which can be told about an upgrade (if one happened). This may be null.- Returns:
- a reference to either sodium-bindprofiles or isode-bindprofiles, will never be null
- Throws:
EncryptionException
- if bindProfilePassphrase is the wrong passphrase.SAXException
- if an error occurs when attempting to parse the contents of a bind profile file. The exception text will contain the name of the file which caused the problem.IOException
- if an error occurred when attempting to create a new isode-bindprofiles file, or if it is not possible to locate the Isode directory. The exception text will contain the name of the file, and information about whether it was trying to create a new file or upgrade it from an old one. If it was an upgrade that failed, then the old sodium file will be left unchanged.- See Also:
-
loadIsodeBindProfiles
Open the Isode bind profiles file in read-only mode, without decrypting any passwords. No upgrade from "old" BindProfile file versions will be done. Loading a bindProfileList is allowed only once (except in test mode) and any attempt to load it again will throw a RuntimeException unless it has been unloaded using the methodunloadIsodeBindProfiles()
.Therefore , loading of BindprofileList should be done only once and if it needs to be reloaded then it should be unloaded before by calling
unloadIsodeBindProfiles()
. If this function is called multiple times, it should be called as follows:if (
getBindProfileList()
== null) { loadIsodeBindProfiles(...); }The method does the following:
- if the BindProfileList has already been populated, throw a RuntimeException - done.
- if "current" version of profiles files exists, load it and return reference - done.
- check if any of the older versions of profile files exist. If so, open the "most recent" one and return reference - done
- return null - done.
- Returns:
- a reference to the most recent profile file version, or null if none exists.
- Throws:
IOException
- if it is not possible to locate the Isode directory.SAXException
- if an error occurs when attempting to parse the contents of a bind profile file. The exception text will contain the name of the file which caused the problem.- See Also:
-
setTestingMode
public static void setTestingMode()This method is for testing only. It provides a way for the unit-tests to test the functionality of the class without requiring that "real" bind profile files exist. Calling this method sets the testingMode flag, which means that every filename that the class uses will have a suffix of "-test" added to it.E.g. instead of
/home/nh/.isode/isode-bindprofiles.xml
it will use/home/nh/.isode/isode-bindprofiles.xml-test
This method always throws a UnsupportedOperationException, which should be caught by test code, but should cause any other application to break.
-
getIsodeBindProfileFilename
Return the file path and name of the "current" isode-bindprofiles file- Returns:
- the filename for "current" (i.e. most recent version) of the isode-bindprofiles file
-
getProfileFilenames
Returns an array of the filenames that have been used for bind profiles, with the "current" filename as the first element of the list, and successively older versions in subsequent positions. The Strings in the array are correctly adjusted in the case of a "test" environmentThis method is intended to be used by unit testing code.
- Returns:
- an array of filenames
- Since:
- 15.0
-
getCurrentBindProfileFilename
Returns the file path and name of whatever file will currently exists which contains bind profiles.This provides a way to find out which file would be read if you use
loadIsodeBindProfiles(String, PostUpgradeCallback)
The value returned will be determined as follows:
- if the "current" file exists, return its name - done.
- if any of the "older" files exist, return the most recent one - done.
- return null
- Returns:
- the filename for the currently existing bindprofiles, or null if there isn't one
-
getArchivedBindProfileFilename
If a bindprofilefile is "upgraded", then the old file is "archived". This method returns the name of the archive file, in the event that an upgrade has occurred- Returns:
- the name of the archived file, or null if no upgrade has occurred.
- Since:
- 15.0
-
getBindProfileList
Get the Bind Profile List that has been loaded- Returns:
- bind profile list or null if there is none or the functions
loadIsodeBindProfiles(String, PostUpgradeCallback)
orloadIsodeBindProfiles()
have not been called to populate it or if there was an error while loading the BindProfileList - Since:
- 14.6
-
unloadIsodeBindProfiles
public static void unloadIsodeBindProfiles()Discard any existing reference to the Isode Bind Profile List. This method may be used if a caller has previously usedloadIsodeBindProfiles(String, PostUpgradeCallback)
orloadIsodeBindProfiles()
to load the bind profiles, but there is a risk that another application has accessed or updated the file in the meantime. Calling this method drops the reference to the file without making any changes to it, and allows the caller to re-load the file by callingloadIsodeBindProfiles()
orloadIsodeBindProfiles(String, PostUpgradeCallback)
again.- Since:
- 14.6
-