uk.org.ogsadai.common.rolemap
Class EncryptRoleMapperFile
java.lang.Object
|
+--uk.org.ogsadai.common.rolemap.EncryptRoleMapperFile
- public class EncryptRoleMapperFile
- extends java.lang.Object
Stand-alone utility for converting an XML file with attributes of form password="SOME PASSWORD"
so that the values within the quotes are encrypted using a user-supplied encryption password and the password
attribute has been renamed to encryptedPassword
.
- Author:
- The OGSA-DAI Project Team
Constructor Summary |
EncryptRoleMapperFile(java.lang.String password, java.lang.String filename)
Initialise the class with the encryption key and file name. |
Method Summary |
java.lang.String |
encrypt()
Change all instances of a password attribute in the file's contents into an encryptedPassword attribute, containing the encrypted version of the original value, and return a string with all the changes in place. |
static void |
main(java.lang.String[] args)
Perform the encryption of the passwords in the file. |
void |
writeToFile(java.lang.String contents)
Delete the current file and replace it with a new one with the given contents. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
COPYRIGHT_NOTICE
private static final java.lang.String COPYRIGHT_NOTICE
-
- See Also:
- Constant Field Values
mFilename
private java.lang.String mFilename
-
mPassword
private java.lang.String mPassword
-
EncryptRoleMapperFile
public EncryptRoleMapperFile(java.lang.String password,
java.lang.String filename)
-
Initialise the class with the encryption key and file name.
- Parameters:
password
- The password to use as the encryption key.
filename
- The path to the file.
main
public static void main(java.lang.String[] args)
throws java.lang.Exception
-
Perform the encryption of the passwords in the file.
-
- Parameters:
args
- An array containin the encryption key password and the path to the file to encrypt.
- Throws:
java.lang.Exception
- if there's a problem encrypting the file
writeToFile
public void writeToFile(java.lang.String contents)
throws java.lang.Exception
-
Delete the current file and replace it with a new one with the given contents.
-
- Parameters:
contents
- The new file content.
- Throws:
java.lang.Exception
- if there's a problem overwriting the file.
encrypt
public java.lang.String encrypt()
throws java.lang.Exception
-
Change all instances of a
password
attribute in the file's contents into an encryptedPassword
attribute, containing the encrypted version of the original value, and return a string with all the changes in place.
-
- Returns:
- the file's contents with the changes made.
- Throws:
java.lang.Exception
- if there's a problem.