zyx 1 vuosi sitten
vanhempi
commit
b7eeec4cd1

+ 12 - 2
build.gradle

@@ -4,7 +4,10 @@ plugins {
 
 group 'org.example'
 version '1.0-SNAPSHOT'
-sourceCompatibility = 17
+sourceCompatibility = 1.8
+tasks.withType(JavaCompile).configureEach {
+    options.encoding = "UTF-8"
+}
 
 repositories {
     maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }
@@ -12,9 +15,14 @@ repositories {
 }
 
 dependencies {
+
     implementation 'commons-io:commons-io:2.11.0'
+    implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.4'
+    implementation 'org.apache.httpcomponents.client5:httpclient5:5.2.1'
     testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
     testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
+    compileOnly 'org.projectlombok:lombok:1.18.24'
+    annotationProcessor 'org.projectlombok:lombok:1.18.24'
 }
 
 
@@ -23,7 +31,7 @@ jar {
     manifest {
         attributes(
                 "Manifest-Version": 1.0,
-                "Main-Class": "org.example.Main")
+                "Main-Class": "org.example.HttpTest")
     }
 
     archiveFileName = 'app.jar'
@@ -31,8 +39,10 @@ jar {
     into('assets') {
         from 'assets'
     }
+    duplicatesStrategy = 'include'
 }
 
 test {
     useJUnitPlatform()
 }
+

BIN
out/production/classes/org/example/AndroidDesUtil.class


BIN
out/production/classes/org/example/BASE64Decoder.class


BIN
out/production/classes/org/example/BASE64Encoder.class


BIN
out/production/classes/org/example/Base64.class


BIN
out/production/classes/org/example/CharacterDecoder.class


BIN
out/production/classes/org/example/CharacterEncoder.class


BIN
out/production/classes/org/example/Daka.class


BIN
out/production/classes/org/example/DakaParams.class


BIN
out/production/classes/org/example/DakaRootParams.class


BIN
out/production/classes/org/example/RsaUtil.class


+ 111 - 0
src/main/java/org/example/AndroidDesUtil.java

@@ -0,0 +1,111 @@
+package org.example;
+
+import lombok.SneakyThrows;
+
+import java.io.UnsupportedEncodingException;
+import java.security.Key;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.DESedeKeySpec;
+import javax.crypto.spec.IvParameterSpec;
+
+/**
+ * 3DES加密工具类
+ */
+public class AndroidDesUtil {
+	// 密钥
+	private final static String secretKey = "m1yanfa@seeyon.com119$#M1#$";
+	private final static String iv = "01234567";
+	private final static String encoding = "utf-8";
+
+	/**
+	 * DES加密
+	 * @param plainText
+	 *            普通文本
+	 * @return
+	 * @throws Exception
+	 */
+	public static String encode(String plainText) throws Exception {
+		if (plainText == null || "".endsWith(plainText)) {
+			return "";
+		}
+		try {
+			Key deskey = null;
+			DESedeKeySpec spec = new DESedeKeySpec(secretKey.getBytes());
+			SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("desede");
+			deskey = keyfactory.generateSecret(spec);
+
+			Cipher cipher = Cipher.getInstance("desede/CBC/PKCS5Padding");
+			IvParameterSpec ips = new IvParameterSpec(iv.getBytes());
+			cipher.init(Cipher.ENCRYPT_MODE, deskey, ips);
+			byte[] encryptData = cipher.doFinal(plainText.getBytes(encoding));
+			return Base64.encode(encryptData);
+		} catch (Exception e) {
+			throw new Exception(e.getLocalizedMessage());
+		}
+	}
+
+	/**
+	 * DES解密
+	 *
+	 * @param encryptText
+	 *            加密文本
+	 * @return
+	 * @throws Exception
+	 */
+	public static String decode(String encryptText) throws Exception {
+		try {
+			if(encryptText == null){
+				return "";
+			}
+			Key deskey = null;
+			DESedeKeySpec spec = new DESedeKeySpec(secretKey.getBytes());
+			SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("desede");
+			deskey = keyfactory.generateSecret(spec);
+			Cipher cipher = Cipher.getInstance("desede/CBC/PKCS5Padding");
+			IvParameterSpec ips = new IvParameterSpec(iv.getBytes());
+			cipher.init(Cipher.DECRYPT_MODE, deskey, ips);
+			byte[] decryptData = cipher.doFinal(Base64.decode(encryptText));
+			return new String(decryptData, encoding);
+		} catch (Exception e) {
+			throw new Exception(e.getLocalizedMessage());
+		}
+	}
+
+	public static String md5String(String inputString) {
+		byte[] hash;
+		try {
+			hash = MessageDigest.getInstance("MD5").digest(inputString.getBytes("UTF-8"));
+		} catch (NoSuchAlgorithmException var7) {
+			throw new RuntimeException("Huh, MD5 should be supported?", var7);
+		} catch (UnsupportedEncodingException var8) {
+			throw new RuntimeException("Huh, UTF-8 should be supported?", var8);
+		}
+
+		StringBuilder hex = new StringBuilder(hash.length * 2);
+		byte[] var3 = hash;
+		int var4 = hash.length;
+
+		for(int var5 = 0; var5 < var4; ++var5) {
+			byte b = var3[var5];
+			if ((b & 255) < 16) {
+				hex.append("0");
+			}
+
+			hex.append(Integer.toHexString(b & 255));
+		}
+
+		return hex.toString();
+	}
+
+	@SneakyThrows
+	public static void main(String[] args) {
+		String encode = AndroidDesUtil.encode("zyx888888");
+		System.out.println(encode);
+		String decode = AndroidDesUtil.decode("rSF3HKzE2Q2wAcJCP6ib+g==");
+		System.out.println(decode);
+	}
+}

+ 93 - 0
src/main/java/org/example/BASE64Decoder.java

@@ -0,0 +1,93 @@
+package org.example;
+
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PushbackInputStream;
+
+public class BASE64Decoder extends CharacterDecoder {
+    private static final char[] pem_array = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'};
+    private static final byte[] pem_convert_array = new byte[256];
+    byte[] decode_buffer = new byte[4];
+
+    static {
+        int i;
+        for(i = 0; i < 255; ++i) {
+            pem_convert_array[i] = -1;
+        }
+
+        for(i = 0; i < pem_array.length; ++i) {
+            pem_convert_array[pem_array[i]] = (byte)i;
+        }
+
+    }
+
+    public BASE64Decoder() {
+    }
+
+    protected int bytesPerAtom() {
+        return 4;
+    }
+
+    protected int bytesPerLine() {
+        return 72;
+    }
+
+    protected void decodeAtom(PushbackInputStream inStream, OutputStream outStream, int rem) throws IOException {
+        byte a = -1;
+        byte b = -1;
+        byte c = -1;
+        byte d = -1;
+        if (rem < 2) {
+            throw new RuntimeException("BASE64Decoder: Not enough bytes for an atom.");
+        } else {
+            int i;
+            do {
+                i = inStream.read();
+                if (i == -1) {
+                    throw new RuntimeException();
+                }
+            } while(i == 10 || i == 13);
+
+            this.decode_buffer[0] = (byte)i;
+            i = this.readFully(inStream, this.decode_buffer, 1, rem - 1);
+            if (i == -1) {
+                throw new RuntimeException();
+            } else {
+                if (rem > 3 && this.decode_buffer[3] == 61) {
+                    rem = 3;
+                }
+
+                if (rem > 2 && this.decode_buffer[2] == 61) {
+                    rem = 2;
+                }
+
+                switch (rem) {
+                    case 4:
+                        d = pem_convert_array[this.decode_buffer[3] & 255];
+                    case 3:
+                        c = pem_convert_array[this.decode_buffer[2] & 255];
+                    case 2:
+                        b = pem_convert_array[this.decode_buffer[1] & 255];
+                        a = pem_convert_array[this.decode_buffer[0] & 255];
+                    default:
+                        switch (rem) {
+                            case 2:
+                                outStream.write((byte)(a << 2 & 252 | b >>> 4 & 3));
+                                break;
+                            case 3:
+                                outStream.write((byte)(a << 2 & 252 | b >>> 4 & 3));
+                                outStream.write((byte)(b << 4 & 240 | c >>> 2 & 15));
+                                break;
+                            case 4:
+                                outStream.write((byte)(a << 2 & 252 | b >>> 4 & 3));
+                                outStream.write((byte)(b << 4 & 240 | c >>> 2 & 15));
+                                outStream.write((byte)(c << 6 & 192 | d & 63));
+                        }
+
+                }
+            }
+        }
+    }
+}
+

+ 52 - 0
src/main/java/org/example/BASE64Encoder.java

@@ -0,0 +1,52 @@
+package org.example;
+
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class BASE64Encoder extends CharacterEncoder {
+    private static final char[] pem_array = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'};
+
+    public BASE64Encoder() {
+    }
+
+    protected int bytesPerAtom() {
+        return 3;
+    }
+
+    protected int bytesPerLine() {
+        return 57;
+    }
+
+    protected void encodeAtom(OutputStream outStream, byte[] data, int offset, int len) throws IOException {
+        byte a;
+        if (len == 1) {
+            a = data[offset];
+            byte b = 0;
+            outStream.write(pem_array[a >>> 2 & 63]);
+            outStream.write(pem_array[(a << 4 & 48) + (b >>> 4 & 15)]);
+            outStream.write(61);
+            outStream.write(61);
+        } else {
+            byte b;
+            if (len == 2) {
+                a = data[offset];
+                b = data[offset + 1];
+                byte c = 0;
+                outStream.write(pem_array[a >>> 2 & 63]);
+                outStream.write(pem_array[(a << 4 & 48) + (b >>> 4 & 15)]);
+                outStream.write(pem_array[(b << 2 & 60) + (c >>> 6 & 3)]);
+                outStream.write(61);
+            } else {
+                a = data[offset];
+                b = data[offset + 1];
+                byte c = data[offset + 2];
+                outStream.write(pem_array[a >>> 2 & 63]);
+                outStream.write(pem_array[(a << 4 & 48) + (b >>> 4 & 15)]);
+                outStream.write(pem_array[(b << 2 & 60) + (c >>> 6 & 3)]);
+                outStream.write(pem_array[c & 63]);
+            }
+        }
+
+    }
+}

+ 125 - 0
src/main/java/org/example/Base64.java

@@ -0,0 +1,125 @@
+package org.example;
+
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Base64编码工具类
+ */
+public class Base64 {
+    private static final char[] legalChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();
+
+    public static String encode(byte[] data) {
+        int start = 0;
+        int len = data.length;
+        StringBuffer buf = new StringBuffer(data.length * 3 / 2);
+
+        int end = len - 3;
+        int i = start;
+        int n = 0;
+
+        while (i <= end) {
+            int d = ((((int) data[i]) & 0x0ff) << 16) | ((((int) data[i + 1]) & 0x0ff) << 8) | (((int) data[i + 2]) & 0x0ff);
+
+            buf.append(legalChars[(d >> 18) & 63]);
+            buf.append(legalChars[(d >> 12) & 63]);
+            buf.append(legalChars[(d >> 6) & 63]);
+            buf.append(legalChars[d & 63]);
+
+            i += 3;
+
+            if (n++ >= 14) {
+                n = 0;
+                buf.append(" ");
+            }
+        }
+
+        if (i == start + len - 2) {
+            int d = ((((int) data[i]) & 0x0ff) << 16) | ((((int) data[i + 1]) & 255) << 8);
+
+            buf.append(legalChars[(d >> 18) & 63]);
+            buf.append(legalChars[(d >> 12) & 63]);
+            buf.append(legalChars[(d >> 6) & 63]);
+            buf.append("=");
+        } else if (i == start + len - 1) {
+            int d = (((int) data[i]) & 0x0ff) << 16;
+
+            buf.append(legalChars[(d >> 18) & 63]);
+            buf.append(legalChars[(d >> 12) & 63]);
+            buf.append("==");
+        }
+
+        return buf.toString();
+    }
+
+    private static int decode(char c) {
+        if (c >= 'A' && c <= 'Z')
+            return ((int) c) - 65;
+        else if (c >= 'a' && c <= 'z')
+            return ((int) c) - 97 + 26;
+        else if (c >= '0' && c <= '9')
+            return ((int) c) - 48 + 26 + 26;
+        else
+            switch (c) {
+                case '+':
+                    return 62;
+                case '/':
+                    return 63;
+                case '=':
+                    return 0;
+                default:
+                    throw new RuntimeException("unexpected code: " + c);
+            }
+    }
+
+    /**
+     * Decodes the given Base64 encoded String to a new byte array. The byte array holding the decoded data is returned.
+     */
+
+    public static byte[] decode(String s) {
+
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        try {
+            decode(s, bos);
+        } catch (IOException e) {
+            throw new RuntimeException();
+        }
+        byte[] decodedBytes = bos.toByteArray();
+        try {
+            bos.close();
+            bos = null;
+        } catch (IOException ex) {
+            ex.printStackTrace();
+        }
+        return decodedBytes;
+    }
+
+    private static void decode(String s, OutputStream os) throws IOException {
+        int i = 0;
+
+        int len = s.length();
+
+        while (true) {
+            while (i < len && s.charAt(i) <= ' ')
+                i++;
+
+            if (i == len)
+                break;
+
+            int tri = (decode(s.charAt(i)) << 18) + (decode(s.charAt(i + 1)) << 12) + (decode(s.charAt(i + 2)) << 6) + (decode(s.charAt(i + 3)));
+
+            os.write((tri >> 16) & 255);
+            if (s.charAt(i + 2) == '=')
+                break;
+            os.write((tri >> 8) & 255);
+            if (s.charAt(i + 3) == '=')
+                break;
+            os.write(tri & 255);
+
+            i += 4;
+        }
+    }
+}
+

+ 103 - 0
src/main/java/org/example/CharacterDecoder.java

@@ -0,0 +1,103 @@
+package org.example;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PushbackInputStream;
+import java.nio.ByteBuffer;
+
+public abstract class CharacterDecoder {
+    public CharacterDecoder() {
+    }
+
+    protected abstract int bytesPerAtom();
+
+    protected abstract int bytesPerLine();
+
+    protected void decodeBufferPrefix(PushbackInputStream aStream, OutputStream bStream) throws IOException {
+    }
+
+    protected void decodeBufferSuffix(PushbackInputStream aStream, OutputStream bStream) throws IOException {
+    }
+
+    protected int decodeLinePrefix(PushbackInputStream aStream, OutputStream bStream) throws IOException {
+        return this.bytesPerLine();
+    }
+
+    protected void decodeLineSuffix(PushbackInputStream aStream, OutputStream bStream) throws IOException {
+    }
+
+    protected void decodeAtom(PushbackInputStream aStream, OutputStream bStream, int l) throws IOException {
+        throw new RuntimeException();
+    }
+
+    protected int readFully(InputStream in, byte[] buffer, int offset, int len) throws IOException {
+        for(int i = 0; i < len; ++i) {
+            int q = in.read();
+            if (q == -1) {
+                return i == 0 ? -1 : i;
+            }
+
+            buffer[i + offset] = (byte)q;
+        }
+
+        return len;
+    }
+
+    public void decodeBuffer(InputStream aStream, OutputStream bStream) throws IOException {
+        int totalBytes = 0;
+        PushbackInputStream ps = new PushbackInputStream(aStream);
+        this.decodeBufferPrefix(ps, bStream);
+
+        while(true) {
+            try {
+                int length = this.decodeLinePrefix(ps, bStream);
+
+                int i;
+                for(i = 0; i + this.bytesPerAtom() < length; i += this.bytesPerAtom()) {
+                    this.decodeAtom(ps, bStream, this.bytesPerAtom());
+                    totalBytes += this.bytesPerAtom();
+                }
+
+                if (i + this.bytesPerAtom() == length) {
+                    this.decodeAtom(ps, bStream, this.bytesPerAtom());
+                    totalBytes += this.bytesPerAtom();
+                } else {
+                    this.decodeAtom(ps, bStream, length - i);
+                    totalBytes += length - i;
+                }
+
+                this.decodeLineSuffix(ps, bStream);
+            } catch (RuntimeException var8) {
+                this.decodeBufferSuffix(ps, bStream);
+                return;
+            }
+        }
+    }
+
+    public byte[] decodeBuffer(String inputString) throws IOException {
+        byte[] inputBuffer = new byte[inputString.length()];
+        inputString.getBytes(0, inputString.length(), inputBuffer, 0);
+        ByteArrayInputStream inStream = new ByteArrayInputStream(inputBuffer);
+        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+        this.decodeBuffer(inStream, outStream);
+        return outStream.toByteArray();
+    }
+
+    public byte[] decodeBuffer(InputStream in) throws IOException {
+        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+        this.decodeBuffer(in, outStream);
+        return outStream.toByteArray();
+    }
+
+    public ByteBuffer decodeBufferToByteBuffer(String inputString) throws IOException {
+        return ByteBuffer.wrap(this.decodeBuffer(inputString));
+    }
+
+    public ByteBuffer decodeBufferToByteBuffer(InputStream in) throws IOException {
+        return ByteBuffer.wrap(this.decodeBuffer(in));
+    }
+}

+ 182 - 0
src/main/java/org/example/CharacterEncoder.java

@@ -0,0 +1,182 @@
+package org.example;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.nio.ByteBuffer;
+
+public abstract class CharacterEncoder {
+    protected PrintStream pStream;
+
+    public CharacterEncoder() {
+    }
+
+    protected abstract int bytesPerAtom();
+
+    protected abstract int bytesPerLine();
+
+    protected void encodeBufferPrefix(OutputStream aStream) throws IOException {
+        this.pStream = new PrintStream(aStream);
+    }
+
+    protected void encodeBufferSuffix(OutputStream aStream) throws IOException {
+    }
+
+    protected void encodeLinePrefix(OutputStream aStream, int aLength) throws IOException {
+    }
+
+    protected void encodeLineSuffix(OutputStream aStream) throws IOException {
+        this.pStream.println();
+    }
+
+    protected abstract void encodeAtom(OutputStream var1, byte[] var2, int var3, int var4) throws IOException;
+
+    protected int readFully(InputStream in, byte[] buffer) throws IOException {
+        for(int i = 0; i < buffer.length; ++i) {
+            int q = in.read();
+            if (q == -1) {
+                return i;
+            }
+
+            buffer[i] = (byte)q;
+        }
+
+        return buffer.length;
+    }
+
+    public void encode(InputStream inStream, OutputStream outStream) throws IOException {
+        byte[] tmpbuffer = new byte[this.bytesPerLine()];
+        this.encodeBufferPrefix(outStream);
+
+        while(true) {
+            int numBytes = this.readFully(inStream, tmpbuffer);
+            if (numBytes == 0) {
+                break;
+            }
+
+            this.encodeLinePrefix(outStream, numBytes);
+
+            for(int j = 0; j < numBytes; j += this.bytesPerAtom()) {
+                if (j + this.bytesPerAtom() <= numBytes) {
+                    this.encodeAtom(outStream, tmpbuffer, j, this.bytesPerAtom());
+                } else {
+                    this.encodeAtom(outStream, tmpbuffer, j, numBytes - j);
+                }
+            }
+
+            if (numBytes < this.bytesPerLine()) {
+                break;
+            }
+
+            this.encodeLineSuffix(outStream);
+        }
+
+        this.encodeBufferSuffix(outStream);
+    }
+
+    public void encode(byte[] aBuffer, OutputStream aStream) throws IOException {
+        ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer);
+        this.encode((InputStream)inStream, aStream);
+    }
+
+    public String encode(byte[] aBuffer) {
+        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+        ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer);
+        String retVal = null;
+
+        try {
+            this.encode((InputStream)inStream, outStream);
+            retVal = outStream.toString("8859_1");
+            return retVal;
+        } catch (Exception var6) {
+            throw new Error("CharacterEncoder.encode internal error");
+        }
+    }
+
+    private byte[] getBytes(ByteBuffer bb) {
+        byte[] buf = (byte[])null;
+        if (bb.hasArray()) {
+            byte[] tmp = bb.array();
+            if (tmp.length == bb.capacity() && tmp.length == bb.remaining()) {
+                buf = tmp;
+                bb.position(bb.limit());
+            }
+        }
+
+        if (buf == null) {
+            buf = new byte[bb.remaining()];
+            bb.get(buf);
+        }
+
+        return buf;
+    }
+
+    public void encode(ByteBuffer aBuffer, OutputStream aStream) throws IOException {
+        byte[] buf = this.getBytes(aBuffer);
+        this.encode(buf, aStream);
+    }
+
+    public String encode(ByteBuffer aBuffer) {
+        byte[] buf = this.getBytes(aBuffer);
+        return this.encode(buf);
+    }
+
+    public void encodeBuffer(InputStream inStream, OutputStream outStream) throws IOException {
+        byte[] tmpbuffer = new byte[this.bytesPerLine()];
+        this.encodeBufferPrefix(outStream);
+
+        int numBytes;
+        do {
+            numBytes = this.readFully(inStream, tmpbuffer);
+            if (numBytes == 0) {
+                break;
+            }
+
+            this.encodeLinePrefix(outStream, numBytes);
+
+            for(int j = 0; j < numBytes; j += this.bytesPerAtom()) {
+                if (j + this.bytesPerAtom() <= numBytes) {
+                    this.encodeAtom(outStream, tmpbuffer, j, this.bytesPerAtom());
+                } else {
+                    this.encodeAtom(outStream, tmpbuffer, j, numBytes - j);
+                }
+            }
+
+            this.encodeLineSuffix(outStream);
+        } while(numBytes >= this.bytesPerLine());
+
+        this.encodeBufferSuffix(outStream);
+    }
+
+    public void encodeBuffer(byte[] aBuffer, OutputStream aStream) throws IOException {
+        ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer);
+        this.encodeBuffer((InputStream)inStream, aStream);
+    }
+
+    public String encodeBuffer(byte[] aBuffer) {
+        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+        ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer);
+
+        try {
+            this.encodeBuffer((InputStream)inStream, outStream);
+        } catch (Exception var5) {
+            throw new Error("CharacterEncoder.encodeBuffer internal error");
+        }
+
+        return outStream.toString();
+    }
+
+    public void encodeBuffer(ByteBuffer aBuffer, OutputStream aStream) throws IOException {
+        byte[] buf = this.getBytes(aBuffer);
+        this.encodeBuffer(buf, aStream);
+    }
+
+    public String encodeBuffer(ByteBuffer aBuffer) {
+        byte[] buf = this.getBytes(aBuffer);
+        return this.encodeBuffer(buf);
+    }
+}

