handle ts5/6 license correctly
allows joining of a ts6 beta server
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.github.manevolent</groupId>
|
||||
<artifactId>ts3j</artifactId>
|
||||
<version>1.0.2</version>
|
||||
<version>1.0.3</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
|
||||
@@ -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)
|
||||
;
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
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<byte[]> 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.SERVER;
|
||||
}
|
||||
|
||||
@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<byte[]> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public LicenseType getLicenseType() {
|
||||
return LicenseType.fromId(type);
|
||||
}
|
||||
|
||||
public void setType(byte type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public byte getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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=");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user