implemented simple license checker

master
Vyacheslav N. Boyko 2017-06-21 18:01:00 +03:00
parent 66f814da31
commit 33d6f40700
10 changed files with 840 additions and 1 deletions

1
generate.cmd 100644
View File

@ -0,0 +1 @@
wsimport -s "src/main/java" -d "target/classes" -p "ru.bvn13.licenseserverjclient.soap" -keep -verbose http://licenseserverj.cf/ws/checkLicense?WSDL

106
pom.xml
View File

@ -6,7 +6,111 @@
<groupId>ru.bvn13</groupId>
<artifactId>licenseserverjclient</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.0</version>
<name>LicenseServerJClient</name>
<description>LicenseServerJ client</description>
<url>https://github.com/bvn13/LicenseServerJClient</url>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>owner</id>
<name>Vyacheslav Boyko</name>
<email>mail4bvn@gmail.com</email>
<timezone>UTC+3</timezone>
</developer>
</developers>
<properties>
<java.version>1.8</java.version>
<github.global.server>github</github.global.server>
<github.maven-plugin>0.12</github.maven-plugin>
<!-- <github.global.oauth2Token>${env.GITHUB_OAUTH_TOKEN}</github.global.oauth2Token> -->
<site.path>https://github.com/bvn13/LicenseServerJClient</site.path>
</properties>
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Temporary Staging Repository</name>
<url>file://${project.build.directory}/mvn-repo</url>
</repository>
</distributionManagement>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.16</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<altDeploymentRepository>internal.repo::default::file://${project.build.directory}/mvn-repo</altDeploymentRepository>
</configuration>
</plugin>
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>${github.maven-plugin}</version>
<configuration>
<message>Maven artifacts for ${project.version}</message>
<noJekyll>true</noJekyll>
<outputDirectory>${project.build.directory}/mvn-repo</outputDirectory>
<branch>refs/heads/mvn-repo</branch>
<includes><include>**/*</include></includes>
<repositoryName>LicenseServerJClient</repositoryName>
<repositoryOwner>bvn13</repositoryOwner>
</configuration>
<executions>
<execution>
<goals>
<goal>site</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,50 @@
package ru.bvn13.licenseserverjclient;
import lombok.Getter;
import ru.bvn13.licenseserverjclient.soap.CheckLicense;
import ru.bvn13.licenseserverjclient.soap.CheckLicenseJ;
import ru.bvn13.licenseserverjclient.soap.CheckLicenseResponse;
import ru.bvn13.licenseserverjclient.soap.CheckLicenseWSService;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import java.net.MalformedURLException;
import java.net.URL;
/**
* Created by bvn13 on 21.06.2017.
*/
public class LicenseChecker {
@Getter
private String clientId;
public LicenseChecker(String clientId) {
this.clientId = clientId;
}
public Boolean checkLicense(String properties) {
URL url = null;
try {
new URL("http://licenseserverj.cf/ws/checkLicense?WSDL");
} catch (MalformedURLException e) {
e.printStackTrace();
return false;
}
QName qname = new QName("http://checkLicenseJ.bvn13.ru", "checkLicense");
CheckLicenseWSService service = (CheckLicenseWSService) CheckLicenseWSService.create(url, qname);
CheckLicenseJ proxy = service.getSOAPOverHTTP();
CheckLicense params = new CheckLicense();
params.getArg0().setClientId(clientId);
params.getArg0().setProperties(properties);
CheckLicenseResponse result = (CheckLicenseResponse) proxy.checkLicense(params);
return result.getReturn().isIsValid();
}
}

View File