+ 102 - 0
src/main/java/org/example/Daka.java

@@ -0,0 +1,102 @@
+package org.example;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.SneakyThrows;
+import org.apache.commons.io.IOUtils;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.io.entity.StringEntity;
+import org.apache.hc.core5.http.message.BasicHeader;
+
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Random;
+
+public class Daka {
+
+    private static String randomStr() {
+        Random random = new Random();
+        StringBuilder randomNumber = new StringBuilder();
+        for (int i = 0; i < 8; i++) {
+            int digit = random.nextInt(10);  // generates a random integer from 0 to 9
+            randomNumber.append(digit);
+        }
+        return randomNumber.toString();
+    }
+
+
+    @SneakyThrows
+    public static void main(String[] args) {
+
+        String publicKeyStr = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQChDzcjw/rWgFwnxunbKp7/4e8w\n" +
+                "/UmXx2jk6qEEn69t6N2R1i/LmcyDT1xr/T2AHGOiXNQ5V8W4iCaaeNawi7aJaRht\n" +
+                "Vx1uOH/2U378fscEESEG8XDqll0GCfB1/TjKI2aitVSzXOtRs8kYgGU78f7VmDNg\n" +
+                "XIlk3gdhnzh+uoEQywIDAQAB";
+
+        byte[] sendTime = RsaUtil.encryptByPublicKey((System.currentTimeMillis() + "").getBytes(), publicKeyStr);
+
+
+        BASE64Encoder encoder = new BASE64Encoder();
+
+        try (CloseableHttpClient client = HttpClients.createDefault()) {
+            String jsessionid = getLoginCookie(client, encoder.encode(sendTime));
+            daka(client, jsessionid);
+        }
+
+    }
+
+    @SneakyThrows
+    private static void daka(CloseableHttpClient client, String jsessionid) {
+        HttpPost httpPost = new HttpPost("http://oa.sxtvs.com/seeyon/rest/m3/login/verification");
+
+        httpPost.setHeaders(new BasicHeader("Content-Type", "application/json;charset=UTF-8"));
+        httpPost.setHeaders(new BasicHeader("User-Agent", "seeyon-m3/4.2.4"));
+        httpPost.setHeaders(new BasicHeader("accessm3-scheme", "http"));
+        httpPost.setHeaders(new BasicHeader("sendtime", String.valueOf(System.currentTimeMillis() / 1000)));
+        httpPost.setHeaders(new BasicHeader("Cookie", jsessionid + ";"));
+        DakaRootParams daka = new DakaRootParams();
+        ObjectMapper objectMapper = new ObjectMapper();
+        String json = objectMapper.writeValueAsString(daka);
+
+        StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
+        httpPost.setEntity(entity);
+        String body = client.execute(httpPost, response -> {
+            InputStream inputStream = response.getEntity().getContent();
+            return IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+        });
+        System.out.println(body);
+    }
+
+    @SneakyThrows
+    private static String getLoginCookie(CloseableHttpClient client, String sendTime) {
+        HttpPost httpPost = new HttpPost("http://oa.sxtvs.com/seeyon/rest/lexmisAtt/attCommon/attApi?cmprnd=" + randomStr());
+
+        httpPost.setHeaders(new BasicHeader("Content-Type", "application/json;charset=UTF-8"));
+        httpPost.setHeaders(new BasicHeader("User-Agent", "seeyon-m3/4.2.4"));
+        httpPost.setHeaders(new BasicHeader("accessm3-scheme", "http"));
+        httpPost.setHeaders(new BasicHeader("sendtime", String.valueOf(System.currentTimeMillis() / 1000)));
+
+        StringEntity entity = new StringEntity("{\"deviceCode\":\"66361943-4EBB-4474-82E1-371CD3C2F768\",\"password\":\"qwjZCXeZeUZBWcH/zHOqWQ==\",\"client\":\"iphone\",\"login_mobliephone\":\"rSF3HKzE2Q2wAcJCP6ib+g==\",\"deviceID\":\"Y04KaZ0081eL5uBHOLHzLjkw7wZDnqXJKWOszrzQV1hy6VAHCUCirUWSdZ\n" +
+                "KxDosJUcvmCYTI2Rytqm62MzTFFYe3HZZUM+k55iYnzwWnpPfdHWTnAi4u+Cyb0VcIVGOBjeq7sVO\\\\/ugAq0jngW\\\\/nQHAxKnLdD2ynzj0i07eS25h4=\",\"timezone\":\"GMT+08:00\",\"sendTime\":\"" + sendTime + "\",\"name\":\"rSF3HKzE2Q2wAcJCP6ib+g==\"}", ContentType.APPLICATION_JSON);
+        httpPost.setEntity(entity);
+
+        return client.execute(httpPost, response -> {
+            InputStream inputStream = response.getEntity().getContent();
+            String body = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+            System.out.println(body);
+            for (Header header : response.getHeaders()) {
+                String name = header.getName();
+                if ("Set-Cookie".equals(name)) {
+                    String value = header.getValue();
+                    if (value.startsWith("JSESSIONID")) {
+                        return value.split(";")[0];
+                    }
+                }
+            }
+            return "";
+        });
+    }
+}

