2017-06-21 18:01:00 +03:00
|
|
|
package ru.bvn13.licenseserverjclient;
|
|
|
|
|
|
|
|
import lombok.Getter;
|
2017-06-22 14:02:38 +03:00
|
|
|
import ru.bvn13.licenseserverjclient.soap.*;
|
2017-06-21 18:01:00 +03:00
|
|
|
|
2017-06-22 14:02:38 +03:00
|
|
|
import javax.xml.bind.JAXBElement;
|
2017-06-21 18:01:00 +03:00
|
|
|
import javax.xml.namespace.QName;
|
|
|
|
import javax.xml.ws.Service;
|
2017-06-22 14:37:46 +03:00
|
|
|
import javax.xml.ws.WebServiceException;
|
2017-06-22 14:02:38 +03:00
|
|
|
import javax.xml.ws.WebServiceRef;
|
2017-06-21 18:01:00 +03:00
|
|
|
import java.net.MalformedURLException;
|
|
|
|
import java.net.URL;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by bvn13 on 21.06.2017.
|
|
|
|
*/
|
|
|
|
public class LicenseChecker {
|
|
|
|
|
|
|
|
@Getter
|
|
|
|
private String clientId;
|
|
|
|
|
2019-01-24 07:00:21 +03:00
|
|
|
//@WebServiceRef(wsdlLocation = "https://licenseserverj.cf/ws/checkLicense?WSDL")
|
|
|
|
//private CheckLicenseWSService service;
|
2017-06-22 14:02:38 +03:00
|
|
|
|
2017-06-21 18:01:00 +03:00
|
|
|
public LicenseChecker(String clientId) {
|
|
|
|
this.clientId = clientId;
|
|
|
|
}
|
|
|
|
|
2019-01-24 07:00:21 +03:00
|
|
|
public CheckClientLicenseResponse.Response checkLicense(String properties, boolean useHttps) throws Exception {
|
2017-06-21 18:01:00 +03:00
|
|
|
|
2017-06-23 12:18:00 +03:00
|
|
|
// try {
|
2019-01-24 07:00:21 +03:00
|
|
|
URL url = new URL(String.format("http%s://licenseserverj.cf/ws/checkLicense?WSDL", (useHttps ? "s" : "")));
|
2017-06-21 18:01:00 +03:00
|
|
|
|
2017-06-22 14:40:11 +03:00
|
|
|
QName qname = new QName("http://checkLicenseJ.bvn13.ru", "CheckLicenseWSService");
|
2017-06-22 14:02:38 +03:00
|
|
|
|
2017-06-22 14:40:11 +03:00
|
|
|
Service service = Service.create(url, qname);
|
|
|
|
|
|
|
|
CheckLicenseWS checkLicenseWS = service.getPort(CheckLicenseWS.class);
|
2017-06-21 18:01:00 +03:00
|
|
|
|
2017-06-22 14:40:11 +03:00
|
|
|
CheckClientLicense.Request params = new CheckClientLicense.Request();
|
|
|
|
params.setClientId(clientId);
|
|
|
|
params.setProperties(properties);
|
2017-06-25 00:07:29 +03:00
|
|
|
params.setSystemId(SystemID.encode(SystemID.getSystemID()));
|
2017-06-21 18:01:00 +03:00
|
|
|
|
2017-06-22 14:40:11 +03:00
|
|
|
CheckClientLicenseResponse.Response result = checkLicenseWS.checkClientLicense(params);
|
2017-06-21 18:01:00 +03:00
|
|
|
|
2017-06-22 14:40:11 +03:00
|
|
|
return result;
|
2017-06-23 12:18:00 +03:00
|
|
|
/*
|
2017-06-22 14:40:11 +03:00
|
|
|
} catch (MalformedURLException e) {
|
|
|
|
CheckClientLicenseResponse.Response result = new CheckClientLicenseResponse.Response();
|
|
|
|
result.setClientId(this.clientId);
|
|
|
|
result.setProperties("error");
|
|
|
|
result.setValid(false);
|
2017-06-21 18:01:00 +03:00
|
|
|
|
2017-06-22 14:40:11 +03:00
|
|
|
e.printStackTrace();
|
|
|
|
return result;
|
|
|
|
}
|
2017-06-23 12:18:00 +03:00
|
|
|
*/
|
2017-06-21 18:01:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|