AuthenticationHelper.java
2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.commons.codec.binary.Base64
* org.apache.commons.codec.binary.StringUtils
*/
package com.day.cq.analytics.sitecatalyst.util;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.StringUtils;
public class AuthenticationHelper {
@Deprecated
public static String generateSharedSecret(String password) {
throw new UnsupportedOperationException("This method is no longer supported.");
}
@Deprecated
public static synchronized String generateApplicationKey(byte[] nonceValue, String key) throws Exception {
throw new UnsupportedOperationException("This method is no longer supported.");
}
public static synchronized String getBase64Digest(byte[] nonce, byte[] created, byte[] password) {
try {
MessageDigest messageDigester = MessageDigest.getInstance("SHA-1");
messageDigester.reset();
messageDigester.update(nonce);
messageDigester.update(created);
messageDigester.update(password);
return AuthenticationHelper.base64Encode(messageDigester.digest());
}
catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
public static synchronized String getBase64DigestKey(byte[] nonce, byte[] apiPass) {
try {
MessageDigest messageDigester = MessageDigest.getInstance("SHA-1");
messageDigester.reset();
messageDigester.update(nonce);
messageDigester.update(apiPass);
return AuthenticationHelper.base64Encode(messageDigester.digest());
}
catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
public static String base64Encode(byte[] bytes) {
return StringUtils.newStringUtf8((byte[])Base64.encodeBase64((byte[])bytes, (boolean)false));
}
}