+ 28 - 0
src/main/java/org/example/DakaParams.java

@@ -0,0 +1,28 @@
+package org.example;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor
+@Data
+public class DakaParams {
+
+    @com.fasterxml.jackson.annotation.JsonProperty("device")
+    private String device = "66361943-4EBB-4474-82E1-371CD3C2F768";
+    @com.fasterxml.jackson.annotation.JsonProperty("check_in_type")
+    private String checkInType = "addr";
+    @com.fasterxml.jackson.annotation.JsonProperty("longitude")
+    private String longitude = "108.9434779188368";
+    @com.fasterxml.jackson.annotation.JsonProperty("wifi_mac")
+    private String wifiMac = "";
+    @com.fasterxml.jackson.annotation.JsonProperty("wifi_ssid")
+    private String wifiSsid = "";
+    @com.fasterxml.jackson.annotation.JsonProperty("sign_address")
+    private String signAddress = "陕西省西安市雁塔区长延堡街道黄金鱼庄西八里村村委会";
+    @com.fasterxml.jackson.annotation.JsonProperty("member_id")
+    private String memberId = "103339618090566457";
+    @com.fasterxml.jackson.annotation.JsonProperty("latitude")
+    private String latitude = "34.21016574435764";
+    @com.fasterxml.jackson.annotation.JsonProperty("check_in_time")
+    private String checkInTime = String.valueOf(System.currentTimeMillis());
+}

