| 12345678910111213141516171819202122232425262728293031 |
- import cn.yoshop.common.auth.LoginInfo;
- import cn.yoshop.common.auth.PhpUnserializer;
- import cn.yoshop.common.auth.ThinkFileCacheTokenStore;
- import java.lang.reflect.Field;
- import java.nio.file.Files;
- import java.nio.file.Path;
- public class AuthDiag {
- public static void main(String[] args) throws Exception {
- Path p = Path.of("F:/shop/java-rewrite/test-runtime/cache/a9/3029ed2d7a32cb7772b841e3c3a68a.php");
- byte[] content = Files.readAllBytes(p);
- System.out.println("file len = " + content.length);
- System.out.println("head32 = " + new String(content, 0, 32, java.nio.charset.StandardCharsets.UTF_8).replace("\n", "\\n"));
- byte[] serialized = new byte[content.length - 32];
- System.arraycopy(content, 32, serialized, 0, serialized.length);
- try {
- Object o = PhpUnserializer.parse(serialized);
- System.out.println("parse OK: " + o);
- } catch (Exception e) {
- System.out.println("parse FAIL: " + e);
- e.printStackTrace();
- }
- ThinkFileCacheTokenStore store = new ThinkFileCacheTokenStore();
- Field f = ThinkFileCacheTokenStore.class.getDeclaredField("cachePath");
- f.setAccessible(true);
- f.set(store, "F:/shop/java-rewrite/test-runtime/cache");
- LoginInfo info = store.getLoginInfo("testtoken123");
- System.out.println("token resolve: " + (info == null ? "null" : "storeId=" + info.getStoreId() + " login=" + info.isLogin() + " userId=" + info.getStoreUserId()));
- }
- }
|