Hello,
I would like to present a solution in order to encrypt/decrypt the passwords of registry for example the password in the dfc.properties via Java programming with the following Documentum utilities classes:
1 | com.documentum.fc.tools.RegistryPasswordUtils.encrypt( "password to be encrypted" ) ; |
2 | com.documentum.fc.tools.RegistryPasswordUtils.decrypt ( "password to be decrypted" ) ; |
Dfc.properties
1 | dfc.globalregistry.repository=globalr |
2 | dfc.globalregistry.username=dm_bof_registry |
3 | dfc.globalregistry. password =XXXXXfsfezrezxxxxxrezrzrXXX/0ezxxxxxxIGAL |
To encrypt/decrypt this value via JAVA programming:
- Java decrypting method:
02 | * Decrypting with BOF utils - shorter, base64 encoded passwords |
04 | * @param passwordEncrypted |
07 | public static String decryptWithBOFUtils(String passwordEncrypted) { |
10 | System.out.print( "\tBOF Utils (decrypt) -> " + passwordEncrypted + "\t\t\t\t" ); |
11 | ret = com.documentum.fc.tools.RegistryPasswordUtils.decrypt(passwordEncrypted); |
12 | } catch (Exception e) { |
13 | System.out.println( "ERROR: " + e.getMessage()); |
- Java encrypting method:
02 | * Encrypting with BOF utils - shorter, base64 encoded passwords |
04 | * @param passwordToEncrypt |
07 | public static String encryptWithBOFUtils(String passwordToEncrypt) { |
10 | System.out.print( "\tBOF Utils (encrypt) -> " + passwordToEncrypt+ "\t\t\t\t" ); |
11 | ret = com.documentum.fc.tools.RegistryPasswordUtils.encrypt(passwordToEncrypt); |
12 | } catch (Exception e) { |
13 | System.out.println( "ERROR: " + e.getMessage()); |
- Test decrypting and encrypting method:
02 | String password = null ; |
03 | String clearText = null ; |
05 | password = "XXXXXfsfezrezxxxxxrezrzrXXX/0ezxxxxxxIGAL" ; |
07 | System.out.println( "\nTrying to decrypt '" + password + "'...\n" ); |
08 | clearText = decryptWithBOFUtils(password); |
09 | if ((clearText != null ) && (clearText.length() > 0 )) { |
10 | System.out.println( "'" + clearText + "'" ); |
15 | clearText = "TEST-javablog-Documentum@123" ; |
18 | System.out.println( "\nTrying to encrypt '" + clearText + "'...\n" ); |
19 | password = encryptWithBOFUtils(clearText); |
20 | if ((password != null ) && (password.length() > 0 )) { |
21 | System.out.println( "'" + password + "'" ); |
27 | System.out.println( "\nTrying to decrypt again '" + password + "'...\n" ); |
28 | clearText = decryptWithBOFUtils(password); |
29 | if ((clearText != null ) && (clearText.length() > 0 )) { |
30 | System.out.println( "'" + clearText + "'" ); |
Here, a code found to decrypt BOF and database passwords (https://www.snip2code.com/Snippet/242104/Decrypt-Documentum-database-passwords-) :
018 | package com.dm_misc.recoverpw; |
020 | import com.documentum.fc.client.impl.crypto.CryptoUtils; |
021 | import com.documentum.fc.tools.RegistryPasswordUtils; |
022 | import com.documentum.dmcl.impl.DmclApi; |
023 | import com.documentum.web.formext.session.TrustedAuthenticatorTool; |
024 | import com.documentum.web.formext.session.TrustedAuthenticatorUtils; |
027 | public class RecoverPW { |
029 | private static final String AEK_PATH = "c:/documentum/config/aek.key" ; |
030 | private static boolean decrypted = false ; |
031 | private static String password = "" ; |
033 | public static void main(String args[]) { |
036 | if (args.length != 1 ) { |
037 | System.out.println( "usage: c:>java recoverPW <password>" ); |
041 | File file = new File(AEK_PATH); |
042 | if (!file.exists()) { |
043 | System.out.println( "Could not find aek.key file. Please copy from Content Server to " + AEK_PATH); |
049 | System.out.println( "\nTrying to decrypt '" + password + "'...\n" ); |
053 | String clearText = "" ; |
054 | System.out.print( "\tBOF Utils ->\t\t\t\t" ); |
055 | clearText = RegistryPasswordUtils.decrypt(password); |
056 | if ((clearText != null ) && (clearText.length() > 0 )) { |
057 | System.out.println( "'" + clearText + "'" ); |
061 | } catch (Exception e) { |
062 | System.out.println( "ERROR: " + e.getMessage()); |
067 | String clearText = "" ; |
068 | System.out.print( "\tAPI ->\t\t\t\t\t" ); |
069 | DmclApi.getInstance().exec( "initcrypto,c," + AEK_PATH); |
070 | clearText = DmclApi.getInstance().get( "decrypttext,c,DM_ENCR_TEXT=" + password); |
071 | if ((clearText != null ) && (clearText.length() > 0 )) { |
072 | System.out.println( "'" + clearText + "'" ); |
076 | } catch (Exception e) { |
077 | System.out.println( "ERROR: " + e.getMessage()); |
082 | String clearText = "" ; |
083 | System.out.print( "\tCryptoUtils (password) ->\t\t" ); |
084 | CryptoUtils c = CryptoUtils.getInstance(); |
085 | clearText = c.decryptPassword( "DM_ENCR_PASS=" + password); |
086 | if ((clearText != null ) && (clearText.length() > 0 )) { |
087 | System.out.println( "'" + clearText + "'" ); |
091 | } catch (Exception e) { |
092 | System.out.println( "ERROR: " + e.getMessage()); |
097 | String clearText = "" ; |
098 | System.out.print( "\tCryptoUtils (text) ->\t\t\t" ); |
099 | CryptoUtils c = CryptoUtils.getInstance(); |
100 | clearText = c.decryptText( "DM_ENCR_TEXT=" + password, "p6lo3ly1oj5ne&" ); |
101 | if ((clearText != null ) && (clearText.length() > 0 )) { |
102 | System.out.println( "'" + clearText + "'" ); |
106 | } catch (Exception e) { |
107 | System.out.println( "ERROR: " + e.getMessage()); |
112 | String clearText = "" ; |
113 | System.out.print( "\tTrustedAuthenticatorUtils (DES) ->\t" ); |
114 | clearText = TrustedAuthenticatorUtils.decryptByDES(password); |
115 | if ((clearText != null ) && (clearText.length() > 0 )) { |
116 | System.out.println( "'" + clearText + "'" ); |
120 | } catch (Exception e) { |
121 | System.out.println( "ERROR: " + e.getMessage()); |
126 | String clearText = "" ; |
127 | System.out.print( "\tTrustedAuthenticatorUtils (decrypt) ->\t" ); |
128 | clearText = TrustedAuthenticatorUtils.decrypt(password); |
129 | if ((clearText != null ) && (clearText.length() > 0 )) { |
130 | System.out.println( "'" + clearText + "'" ); |
134 | } catch (Exception e) { |
135 | System.out.println( "ERROR: " + e.getMessage()); |
141 | System.out.print( "\tWDK authenticator tool -> \t\t" ); |
145 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
146 | PrintStream ps = new PrintStream(baos); |
147 | PrintStream old = System.out; |
151 | TrustedAuthenticatorTool.main( new String[]{password}); |
158 | String clearText = baos.toString(); |
159 | int idx = clearText.indexOf( "Decrypted:" ); |
161 | clearText = clearText.substring(idx + "Decrypted: [" .length(), clearText.length() - 3 ); |
162 | System.out.println( "'" + clearText + "'" ); |
163 | if (clearText.equalsIgnoreCase(password)) { |
169 | System.out.println( "ERROR: could not decrypt with WDK Authenticator Tool" ); |
172 | } catch (Exception e) { |
173 | System.out.println( "ERROR: " + e.getMessage()); |
176 | } catch (Exception e) { |
177 | System.out.println( "General Error: " + e.getMessage()); |
180 | System.out.println(); |
182 | System.out.println( "\nSorry, could not decrypt '" + password + "'." ); |
184 | System.out.println( "Done." ); |
That’s all!!!
Huseyin OZVEREN
Related