uk.org.ogsadai.common.rolemap
Class DecryptRoleMapperFile

java.lang.Object
  |
  +--uk.org.ogsadai.common.rolemap.DecryptRoleMapperFile

public class DecryptRoleMapperFile
extends java.lang.Object

Stand-alone utility for converting an XML file with attributes of form encryptedPassword="SOME PASSWORD" so that the values within the quotes are decrypted using a user-supplied encryption password and the encryptedPassword attribute has been renamed to password. This assumes that the XML file was created using uk.org.ogsadai.common.rolemap.EncryptRoleMapperFile.

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
           
private  java.lang.String mFilename
           
private  java.lang.String mPassword
           
 
Constructor Summary
DecryptRoleMapperFile(java.lang.String password, java.lang.String filename)
          Initialise the class with the encryption key and file name.
 
Method Summary
 java.lang.String decrypt()
          Change all instances of an encryptedPpassword attribute in the file's contents into a password attribute, containing the decrypted version of the original value, and return a string with all the changes in place.
static void main(java.lang.String[] args)
          Perform the decryption 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
 

Field Detail

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
Constructor Detail

DecryptRoleMapperFile

public DecryptRoleMapperFile(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.
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Perform the decryption of the passwords in the file.

Parameters:
args - An array containin the encryption key password and the path to the file to decrypt.
Throws:
java.lang.Exception - if there's a problem decrypting 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.

decrypt

public java.lang.String decrypt()
                         throws java.lang.Exception
Change all instances of an encryptedPpassword attribute in the file's contents into a password attribute, containing the decrypted 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.