|
5 | 5 |
|
6 | 6 | package com.liferay.portal.security.password.encryptor.internal;
|
7 | 7 |
|
| 8 | +import com.liferay.petra.string.CharPool; |
| 9 | +import com.liferay.petra.string.StringBundler; |
8 | 10 | import com.liferay.petra.string.StringPool;
|
9 | 11 | import com.liferay.portal.kernel.exception.PwdEncryptorException;
|
10 | 12 | import com.liferay.portal.kernel.io.BigEndianCodec;
|
| 13 | +import com.liferay.portal.kernel.log.Log; |
| 14 | +import com.liferay.portal.kernel.log.LogFactoryUtil; |
11 | 15 | import com.liferay.portal.kernel.security.SecureRandomUtil;
|
12 | 16 | import com.liferay.portal.kernel.security.pwd.PasswordEncryptor;
|
13 | 17 | import com.liferay.portal.kernel.util.Base64;
|
@@ -89,12 +93,39 @@ public String encrypt(
|
89 | 93 | }
|
90 | 94 | }
|
91 | 95 |
|
| 96 | + @Override |
| 97 | + public String getFullAlgorithmConfiguration(String encryptedPassword) { |
| 98 | + PBKDF2EncryptionConfiguration pbkdf2EncryptionConfiguration = |
| 99 | + new PBKDF2EncryptionConfiguration(); |
| 100 | + |
| 101 | + int index = encryptedPassword.indexOf(CharPool.CLOSE_CURLY_BRACE); |
| 102 | + |
| 103 | + try { |
| 104 | + pbkdf2EncryptionConfiguration.configure( |
| 105 | + StringPool.BLANK, encryptedPassword.substring(index + 1)); |
| 106 | + } |
| 107 | + catch (Exception exception) { |
| 108 | + _log.error(exception); |
| 109 | + } |
| 110 | + |
| 111 | + String algorithm = encryptedPassword.substring(1, index); |
| 112 | + |
| 113 | + return StringBundler.concat( |
| 114 | + algorithm, StringPool.FORWARD_SLASH, |
| 115 | + pbkdf2EncryptionConfiguration.getKeySize(), |
| 116 | + StringPool.FORWARD_SLASH, |
| 117 | + pbkdf2EncryptionConfiguration.getRounds()); |
| 118 | + } |
| 119 | + |
92 | 120 | private static final int _KEY_SIZE = 160;
|
93 | 121 |
|
94 | 122 | private static final int _ROUNDS = 1300000;
|
95 | 123 |
|
96 | 124 | private static final int _SALT_BYTES_LENGTH = 16;
|
97 | 125 |
|
| 126 | + private static final Log _log = LogFactoryUtil.getLog( |
| 127 | + PBKDF2PasswordEncryptor.class); |
| 128 | + |
98 | 129 | private static final Pattern _pattern = Pattern.compile(
|
99 | 130 | "^.*/?([0-9]+)?/([0-9]+)$");
|
100 | 131 |
|
|
0 commit comments