[FIX] Исправления работоспособности клиента

This commit is contained in:
Gravit 2019-12-12 06:04:52 +07:00
parent 5e27db127a
commit 4dcc1443f6
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
5 changed files with 10 additions and 36 deletions

View file

@ -448,7 +448,6 @@ public static void main(String... args) throws Throwable {
EnvHelper.checkDangerousParams();
JVMHelper.checkStackTrace(ClientLauncher.class);
LogHelper.printVersion("Client Launcher");
//System.setSecurityManager(new ClientSecurityManager());
engine.readKeys();
HWIDProvider.registerHWIDs();
LauncherGuardManager.initGuard(true);

View file

@ -1,29 +0,0 @@
package pro.gravit.launcher.client;
import java.security.Permission;
public class ClientSecurityManager extends SecurityManager {
@Override
public void checkPermission(Permission perm)
{
String permName = perm.getName();
if(permName == null) return;
if (permName.startsWith("exitVM"))
{
Class<?>[] classContexts = getClassContext();
String callingClass = classContexts.length > 3 ? classContexts[4].getName() : "none";
if (!(callingClass.startsWith("pro.gravit.")))
{
throw new ExitTrappedException();
}
}
}
@Override
public void checkPermission(Permission perm, Object context) {
}
public static class ExitTrappedException extends SecurityException {
private static final long serialVersionUID = 6929785890434102330L;
}
}

View file

@ -82,7 +82,7 @@ public void openAsync(Runnable onConnect) {
new WebSocketClientHandler(
WebSocketClientHandshakerFactory.newHandshaker(
uri, WebSocketVersion.V13, null, false, EmptyHttpHeaders.INSTANCE, 12800000), this);
ChannelFuture future = bootstrap.connect();
ChannelFuture future = bootstrap.connect(uri.getHost(), port);
future.addListener((e) -> {
ch = future.channel();
webSocketClientHandler.handshakeFuture().addListener((e1) -> onConnect.run());

View file

@ -40,7 +40,7 @@ public enum CheckMode {
}
public interface CertificateChecker {
void check(X509Certificate cert, X509Certificate signer) throws SecurityException;
void check(X509Certificate cert, X509Certificate signer, int number) throws SecurityException;
}
public void checkCertificate(X509Certificate[] certs, CertificateChecker checker) throws CertificateException, NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
@ -61,7 +61,7 @@ public void checkCertificate(X509Certificate[] certs, CertificateChecker checker
throw new CertificateException(String.format("Certificate %s is not signed by a trusted signer", cert.getSubjectDN().getName()));
}
}
checker.check(cert, signer);
checker.check(cert, signer, i);
}
Collections.addAll(trustCache, certs);
}
@ -108,11 +108,11 @@ public void isCertificateCodeSign(X509Certificate certificate)
}
public void isCertificateCA(X509Certificate certificate)
{
if(certificate.getBasicConstraints() <= 0) throw new SecurityException("This certificate not CA");
if(certificate.getBasicConstraints() < 0) throw new SecurityException("This certificate not CA");
}
public void stdCertificateChecker(X509Certificate cert, X509Certificate signer)
public void stdCertificateChecker(X509Certificate cert, X509Certificate signer, int number)
{
if(signer == null)
if(number == 0)
isCertificateCodeSign(cert);
else
isCertificateCA(cert);

View file

@ -46,6 +46,10 @@ public JsonElement serialize(R src, Type typeOfSrc, JsonSerializationContext con
if (classPath == null && src instanceof TypeSerializeInterface) {
classPath = ((TypeSerializeInterface) src).getType();
}
if(classPath == null)
{
LogHelper.warning("Class %s type null", src.getClass());
}
jo.add(PROP_NAME, new JsonPrimitive(classPath));
return jo;