@ -0,0 +1,155 @@
package ru.bvn13.licenseserverjclient.soap;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for checkLicense complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="checkLicense">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="arg0" minOccurs="0">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="clientId" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="properties" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "checkLicense", propOrder = {
"arg0"
})
public class CheckLicense {
protected CheckLicense.Arg0 arg0;
/**
* Gets the value of the arg0 property.
*
* @return
* possible object is
* {@link CheckLicense.Arg0 }
*
*/
public CheckLicense.Arg0 getArg0() {
return arg0;
}
/**
* Sets the value of the arg0 property.
*
* @param value
* allowed object is
* {@link CheckLicense.Arg0 }
*
*/
public void setArg0(CheckLicense.Arg0 value) {
this.arg0 = value;
}
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="clientId" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="properties" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"clientId",
"properties"
})
public static class Arg0 {
@XmlElement(required = true)
protected String clientId;
@XmlElement(required = true)
protected String properties;
/**
* Gets the value of the clientId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getClientId() {
return clientId;
}
/**
* Sets the value of the clientId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setClientId(String value) {
this.clientId = value;
}
/**
* Gets the value of the properties property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getProperties() {
return properties;
}
/**
* Sets the value of the properties property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setProperties(String value) {
this.properties = value;
}
}
}

View File

@ -0,0 +1,38 @@
package ru.bvn13.licenseserverjclient.soap;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*
*/
@WebService(name = "checkLicenseJ", targetNamespace = "http://checkLicenseJ.bvn13.ru")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso({
ObjectFactory.class
})
public interface CheckLicenseJ {
/**
*
* @param parameters
* @return
* returns java.lang.Object
*/
@WebMethod
@WebResult(name = "checkLicenseResponse", targetNamespace = "http://checkLicenseJ.bvn13.ru", partName = "parameters")
public Object checkLicense(
@WebParam(name = "checkLicense", targetNamespace = "http://checkLicenseJ.bvn13.ru", partName = "parameters")
CheckLicense parameters);
}

View File

@ -0,0 +1,92 @@
package ru.bvn13.licenseserverjclient.soap;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="clientId" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="properties" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"clientId",
"properties"
})
@XmlRootElement(name = "checkLicenseRequest")
public class CheckLicenseRequest {
@XmlElement(required = true)
protected String clientId;
@XmlElement(required = true)
protected String properties;
/**
* Gets the value of the clientId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getClientId() {
return clientId;
}
/**
* Sets the value of the clientId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setClientId(String value) {
this.clientId = value;
}
/**
* Gets the value of the properties property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getProperties() {
return properties;
}
/**
* Sets the value of the properties property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setProperties(String value) {
this.properties = value;
}
}

View File

@ -0,0 +1,208 @@
package ru.bvn13.licenseserverjclient.soap;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;
/**
* <p>Java class for checkLicenseResponse complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="checkLicenseResponse">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="return" minOccurs="0">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="clientId" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="date" type="{http://www.w3.org/2001/XMLSchema}date"/>
* &lt;element name="isValid" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* &lt;element name="properties" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "checkLicenseResponse", propOrder = {
"_return"
})
public class CheckLicenseResponse {
@XmlElement(name = "return")
protected CheckLicenseResponse.Return _return;
/**
* Gets the value of the return property.
*
* @return
* possible object is
* {@link CheckLicenseResponse.Return }
*
*/
public CheckLicenseResponse.Return getReturn() {
return _return;
}
/**
* Sets the value of the return property.
*
* @param value
* allowed object is
* {@link CheckLicenseResponse.Return }
*
*/
public void setReturn(CheckLicenseResponse.Return value) {
this._return = value;
}
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="clientId" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="date" type="{http://www.w3.org/2001/XMLSchema}date"/>
* &lt;element name="isValid" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* &lt;element name="properties" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"clientId",
"date",
"isValid",
"properties"
})
public static class Return {
@XmlElement(required = true)
protected String clientId;
@XmlElement(required = true)
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar date;
protected boolean isValid;
@XmlElement(required = true)
protected String properties;
/**
* Gets the value of the clientId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getClientId() {
return clientId;
}
/**
* Sets the value of the clientId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setClientId(String value) {
this.clientId = value;
}
/**
* Gets the value of the date property.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getDate() {
return date;
}
/**
* Sets the value of the date property.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setDate(XMLGregorianCalendar value) {
this.date = value;
}
/**
* Gets the value of the isValid property.
*
*/
public boolean isIsValid() {
return isValid;
}
/**
* Sets the value of the isValid property.
*
*/
public void setIsValid(boolean value) {
this.isValid = value;
}
/**
* Gets the value of the properties property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getProperties() {
return properties;
}
/**
* Sets the value of the properties property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setProperties(String value) {
this.properties = value;
}
}
}

View File

@ -0,0 +1,94 @@
package ru.bvn13.licenseserverjclient.soap;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*
*/
@WebServiceClient(name = "CheckLicenseWSService", targetNamespace = "http://checkLicenseJ.bvn13.ru", wsdlLocation = "http://licenseserverj.cf/ws/checkLicense?WSDL")
public class CheckLicenseWSService
extends Service
{
private final static URL CHECKLICENSEWSSERVICE_WSDL_LOCATION;
private final static WebServiceException CHECKLICENSEWSSERVICE_EXCEPTION;
private final static QName CHECKLICENSEWSSERVICE_QNAME = new QName("http://checkLicenseJ.bvn13.ru", "CheckLicenseWSService");
static {
URL url = null;
WebServiceException e = null;
try {
url = new URL("http://licenseserverj.cf/ws/checkLicense?WSDL");
} catch (MalformedURLException ex) {
e = new WebServiceException(ex);
}
CHECKLICENSEWSSERVICE_WSDL_LOCATION = url;
CHECKLICENSEWSSERVICE_EXCEPTION = e;
}
public CheckLicenseWSService() {
super(__getWsdlLocation(), CHECKLICENSEWSSERVICE_QNAME);
}
public CheckLicenseWSService(WebServiceFeature... features) {
super(__getWsdlLocation(), CHECKLICENSEWSSERVICE_QNAME, features);
}
public CheckLicenseWSService(URL wsdlLocation) {
super(wsdlLocation, CHECKLICENSEWSSERVICE_QNAME);
}
public CheckLicenseWSService(URL wsdlLocation, WebServiceFeature... features) {
super(wsdlLocation, CHECKLICENSEWSSERVICE_QNAME, features);
}
public CheckLicenseWSService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public CheckLicenseWSService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
super(wsdlLocation, serviceName, features);
}
/**
*
* @return
* returns CheckLicenseJ
*/
@WebEndpoint(name = "SOAPOverHTTP")
public CheckLicenseJ getSOAPOverHTTP() {
return super.getPort(new QName("http://checkLicenseJ.bvn13.ru", "SOAPOverHTTP"), CheckLicenseJ.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return
* returns CheckLicenseJ
*/
@WebEndpoint(name = "SOAPOverHTTP")
public CheckLicenseJ getSOAPOverHTTP(WebServiceFeature... features) {
return super.getPort(new QName("http://checkLicenseJ.bvn13.ru", "SOAPOverHTTP"), CheckLicenseJ.class, features);
}
private static URL __getWsdlLocation() {
if (CHECKLICENSEWSSERVICE_EXCEPTION!= null) {
throw CHECKLICENSEWSSERVICE_EXCEPTION;
}
return CHECKLICENSEWSSERVICE_WSDL_LOCATION;
}
}

View File

@ -0,0 +1,95 @@
package ru.bvn13.licenseserverjclient.soap;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the ru.bvn13.licenseserverjclient.soap package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
private final static QName _CheckLicense_QNAME = new QName("http://checkLicenseJ.bvn13.ru", "checkLicense");
private final static QName _CheckLicenseResponse_QNAME = new QName("http://checkLicenseJ.bvn13.ru", "checkLicenseResponse");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: ru.bvn13.licenseserverjclient.soap
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link CheckLicenseResponse }
*
*/
public CheckLicenseResponse createCheckLicenseResponse() {
return new CheckLicenseResponse();
}
/**
* Create an instance of {@link CheckLicense }
*
*/
public CheckLicense createCheckLicense() {
return new CheckLicense();
}
/**
* Create an instance of {@link CheckLicenseRequest }
*
*/
public CheckLicenseRequest createCheckLicenseRequest() {
return new CheckLicenseRequest();
}
/**
* Create an instance of {@link CheckLicenseResponse.Return }
*
*/
public CheckLicenseResponse.Return createCheckLicenseResponseReturn() {
return new CheckLicenseResponse.Return();
}
/**
* Create an instance of {@link CheckLicense.Arg0 }
*
*/
public CheckLicense.Arg0 createCheckLicenseArg0() {
return new CheckLicense.Arg0();
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link CheckLicense }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://checkLicenseJ.bvn13.ru", name = "checkLicense")
public JAXBElement<CheckLicense> createCheckLicense(CheckLicense value) {
return new JAXBElement<CheckLicense>(_CheckLicense_QNAME, CheckLicense.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link Object }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://checkLicenseJ.bvn13.ru", name = "checkLicenseResponse")
public JAXBElement<Object> createCheckLicenseResponse(Object value) {
return new JAXBElement<Object>(_CheckLicenseResponse_QNAME, Object.class, null, value);
}
}

View File

@ -0,0 +1,2 @@
@javax.xml.bind.annotation.XmlSchema(namespace = "http://checkLicenseJ.bvn13.ru")
package ru.bvn13.licenseserverjclient.soap;