+ 10 - 0
src/main/java/org/example/DakaRootParams.java

@@ -0,0 +1,10 @@
+package org.example;
+
+import lombok.Data;
+
+@Data
+public class DakaRootParams {
+    private DakaParams params = new DakaParams();
+    private String managerName = "attMobileManager";
+    private String methodName = "userCheckIn";
+}

+ 0 - 13
src/main/java/org/example/Main.java

@@ -1,13 +0,0 @@
-package org.example;
-
-import org.apache.commons.io.FileUtils;
-
-import java.io.File;
-
-public class Main {
-    public static void main(String[] args) {
-        var files = FileUtils.listFiles(new File("."), null, false);
-        System.out.println(files);
-        System.out.println("hello");
-    }
-}

+ 129 - 0
src/main/java/org/example/RsaUtil.java

@@ -0,0 +1,129 @@
+package org.example;
+
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.security.Key;
+import java.security.KeyFactory;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.security.spec.X509EncodedKeySpec;
+
+import javax.crypto.Cipher;
+
+
+public class RsaUtil { /** */
+    /**
+     * 加密算法RSA
+     */
+    public static final String RSA = "RSA";
+    /**
+     * RSA最大加密明文大小
+     */
+    private static final int MAX_ENCRYPT_BLOCK = 117;
+    /**
+     * RSA最大解密密文大小
+     */
+    private static final int MAX_DECRYPT_BLOCK = 128;
+
+    /**
+     * <p>
+     * 公钥加密
+     * </p>
+     *
+     * @param data      源数据
+     * @param publicKey 公钥(BASE64编码)
+     * @return
+     * @throws Exception
+     */
+    public static byte[] encryptByPublicKey(byte[] data, String publicKey)
+            throws Exception {
+        byte[] keyBytes = new BASE64Decoder().decodeBuffer(publicKey);
+        X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
+        KeyFactory keyFactory = KeyFactory.getInstance(RSA);
+        Key publicK = keyFactory.generatePublic(x509KeySpec);
+        // 对数据加密
+        Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
+        cipher.init(Cipher.ENCRYPT_MODE, publicK);
+        int inputLen = data.length;
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        int offSet = 0;
+        byte[] cache;
+        int i = 0;
+        // 对数据分段加密
+        while (inputLen - offSet > 0) {
+            if (inputLen - offSet > MAX_ENCRYPT_BLOCK) {
+                cache = cipher.doFinal(data, offSet, MAX_ENCRYPT_BLOCK);
+            } else {
+                cache = cipher.doFinal(data, offSet, inputLen - offSet);
+            }
+            out.write(cache, 0, cache.length);
+            i++;
+            offSet = i * MAX_ENCRYPT_BLOCK;
+        }
+        byte[] encryptedData = out.toByteArray();
+        out.close();
+        return encryptedData;
+    }
+
+    /**
+     * <P>
+     * 私钥解密
+     * </p>
+     *
+     * @param encryptedData 已加密数据
+     * @param privateKey    私钥(BASE64编码)
+     * @return
+     * @throws Exception
+     */
+    public static byte[] decryptByPrivateKey(byte[] encryptedData, String privateKey)
+            throws Exception {
+        byte[] keyBytes = new BASE64Decoder().decodeBuffer(privateKey);
+        PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
+        KeyFactory keyFactory = KeyFactory.getInstance(RSA);
+        Key privateK = keyFactory.generatePrivate(pkcs8KeySpec);
+        Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
+        cipher.init(Cipher.DECRYPT_MODE, privateK);
+        int inputLen = encryptedData.length;
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        int offSet = 0;
+        byte[] cache;
+        int i = 0;
+        // 对数据分段解密
+        while (inputLen - offSet > 0) {
+            if (inputLen - offSet > MAX_DECRYPT_BLOCK) {
+                cache = cipher.doFinal(encryptedData, offSet, MAX_DECRYPT_BLOCK);
+            } else {
+                cache = cipher.doFinal(encryptedData, offSet, inputLen - offSet);
+            }
+            out.write(cache, 0, cache.length);
+            i++;
+            offSet = i * MAX_DECRYPT_BLOCK;
+        }
+        byte[] decryptedData = out.toByteArray();
+        out.close();
+        return decryptedData;
+    }
+
+    public static String getKeyString(InputStream in) {
+        try {
+            BufferedReader br = new BufferedReader(new InputStreamReader(in));
+            String readLine = null;
+            StringBuilder sb = new StringBuilder();
+            while ((readLine = br.readLine()) != null) {
+                if (readLine.charAt(0) == '-') {
+                    continue;
+                } else {
+                    sb.append(readLine);
+                    sb.append('\r');
+                }
+            }
+            return sb.toString();
+        } catch (Exception e) {
+            e.printStackTrace();
+            return "";
+        }
+    }
+}
+