diff --git a/pom.xml b/pom.xml index d992128..9f5c3a6 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.manevolent ts3j - 1.0.2 + 1.0.3 1.8 diff --git a/src/main/java/com/github/manevolent/ts3j/license/LicenseUseType.java b/src/main/java/com/github/manevolent/ts3j/license/LicenseUseType.java index a77971f..638ff1b 100644 --- a/src/main/java/com/github/manevolent/ts3j/license/LicenseUseType.java +++ b/src/main/java/com/github/manevolent/ts3j/license/LicenseUseType.java @@ -3,6 +3,7 @@ package com.github.manevolent.ts3j.license; public enum LicenseUseType { INTERMEDIATE(0, IntermediateLicenseUse.class), SERVER(2, ServerLicenseUse.class), + TS5SERVER(8, Ts5ServerLicenseUse.class), EPHEMERAL(32, EphemeralLicenseUse.class) ; diff --git a/src/main/java/com/github/manevolent/ts3j/license/Ts5ServerLicenseUse.java b/src/main/java/com/github/manevolent/ts3j/license/Ts5ServerLicenseUse.java new file mode 100644 index 0000000..ba2d028 --- /dev/null +++ b/src/main/java/com/github/manevolent/ts3j/license/Ts5ServerLicenseUse.java @@ -0,0 +1,75 @@ +package com.github.manevolent.ts3j.license; + +import com.github.manevolent.ts3j.enums.LicenseType; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; + +public class Ts5ServerLicenseUse extends LicenseUse { + private byte type; + private List properties; + + public Ts5ServerLicenseUse() { + super(); + properties = new ArrayList<>(); + } + + @Override + public int getSize() { + int propertiesSize = 1; // first byte is property count + for (byte[] property : properties) { + propertiesSize += property.length + 1; // + 1 because the first byte is always the length of the property + } + return 1 + 4 + propertiesSize + 1; + } + + @Override + public LicenseUseType getUseType() { + return LicenseUseType.TS5SERVER; + } + + @Override + public ByteBuffer write(ByteBuffer buffer) { + buffer.put(type); + + buffer.put((byte) properties.size()); + for (byte[] property : properties) { + buffer.put((byte) property.length); + buffer.put(property); + } + + return buffer; + } + + @Override + public ByteBuffer read(ByteBuffer buffer) { + type = buffer.get(); + int propertyCount = buffer.get(); + + for (int i = 0; i < propertyCount; i++) { + int propertyLength = buffer.get(); + byte[] propertyBytes = new byte[propertyLength]; + buffer.get(propertyBytes); + properties.add(propertyBytes); + } + + return buffer; + } + + public List getProperties() { + return properties; + } + + public LicenseType getLicenseType() { + return LicenseType.fromId(type); + } + + public void setType(byte type) { + this.type = type; + } + + public byte getType() { + return type; + } +} diff --git a/src/main/java/com/github/manevolent/ts3j/util/Ts3Crypt.java b/src/main/java/com/github/manevolent/ts3j/util/Ts3Crypt.java index 7929424..bddd882 100644 --- a/src/main/java/com/github/manevolent/ts3j/util/Ts3Crypt.java +++ b/src/main/java/com/github/manevolent/ts3j/util/Ts3Crypt.java @@ -258,9 +258,9 @@ public final class Ts3Crypt { try { byte[] dataArray = new DERSequence(new ASN1Encodable[]{ new DERBitString(new byte[]{0b0000_0000}, 7), - new DERInteger(32), - new DERInteger(publicKey.getAffineXCoord().toBigInteger()), - new DERInteger(publicKey.getAffineYCoord().toBigInteger()) + new ASN1Integer(32), + new ASN1Integer(publicKey.getAffineXCoord().toBigInteger()), + new ASN1Integer(publicKey.getAffineYCoord().toBigInteger()) }).getEncoded(); return dataArray; diff --git a/src/test/java/com/github/manevolent/ts3j/LicenseDerivationTest.java b/src/test/java/com/github/manevolent/ts3j/LicenseDerivationTest.java index d0dcfdf..06a1074 100644 --- a/src/test/java/com/github/manevolent/ts3j/LicenseDerivationTest.java +++ b/src/test/java/com/github/manevolent/ts3j/LicenseDerivationTest.java @@ -63,6 +63,15 @@ public class LicenseDerivationTest extends TestCase { "/mxgAYAAAAAVGVhbVNwZWFrIFN5c3RlbXMgR21iSAAAWysE+/5ug1yKk4WiiWMNeB+" + "E+vQ5RmxglJLi8rW15UsgCnjyQAp5mwA=", "ZWGGM5QmRdl6AQOgBUZgOAVHcicsm/YPYR3EukrFiGE="); + + // TS5 License + check("AQCFoMHnK9xq4cnyi4UO6jlF3wpdR2CqK7HBWgAaIqgdaQAXCQWA" + + "GstsgAAAAQRUZWFtU3BlYWsgU3lzdGVtcyBHbWJIAACiHkpxdiDFyfywh8TxbuN5/" + + "nlykG4F41DGojMydnYKTAgXgP4AF9K7AAcDBgEBAAAAIBgCAFRlYW1TcGVhayBTeX" + + "N0ZW0gR21iSAAGAwEAAAAGAPROQHIID4UrzI3G4Mn4ObmKAri64LHxwt9onnb7IThdI" + + "Bej96cXpKBn", + "Zqnu3TCpswOYMFZgkMOMMuE/jK3WRiUGJVWdHeHEH7I="); + } }