· 7 years ago · Aug 12, 2018, 11:14 PM
1// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
2// Jad home page: http://www.geocities.com/kpdus/jad.html
3// Decompiler options: braces fieldsfirst space lnc
4
5package com.abc.authentication.managers;
6
7import com.abc.authentication.exceptions.PinCheckLimitExceededLogout;
8import com.abc.authentication.exceptions.PinIsTooSimpleException;
9import com.securepreferences.a.a;
10import java.security.MessageDigest;
11import java.security.NoSuchAlgorithmException;
12import java.security.SecureRandom;
13import java.security.spec.KeySpec;
14import java.util.ArrayList;
15import java.util.Arrays;
16import javax.crypto.KeyGenerator;
17import javax.crypto.SecretKey;
18import javax.crypto.SecretKeyFactory;
19import javax.crypto.spec.PBEKeySpec;
20import kotlin.TypeCastException;
21import kotlin.a.j;
22import kotlin.e.b.g;
23import kotlin.e.b.k;
24import kotlin.e.b.x;
25import kotlin.i.d;
26import timber.log.Timber;
27
28public final class PinManager
29{
30 private static final class a
31 {
32
33 public final int a()
34 {
35 return com.abc.authentication.managers.PinManager.j();
36 }
37
38 public final ArrayList b()
39 {
40 return com.abc.authentication.managers.PinManager.k();
41 }
42
43 private a()
44 {
45 }
46
47 public a(g g1)
48 {
49 this();
50 }
51 }
52
53
54 public static final a a = new a(null);
55 private static final int d = 15000;
56 private static final ArrayList e = kotlin.a.j.d(new String[] {
57 "12345", "54321", "00000", "11111", "22222", "33333", "44444", "55555", "66666", "77777",
58 "88888", "99999", "12121", "13131", "69696", "01234", "98765", "09876", "90210", "12321"
59 });
60 private boolean b;
61 private long c;
62
63 public PinManager()
64 {
65 }
66
67 private final boolean d(String s)
68 {
69 Object obj;
70 Object obj1;
71 obj = MessageDigest.getInstance("SHA-256");
72 obj1 = d.a;
73 if (s == null)
74 {
75 try
76 {
77 throw new TypeCastException("null cannot be cast to non-null type java.lang.String");
78 }
79 // Misplaced declaration of an exception variable
80 catch (String s)
81 {
82 Timber.b((Throwable)s);
83 }
84 return false;
85 }
86 byte abyte0[];
87 int j1;
88 byte abyte1[] = s.getBytes(((java.nio.charset.Charset) (obj1)));
89 kotlin.e.b.k.a(abyte1, "(this as java.lang.String).getBytes(charset)");
90 ((MessageDigest) (obj)).update(abyte1);
91 abyte0 = ((MessageDigest) (obj)).digest();
92 abyte1 = new StringBuilder();
93 j1 = abyte0.length;
94 int i1 = 0;
95_L2:
96 byte byte0;
97 if (i1 >= j1)
98 {
99 break; /* Loop/switch isn't completed */
100 }
101 byte0 = abyte0[i1];
102 Object obj2 = x.a;
103 Object aobj[] = new Object[1];
104 aobj[0] = Byte.valueOf(byte0);
105 aobj = String.format("%02x", Arrays.copyOf(aobj, aobj.length));
106 kotlin.e.b.k.a(((Object) (aobj)), "java.lang.String.format(format, *args)");
107 abyte1.append(((String) (aobj)));
108 i1++;
109 if (true) goto _L2; else goto _L1
110_L1:
111 boolean flag;
112 abyte0 = abyte1.toString();
113 abyte1 = (String)com.e.a.j.b("pin_code", "");
114 flag = kotlin.e.b.k.a(abyte1, abyte0);
115 abyte0 = (String)com.e.a.j.b("pin_salt", null);
116 if (abyte0 != null)
117 {
118 break MISSING_BLOCK_LABEL_226;
119 }
120 abyte0 = com.securepreferences.a.a.c(n().getEncoded(), 0);
121 kotlin.e.b.k.a(abyte0, "Base64.encode(generateRa\u2026.encoded, Base64.DEFAULT)");
122 abyte0 = new String(abyte0, d.a);
123 com.e.a.j.a("pin_salt", abyte0);
124 SecretKeyFactory secretkeyfactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
125 if (s != null)
126 {
127 break MISSING_BLOCK_LABEL_247;
128 }
129 throw new TypeCastException("null cannot be cast to non-null type java.lang.String");
130 s = s.toCharArray();
131 kotlin.e.b.k.a(s, "(this as java.lang.String).toCharArray()");
132 s = secretkeyfactory.generateSecret((KeySpec)new PBEKeySpec(s, com.securepreferences.a.a.a(abyte0, 0), 1000, 256));
133 kotlin.e.b.k.a(s, "secretKey");
134 s = com.securepreferences.a.a.c(s.getEncoded(), 0);
135 kotlin.e.b.k.a(s, "Base64.encode(secretKey.encoded, Base64.DEFAULT)");
136 s = new String(s, d.a);
137 if (!flag)
138 {
139 break MISSING_BLOCK_LABEL_335;
140 }
141 com.e.a.j.a("pin_code", s);
142 return true;
143 flag = Arrays.equals(com.securepreferences.a.a.a(abyte1, 0), com.securepreferences.a.a.a(s, 0));
144 return flag;
145 }
146
147 public static final int j()
148 {
149 return d;
150 }
151
152 public static final ArrayList k()
153 {
154 return e;
155 }
156
157 private final boolean l()
158 {
159 return com.e.a.j.a("pin_incorrect_count", Integer.valueOf(c() + 1));
160 }
161
162 private final boolean m()
163 {
164 return c == 0L || c + (long)a.a() < System.currentTimeMillis();
165 }
166
167 private final SecretKey n()
168 throws NoSuchAlgorithmException
169 {
170 Object obj = new SecureRandom();
171 KeyGenerator keygenerator = KeyGenerator.getInstance("AES");
172 keygenerator.init(256, ((SecureRandom) (obj)));
173 obj = keygenerator.generateKey();
174 kotlin.e.b.k.a(obj, "keyGenerator.generateKey()");
175 return ((SecretKey) (obj));
176 }
177
178 public final void a(String s)
179 {
180 kotlin.e.b.k.b(s, "pin");
181 if (a.b().contains(s))
182 {
183 throw (Throwable)new PinIsTooSimpleException();
184 }
185 if (s.length() != 5)
186 {
187 throw (Throwable)new Exception("Pin length must be: 5");
188 } else
189 {
190 byte abyte0[] = com.securepreferences.a.a.c(n().getEncoded(), 0);
191 kotlin.e.b.k.a(abyte0, "Base64.encode(generateRa\u2026.encoded, Base64.DEFAULT)");
192 String s1 = new String(abyte0, d.a);
193 com.e.a.j.a("pin_salt", s1);
194 SecretKeyFactory secretkeyfactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
195 s = s.toCharArray();
196 kotlin.e.b.k.a(s, "(this as java.lang.String).toCharArray()");
197 s = secretkeyfactory.generateSecret((KeySpec)new PBEKeySpec(s, com.securepreferences.a.a.a(s1, 0), 1000, 256));
198 kotlin.e.b.k.a(s, "secretKey");
199 s = com.securepreferences.a.a.c(s.getEncoded(), 0);
200 kotlin.e.b.k.a(s, "Base64.encode(secretKey.encoded, Base64.DEFAULT)");
201 com.e.a.j.a("pin_code", new String(s, d.a));
202 return;
203 }
204 }
205
206 public final void a(String s, String s1)
207 {
208 kotlin.e.b.k.b(s, "hashedPin");
209 kotlin.e.b.k.b(s1, "salt");
210 com.e.a.j.a("pin_code", s);
211 com.e.a.j.a("pin_salt", s1);
212 }
213
214 public final void a(boolean flag)
215 {
216 b = flag;
217 }
218
219 public final void a(boolean flag, long l1)
220 {
221 com.e.a.j.a("pin_lock_ignore", Boolean.valueOf(flag));
222 if (l1 != 0L)
223 {
224 com.e.a.j.a("pin_lock_ignore_end_time", Long.valueOf(l1));
225 }
226 }
227
228 public final boolean a()
229 {
230 return b;
231 }
232
233 public final boolean b()
234 {
235 CharSequence charsequence = (CharSequence)com.e.a.j.a("pin_code");
236 boolean flag;
237 if (charsequence == null || charsequence.length() == 0)
238 {
239 flag = true;
240 } else
241 {
242 flag = false;
243 }
244 return !flag;
245 }
246
247 public final boolean b(String s)
248 {
249 kotlin.e.b.k.b(s, "pin");
250 if (c(s))
251 {
252 return true;
253 }
254 if (c() >= 10)
255 {
256 throw (Throwable)new PinCheckLimitExceededLogout();
257 } else
258 {
259 return false;
260 }
261 }
262
263 public final int c()
264 {
265 Integer integer = (Integer)com.e.a.j.a("pin_incorrect_count");
266 if (integer != null)
267 {
268 return integer.intValue();
269 } else
270 {
271 return 0;
272 }
273 }
274
275 public final boolean c(String s)
276 {
277 kotlin.e.b.k.b(s, "pin");
278 if (d(s))
279 {
280 d();
281 return true;
282 } else
283 {
284 l();
285 return false;
286 }
287 }
288
289 public final void d()
290 {
291 com.e.a.j.a("pin_incorrect_count", Integer.valueOf(0));
292 }
293
294 public final void e()
295 {
296 com.e.a.j.b("pin_code");
297 com.e.a.j.b("pin_incorrect_count");
298 com.e.a.j.b("pin_lock_ignore");
299 com.e.a.j.b("pin_lock_ignore_end_time");
300 }
301
302 public final void f()
303 {
304 a(true, System.currentTimeMillis() + 0x1d4c0L);
305 }
306
307 public final boolean g()
308 {
309 if (b)
310 {
311 b = false;
312 return true;
313 }
314 if (!m())
315 {
316 return true;
317 }
318 Object obj = com.e.a.j.b("pin_lock_ignore", Boolean.valueOf(false));
319 kotlin.e.b.k.a(obj, "Hawk.get<Boolean>(ARG_PIN_LOCK_IGNORE, false)");
320 return ((Boolean)obj).booleanValue() && kotlin.e.b.k.a(((Number)com.e.a.j.b("pin_lock_ignore_end_time", Long.valueOf(0L))).longValue(), System.currentTimeMillis()) > 0;
321 }
322
323 public final void h()
324 {
325 c = System.currentTimeMillis();
326 }
327
328 public final void i()
329 {
330 c = 0L;
331 }
332
333}