├── README.md ├── data-ingestion-demo-war ├── src │ └── main │ │ ├── resources │ │ ├── validation.properties │ │ └── DemoSchema.xsd │ │ ├── webapp │ │ ├── WEB-INF │ │ │ ├── successFile.jsp │ │ │ ├── ok.jsp │ │ │ ├── error.jsp │ │ │ ├── file.jsp │ │ │ ├── errorData.jsp │ │ │ ├── web.xml │ │ │ └── mvc-dispatcher-servlet.xml │ │ ├── index.jsp │ │ └── fileUpload.html │ │ └── java │ │ └── com │ │ └── jason │ │ └── example │ │ ├── controller │ │ ├── DemoCache.java │ │ ├── DemoFileUploadController.java │ │ └── DemoSeekController.java │ │ └── model │ │ ├── package-info.java │ │ ├── Movie.java │ │ ├── Localized.java │ │ ├── ObjectInfos.java │ │ ├── ObjectFactory.java │ │ ├── Lang.java │ │ └── ObjectInfo.java ├── doc │ ├── Data_ingestion.docx │ └── demo.xml └── pom.xml ├── SpringPattern ├── guide.docx ├── src │ ├── main │ │ └── java │ │ │ ├── com │ │ │ └── jason │ │ │ │ └── pattern │ │ │ │ ├── ploicy │ │ │ │ ├── PolicyIF.java │ │ │ │ ├── Policy1.java │ │ │ │ ├── Policy2.java │ │ │ │ └── Policy3.java │ │ │ │ └── OperatorClass.java │ │ │ └── applicationContext.xml │ └── applicationContext.xml └── pom.xml └── java-license-jar ├── doc ├── java_license_guide.docx └── ~$va_license_guide.docx ├── src └── main │ ├── resources │ ├── certfile.cer │ ├── license.lic │ ├── PublicCerts.store │ ├── PrivateKeys.keystore │ ├── verifyparam.properties │ └── createparam.properties │ └── java │ └── zlicense │ ├── util │ ├── HardWareUtils.java │ ├── LicenseCheckModel.java │ └── ListNets.java │ ├── de │ └── schlichtherle │ │ ├── license │ │ ├── Policy.java.bak │ │ ├── CipherParam.java │ │ ├── LicenseContent.java.bak │ │ ├── LicenseNotary.java.bak │ │ ├── LicenseCreator.java │ │ ├── LicenseVerifier.java │ │ ├── LicenseContentException.java │ │ ├── DefaultCipherParam.java │ │ ├── LicenseParam.java │ │ ├── KeyStoreParam.java │ │ ├── IllegalPasswordException.java │ │ ├── LicenseNotaryException.java │ │ ├── NoLicenseInstalledException.java │ │ ├── DefaultKeyStoreParam.java │ │ ├── Policy.java │ │ ├── DefaultLicenseParam.java │ │ ├── LocalKeyStoreParam.java │ │ ├── AbstractKeyStoreParam.java │ │ ├── Resources.properties │ │ ├── CipherParam.java.bak │ │ ├── LicenseCreator.java.bak │ │ ├── Resources_de.properties │ │ ├── DefaultKeyStoreParam.java.bak │ │ ├── DefaultLicenseParam.java.bak │ │ ├── Resources.java │ │ ├── AbstractKeyStoreParam.java.bak │ │ ├── LicenseContentBeanInfo.java │ │ ├── PrivacyGuard.java │ │ ├── LicenseNotary.java │ │ ├── LicenseContent.java │ │ ├── LocalLicenseManager.java │ │ ├── PrivacyGuard.java.bak │ │ └── LicenseManager.java │ │ ├── xml │ │ ├── PersistenceService.java.bak │ │ ├── GenericCertificateNotLockedException.java │ │ ├── XMLConstants.java │ │ ├── GenericCertificateIntegrityException.java │ │ ├── PersistenceServiceException.java │ │ ├── GenericCertificateIsLockedException.java │ │ ├── package-info.java │ │ ├── PersistenceService.java │ │ └── GenericCertificate.java │ │ └── util │ │ └── ObfuscatedString.java │ ├── create │ ├── licenseCreateTest.java │ ├── LicenseManagerHolder.java │ └── CreateLicense.java │ └── verify │ ├── licenseVerifyTest.java │ ├── LicenseManagerHolder.java │ ├── RequestVerifyLicense.java │ └── VerifyLicense.java └── pom.xml /README.md: -------------------------------------------------------------------------------- 1 | # JavaSpringSurmmary 2 | JavaSpringSurmmary 3 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/resources/validation.properties: -------------------------------------------------------------------------------- 1 | valid.file= Please select a file! -------------------------------------------------------------------------------- /SpringPattern/guide.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingshauizh/JavaSpringSurmmary/HEAD/SpringPattern/guide.docx -------------------------------------------------------------------------------- /java-license-jar/doc/java_license_guide.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingshauizh/JavaSpringSurmmary/HEAD/java-license-jar/doc/java_license_guide.docx -------------------------------------------------------------------------------- /java-license-jar/doc/~$va_license_guide.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingshauizh/JavaSpringSurmmary/HEAD/java-license-jar/doc/~$va_license_guide.docx -------------------------------------------------------------------------------- /data-ingestion-demo-war/doc/Data_ingestion.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingshauizh/JavaSpringSurmmary/HEAD/data-ingestion-demo-war/doc/Data_ingestion.docx -------------------------------------------------------------------------------- /java-license-jar/src/main/resources/certfile.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingshauizh/JavaSpringSurmmary/HEAD/java-license-jar/src/main/resources/certfile.cer -------------------------------------------------------------------------------- /java-license-jar/src/main/resources/license.lic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingshauizh/JavaSpringSurmmary/HEAD/java-license-jar/src/main/resources/license.lic -------------------------------------------------------------------------------- /java-license-jar/src/main/resources/PublicCerts.store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingshauizh/JavaSpringSurmmary/HEAD/java-license-jar/src/main/resources/PublicCerts.store -------------------------------------------------------------------------------- /java-license-jar/src/main/resources/PrivateKeys.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingshauizh/JavaSpringSurmmary/HEAD/java-license-jar/src/main/resources/PrivateKeys.keystore -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/util/HardWareUtils.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingshauizh/JavaSpringSurmmary/HEAD/java-license-jar/src/main/java/zlicense/util/HardWareUtils.java -------------------------------------------------------------------------------- /SpringPattern/src/main/java/com/jason/pattern/ploicy/PolicyIF.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package com.jason.pattern.ploicy; 4 | 5 | public interface PolicyIF { 6 | public void excute(String parameter); 7 | } 8 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/Policy.java.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingshauizh/JavaSpringSurmmary/HEAD/java-license-jar/src/main/java/zlicense/de/schlichtherle/license/Policy.java.bak -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/CipherParam.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | public abstract interface CipherParam 4 | { 5 | public abstract String getKeyPwd(); 6 | } 7 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/LicenseContent.java.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingshauizh/JavaSpringSurmmary/HEAD/java-license-jar/src/main/java/zlicense/de/schlichtherle/license/LicenseContent.java.bak -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/LicenseNotary.java.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingshauizh/JavaSpringSurmmary/HEAD/java-license-jar/src/main/java/zlicense/de/schlichtherle/license/LicenseNotary.java.bak -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/xml/PersistenceService.java.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingshauizh/JavaSpringSurmmary/HEAD/java-license-jar/src/main/java/zlicense/de/schlichtherle/xml/PersistenceService.java.bak -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/xml/GenericCertificateNotLockedException.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.xml; 2 | 3 | public class GenericCertificateNotLockedException 4 | extends IllegalStateException 5 | {} 6 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/webapp/WEB-INF/successFile.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> 2 | 3 | 4 |

Spring MVC - Uploading a file..

5 | Your file is successfully uploaded. 6 | 7 | 8 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 |

Click here to download file

6 |
7 | 8 | 9 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/xml/XMLConstants.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.xml; 2 | 3 | abstract interface XMLConstants 4 | { 5 | public static final String XML_CHARSET = "UTF-8"; 6 | public static final int DEFAULT_BUFSIZE = 10240; 7 | } 8 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/xml/GenericCertificateIntegrityException.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.xml; 2 | 3 | import java.security.GeneralSecurityException; 4 | 5 | public class GenericCertificateIntegrityException 6 | extends GeneralSecurityException 7 | {} 8 | -------------------------------------------------------------------------------- /SpringPattern/src/main/java/com/jason/pattern/ploicy/Policy1.java: -------------------------------------------------------------------------------- 1 | package com.jason.pattern.ploicy; 2 | 3 | public class Policy1 implements PolicyIF { 4 | 5 | @Override 6 | public void excute(String parameter) { 7 | // TODO Auto-generated method stub 8 | System.out.println("Policy1 excute"); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /SpringPattern/src/main/java/com/jason/pattern/ploicy/Policy2.java: -------------------------------------------------------------------------------- 1 | package com.jason.pattern.ploicy; 2 | 3 | public class Policy2 implements PolicyIF { 4 | 5 | @Override 6 | public void excute(String parameter) { 7 | // TODO Auto-generated method stub 8 | System.out.println("Policy2 excute"); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /SpringPattern/src/main/java/com/jason/pattern/ploicy/Policy3.java: -------------------------------------------------------------------------------- 1 | package com.jason.pattern.ploicy; 2 | 3 | public class Policy3 implements PolicyIF { 4 | 5 | @Override 6 | public void excute(String parameter) { 7 | // TODO Auto-generated method stub 8 | System.out.println("Policy3 excute"); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /java-license-jar/src/main/resources/verifyparam.properties: -------------------------------------------------------------------------------- 1 | ##########common parameters########### 2 | #alias 3 | PUBLICALIAS=publiccert 4 | #STOREPWD 5 | STOREPWD=iptv1234 6 | #SUBJECT 7 | SUBJECT=bigdata 8 | #licPath 9 | licPath=C:/9exce/iodlicense/iodlicense.lic 10 | #pubPath 11 | pubPath=C:/9exce/iodlicense/iodPublicCerts.store -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/LicenseCreator.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | import java.rmi.Remote; 4 | 5 | public abstract interface LicenseCreator 6 | extends Remote 7 | { 8 | public abstract byte[] create(LicenseContent paramLicenseContent) 9 | throws Exception; 10 | } 11 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/LicenseVerifier.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | import java.rmi.Remote; 4 | 5 | public abstract interface LicenseVerifier 6 | extends Remote 7 | { 8 | public abstract LicenseContent verify(byte[] paramArrayOfByte) 9 | throws Exception; 10 | } 11 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/create/licenseCreateTest.java: -------------------------------------------------------------------------------- 1 | package zlicense.create; 2 | 3 | 4 | 5 | public class licenseCreateTest { 6 | public static void main(String[] args){ 7 | CreateLicense cLicense = new CreateLicense(); 8 | 9 | cLicense.setParam("C:/license/createparam.properties"); 10 | // 11 | cLicense.create(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/xml/PersistenceServiceException.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.xml; 2 | 3 | public class PersistenceServiceException 4 | extends Exception 5 | { 6 | public PersistenceServiceException(Throwable paramThrowable) 7 | { 8 | super(paramThrowable.getLocalizedMessage(), paramThrowable); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/webapp/fileUpload.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |

data Upload

5 |
6 | 7 | 8 |
9 | 10 |
11 | 12 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/webapp/WEB-INF/ok.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | export xml file successful!! 6 | 7 | 8 |

export xml file successful!!

9 | 10 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/webapp/WEB-INF/error.jsp: -------------------------------------------------------------------------------- 1 | <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 2 | 3 | 4 | 5 | 6 | ERROR 7 | 8 | 9 |

${message}

10 | 11 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/LicenseContentException.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | public class LicenseContentException 4 | extends Exception 5 | { 6 | public LicenseContentException(String paramString) 7 | { 8 | super(paramString); 9 | } 10 | 11 | public String getLocalizedMessage() 12 | { 13 | return Resources.getString(super.getMessage()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/verify/licenseVerifyTest.java: -------------------------------------------------------------------------------- 1 | package zlicense.verify; 2 | 3 | public class licenseVerifyTest { 4 | public static void main(String[] args){ 5 | VerifyLicense vLicense = new VerifyLicense(); 6 | try{ 7 | 8 | vLicense.setParam("C:/license/verifyparam.properties"); 9 | 10 | vLicense.verify(); 11 | } 12 | catch(Exception er){ 13 | er.printStackTrace(); 14 | } 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/DefaultCipherParam.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | public class DefaultCipherParam 4 | implements CipherParam 5 | { 6 | private final String keyPwd; 7 | 8 | public DefaultCipherParam(String paramString) 9 | { 10 | this.keyPwd = paramString; 11 | } 12 | 13 | public String getKeyPwd() 14 | { 15 | return this.keyPwd; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/LicenseParam.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | import java.util.prefs.Preferences; 4 | 5 | public abstract interface LicenseParam 6 | { 7 | public abstract String getSubject(); 8 | 9 | public abstract Preferences getPreferences(); 10 | 11 | public abstract KeyStoreParam getKeyStoreParam(); 12 | 13 | public abstract CipherParam getCipherParam(); 14 | } 15 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/KeyStoreParam.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | public abstract interface KeyStoreParam 7 | { 8 | public abstract InputStream getStream() 9 | throws IOException; 10 | 11 | public abstract String getAlias(); 12 | 13 | public abstract String getStorePwd(); 14 | 15 | public abstract String getKeyPwd(); 16 | } 17 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/java/com/jason/example/controller/DemoCache.java: -------------------------------------------------------------------------------- 1 | package com.jason.example.controller; 2 | 3 | import java.util.List; 4 | 5 | import com.jason.example.model.ObjectInfo; 6 | 7 | public class DemoCache { 8 | private static List infoList; 9 | 10 | public static List getInfoList() { 11 | return infoList; 12 | } 13 | 14 | public static void setInfoList(List infoList) { 15 | DemoCache.infoList = infoList; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/webapp/WEB-INF/file.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> 2 | 3 | 4 | 5 | 6 |

Spring MVC - Uploading a file..

7 | 8 | 9 | Upload your file please: 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/xml/GenericCertificateIsLockedException.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.xml; 2 | 3 | import java.beans.PropertyChangeEvent; 4 | import java.beans.PropertyVetoException; 5 | 6 | public class GenericCertificateIsLockedException 7 | extends PropertyVetoException 8 | { 9 | public GenericCertificateIsLockedException(PropertyChangeEvent paramPropertyChangeEvent) 10 | { 11 | super(paramPropertyChangeEvent.getPropertyName(), paramPropertyChangeEvent); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/xml/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2012 Schlichtherle IT Services 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | */ 9 | /** Provides XML services like encoding/decoding of persistent objects. */ 10 | package zlicense.de.schlichtherle.xml; 11 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/IllegalPasswordException.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | import zlicense.de.schlichtherle.util.ObfuscatedString; 4 | 5 | public class IllegalPasswordException 6 | extends IllegalArgumentException 7 | { 8 | public String getLocalizedMessage() 9 | { 10 | return Resources.getString(new ObfuscatedString(new long[] { -6087108248892165543L, 4668112285741627657L, -1028382439244694792L, -1679939343705678708L }).toString()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/java/com/jason/example/model/package-info.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2015.02.03 at 03:41:20 PM CST 6 | // 7 | 8 | @javax.xml.bind.annotation.XmlSchema(namespace = "http://www.example.org/DemoSchema", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) 9 | package com.jason.example.model; 10 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/LicenseNotaryException.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | import java.security.GeneralSecurityException; 4 | 5 | public class LicenseNotaryException 6 | extends GeneralSecurityException 7 | { 8 | private String alias; 9 | 10 | public LicenseNotaryException(String paramString1, String paramString2) 11 | { 12 | super(paramString1); 13 | this.alias = paramString2; 14 | } 15 | 16 | public String getLocalizedMessage() 17 | { 18 | return Resources.getString(super.getMessage(), this.alias); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/create/LicenseManagerHolder.java: -------------------------------------------------------------------------------- 1 | package zlicense.create; 2 | import zlicense.de.schlichtherle.license.LicenseManager; 3 | import zlicense.de.schlichtherle.license.LicenseParam; 4 | 5 | /** 6 | * LicenseManager 7 | * @author melina 8 | */ 9 | public class LicenseManagerHolder { 10 | 11 | private static LicenseManager licenseManager; 12 | 13 | public static synchronized LicenseManager getLicenseManager(LicenseParam licenseParams) { 14 | if (licenseManager == null) { 15 | licenseManager = new LicenseManager(licenseParams); 16 | } 17 | return licenseManager; 18 | } 19 | } -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/verify/LicenseManagerHolder.java: -------------------------------------------------------------------------------- 1 | package zlicense.verify; 2 | import zlicense.de.schlichtherle.license.LicenseManager; 3 | import zlicense.de.schlichtherle.license.LicenseParam; 4 | 5 | /** 6 | * LicenseManager������ 7 | * @author melina 8 | */ 9 | public class LicenseManagerHolder { 10 | 11 | private static LicenseManager licenseManager; 12 | 13 | public static synchronized LicenseManager getLicenseManager(LicenseParam licenseParams) { 14 | if (licenseManager == null) { 15 | licenseManager = new LicenseManager(licenseParams); 16 | } 17 | return licenseManager; 18 | } 19 | } -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/webapp/WEB-INF/errorData.jsp: -------------------------------------------------------------------------------- 1 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 2 | 3 | 4 | 5 | 6 | Your data exist some error! 7 | 8 | 9 |

Your data exist some error,you should modify them!!!

10 | <%-- ${msg} --%> 11 | 12 |
    13 | 14 |
  • ${listValue.getMoreInfo()}
  • 15 |
    16 |
17 |
18 | 19 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/NoLicenseInstalledException.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | import zlicense.de.schlichtherle.util.ObfuscatedString; 4 | 5 | public class NoLicenseInstalledException 6 | extends Exception 7 | { 8 | private static final String EXC_NO_LICENSE_INSTALLED = new ObfuscatedString(new long[] { 5636850220590995934L, -798521115123526970L, 3054112192777193179L, 881750348384376277L }).toString(); 9 | 10 | public NoLicenseInstalledException(String paramString) 11 | { 12 | super(paramString); 13 | } 14 | 15 | public String getLocalizedMessage() 16 | { 17 | return Resources.getString(EXC_NO_LICENSE_INSTALLED, super.getMessage()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /java-license-jar/src/main/resources/createparam.properties: -------------------------------------------------------------------------------- 1 | ##########common parameters########### 2 | #alias 3 | PRIVATEALIAS=privateKeys 4 | #key(important!) 5 | KEYPWD=iptv1234 6 | #STOREPWD 7 | STOREPWD=iptv1234 8 | #SUBJECT 9 | SUBJECT=bigdata 10 | #licPath 11 | licPath=C:/9exce/iodlicense/iodlicense.lic 12 | #priPath 13 | priPath=C:/9exce/iodlicense/iodPrivateKeys.keystore 14 | ##########license content########### 15 | #issuedTime 16 | issuedTime=2015-03-09 17 | #notBeforeTime 18 | notBefore=2015-03-09 19 | #notAfterTime 20 | notAfter=2016-03-20 21 | #ip address 22 | ipAddress=150.236.220.200 23 | #mac address 24 | macAddress=00-0C-29-8B-37-A4 25 | #consumerType 26 | consumerType=user 27 | #ConsumerAmount 28 | consumerAmount=1 29 | #info 30 | info=this is a license -------------------------------------------------------------------------------- /java-license-jar/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | java-license-jar 4 | java-license-jar 5 | jar 6 | 1.0 7 | java-license-jar 8 | http://maven.apache.org 9 | 10 | 11 | commons-codec 12 | commons-codec 13 | 1.7 14 | 15 | 16 | commons-io 17 | commons-io 18 | 2.4 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/DefaultKeyStoreParam.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | public class DefaultKeyStoreParam 4 | extends AbstractKeyStoreParam 5 | { 6 | private final String alias; 7 | private final String storePwd; 8 | private final String keyPwd; 9 | 10 | public DefaultKeyStoreParam(Class paramClass, String paramString1, String paramString2, String paramString3, String paramString4) 11 | { 12 | super(paramClass, paramString1); 13 | this.alias = paramString2; 14 | this.storePwd = paramString3; 15 | this.keyPwd = paramString4; 16 | } 17 | 18 | public String getAlias() 19 | { 20 | return this.alias; 21 | } 22 | 23 | public String getStorePwd() 24 | { 25 | return this.storePwd; 26 | } 27 | 28 | public String getKeyPwd() 29 | { 30 | return this.keyPwd; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SpringPattern/src/main/java/com/jason/pattern/OperatorClass.java: -------------------------------------------------------------------------------- 1 | 2 | package com.jason.pattern; 3 | 4 | import java.util.List; 5 | 6 | import org.springframework.context.ApplicationContext; 7 | import org.springframework.context.support.ClassPathXmlApplicationContext; 8 | import com.jason.pattern.ploicy.*; 9 | public class OperatorClass { 10 | private List policyList; 11 | 12 | public List getPolicyList() { 13 | return policyList; 14 | } 15 | 16 | public void setPolicyList(List policyList) { 17 | this.policyList = policyList; 18 | } 19 | 20 | public static void main(String [] agrs){ 21 | ApplicationContext context = new ClassPathXmlApplicationContext("file:C:\\2task\\Code\\SpringAOP\\src\\applicationContext.xml"); 22 | OperatorClass operatorClass = (OperatorClass) context.getBean("operatorClass"); 23 | System.out.println("policyList.size " + operatorClass.getPolicyList().size()); 24 | for(int i=0;i 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 24 | 26 | 27 | -------------------------------------------------------------------------------- /SpringPattern/src/main/java/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 24 | 26 | 27 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | Archetype Created Web Application 7 | 8 | 9 | 10 | mvc-dispatcher 11 | 12 | org.springframework.web.servlet.DispatcherServlet 13 | 14 | 1 15 | 16 | 17 | 18 | mvc-dispatcher 19 | *.htm 20 | 21 | 22 | 23 | encodingFilter 24 | org.springframework.web.filter.CharacterEncodingFilter 25 | 26 | encoding 27 | UTF-8 28 | 29 | 30 | forceEncoding 31 | true 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/LocalKeyStoreParam.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | import java.io.InputStream; 4 | 5 | import zlicense.de.schlichtherle.license.KeyStoreParam; 6 | 7 | public class LocalKeyStoreParam 8 | implements KeyStoreParam { 9 | 10 | private String alias; 11 | private String keyPwd; 12 | private String storePwd; 13 | private InputStream stream; 14 | 15 | public LocalKeyStoreParam(String localAlias, String localKeyPwd, String localStorePwd, InputStream localStream) { 16 | setAlias(localAlias); 17 | setKeyPwd(localKeyPwd); 18 | setStorePwd(localStorePwd); 19 | setStream(localStream); 20 | } 21 | 22 | public String getAlias() { 23 | return alias; 24 | } 25 | 26 | public void setAlias(String alias) { 27 | this.alias = alias; 28 | } 29 | 30 | public String getKeyPwd() { 31 | return keyPwd; 32 | } 33 | 34 | public void setKeyPwd(String keyPwd) { 35 | this.keyPwd = keyPwd; 36 | } 37 | 38 | public String getStorePwd() { 39 | return storePwd; 40 | } 41 | 42 | public void setStorePwd(String storePwd) { 43 | this.storePwd = storePwd; 44 | } 45 | 46 | public InputStream getStream() { 47 | return stream; 48 | } 49 | 50 | public void setStream(InputStream stream) { 51 | this.stream = stream; 52 | } 53 | } -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/AbstractKeyStoreParam.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.FileNotFoundException; 5 | import java.io.IOException; 6 | import java.io.InputStream; 7 | import java.net.URL; 8 | 9 | public abstract class AbstractKeyStoreParam 10 | implements KeyStoreParam 11 | { 12 | private final Class clazz; 13 | private final String resource; 14 | 15 | protected AbstractKeyStoreParam(Class paramClass, String paramString) 16 | { 17 | this.clazz = paramClass; 18 | this.resource = paramString; 19 | } 20 | 21 | public InputStream getStream() 22 | throws IOException 23 | { 24 | InputStream localInputStream = this.clazz.getResourceAsStream(this.resource); 25 | localInputStream = new FileInputStream(this.resource);//zjs 26 | if (localInputStream == null) { 27 | throw new FileNotFoundException(this.resource); 28 | } 29 | return localInputStream; 30 | } 31 | 32 | public boolean equals(Object paramObject) 33 | { 34 | if (!(paramObject instanceof KeyStoreParam)) { 35 | return false; 36 | } 37 | AbstractKeyStoreParam localAbstractKeyStoreParam = (AbstractKeyStoreParam)paramObject; 38 | return (this.clazz.getResource(this.resource).equals(localAbstractKeyStoreParam.clazz.getResource(localAbstractKeyStoreParam.resource))) && (getAlias().equals(localAbstractKeyStoreParam.getAlias())); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 17 | 18 | 20 | 21 | 22 | 24 | 25 | 26 | /WEB-INF/ 27 | 28 | 29 | .jsp 30 | 31 | 32 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/Resources.properties: -------------------------------------------------------------------------------- 1 | 2 | fileFilter.description={0} License 3 | 4 | exc.noLicenseInstalled=There is no license certificate installed for {0}. 5 | 6 | exc.jceSetupError=It seems that the Java Cryptography Extension (JCE) is not installed or corrupted - please (re)install\! 7 | 8 | exc.consumerAmountIsNotPositive=License Consumer amount is not positive\! 9 | 10 | exc.consumerTypeIsNull=License Consumer type is null\! 11 | 12 | exc.licenseHasExpired=License Certificate has expired\! 13 | 14 | exc.licenseIsNotYetValid=License Certificate is not yet valid\! 15 | 16 | exc.issuedIsNull=License Issue date is null\! 17 | 18 | exc.issuerIsNull=License Issuer is null\! 19 | 20 | exc.holderIsNull=License Holder is null\! 21 | 22 | exc.invalidSubject=Invalid licensing subject\! 23 | 24 | exc.privateKeyOrPwdIsNotAllowed=For security reasons a client application is not allowed to provide private keys or passwords for private keys in a Java keystore\! 25 | 26 | exc.noKeyPwd=No password for key entry '{0}' provided\! 27 | 28 | exc.noCertificateEntry=Certificate or alias '{0}' does not exist in keystore\! 29 | 30 | exc.noKeyEntry=Private key or alias '{0}' does not exist in keystore\! 31 | 32 | exc.consumerTypeIsNotUser=License Consumer Type is not "User"\! 33 | 34 | exc.consumerAmountIsNotOne=License Consumer amount is not equal to one\! 35 | 36 | exc.policy.IllegalPwd=The password does not match the default policy\: At least six characters consisting of letters and digits\! 37 | 38 | user=Anonymous User 39 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/doc/demo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bf435848-a165-4361-a2ad-13c23fa0b3ff 6 | 20141211064023715.png 7 | 666 8 | 9 | 10 | en 11 | 3333 12 | 555 13 | 555 14 | 15 | 16 | 17 | 18 | 19 | bf435848-a165-4361-a2ad-13c23fa0b3 20 | 20141211064023715.png 21 | 140 22 | 23 | 24 | en 25 | Sintel_en 26 | Hero_en 27 | Hero_en 28 | 29 | 30 | zh 31 | Sintel_zh 32 | Hero_zh 33 | Hero_zh 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/CipherParam.java.bak: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2012 Schlichtherle IT Services 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | */ 9 | package de.schlichtherle.license; 10 | 11 | /** 12 | * Configures parameters for the PKCS-5 algorithm used to encrypt/decrypt a 13 | * compressed, signed {@link de.schlichtherle.xml.GenericCertificate}. 14 | * This interface is used by the {@link LicenseManager} to perform the 15 | * encryption/decyrption of license keys. 16 | *

17 | * Note: To protect your application against reverse engineering 18 | * and thus reduce the risk to compromise the privacy of your passwords, 19 | * it is highly recommended to obfuscate all JAR files which contain class 20 | * files that implement this interface with a tool like 21 | * ProGuard. 22 | * 23 | * @author Christian Schlichtherle 24 | * @version $Id$ 25 | */ 26 | public interface CipherParam { 27 | 28 | /** 29 | * Returns the password used to generate a secret key for 30 | * encryption/decryption of license keys. 31 | * - {@code null} is never returned. 32 | *

33 | * Note that the {@link Policy} class provides additional constraints 34 | * for the returned password. 35 | * 36 | * @see Policy#checkPwd(String) 37 | */ 38 | String getKeyPwd(); 39 | } 40 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/LicenseCreator.java.bak: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2012 Schlichtherle IT Services 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | */ 9 | package de.schlichtherle.license; 10 | 11 | import java.rmi.Remote; 12 | 13 | /** 14 | * Provides remote license creation services. 15 | * 16 | * @author Christian Schlichtherle 17 | * @version $Id$ 18 | */ 19 | public interface LicenseCreator extends Remote { 20 | 21 | /** 22 | * Initializes and validates the license content, creates a new signed 23 | * license certificate for it and compresses, encrypts and returns it 24 | * as a license key. 25 | *

26 | * As a side effect, the given license {@code content} may be initialized 27 | * with some reasonable defaults unless the respective properties have 28 | * already been set. 29 | * 30 | * @param content The license content 31 | * - may not be {@code null}. 32 | * 33 | * @return The license key 34 | * - {@code null} is never returned. 35 | * 36 | * @throws Exception An instance of a subclass of this class for various 37 | * reasons. 38 | * Note that you should always use 39 | * {@link Throwable#getLocalizedMessage()} to get a (possibly 40 | * localized) meaningful detail message. 41 | */ 42 | byte[] create(LicenseContent content) throws Exception; 43 | } 44 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/Resources_de.properties: -------------------------------------------------------------------------------- 1 | 2 | fileFilter.description=Lizenz f\u00FCr {0} 3 | 4 | exc.noLicenseInstalled=Es ist kein Lizenz-Zertifikat installiert f\u00FCr {0}. 5 | 6 | exc.jceSetupError=Es scheint, dass die Java Cryptogaphy Extension (JCE) nicht installiert oder defekt ist - bitte (re)installieren Sie sie\! 7 | 8 | exc.consumerAmountIsNotPositive=Lizenz-Verbraucheranzahl ist nicht positiv\! 9 | 10 | exc.consumerTypeIsNull=Lizenz-Verbrauchertyp ist null\! 11 | 12 | exc.licenseHasExpired=Lizenz-Zertifikat ist abgelaufen\! 13 | 14 | exc.licenseIsNotYetValid=Lizenz-Zertifikat ist noch nicht g\u00FCltig\! 15 | 16 | exc.issuedIsNull=Lizenz-Ausstellungsdatum ist null\! 17 | 18 | exc.issuerIsNull=Lizenz-Herausgeber ist null\! 19 | 20 | exc.holderIsNull=Lizenz-Inhaber ist null\! 21 | 22 | exc.invalidSubject=Ung\u00FCltiger Lizenzierungsgegenstand\! 23 | 24 | exc.privateKeyOrPwdIsNotAllowed=Aus Sicherheitsgr\u00FCnden ist es einer Kundenapplikation nicht erlaubt, private Schl\u00FCssel oder Passw\u00F6rter f\u00FCr private Schl\u00FCssel in einem Java keystore bereitzustellen\! 25 | 26 | exc.noKeyPwd=Kein Passwort f\u00FCr Schl\u00FCsseleintrag '{0}' angegeben\! 27 | 28 | exc.noCertificateEntry=Zertifikat oder Alias '{0}' existieren nicht im keystore\! 29 | 30 | exc.noKeyEntry=Privater Schl\u00FCssel oder Alias '{0}' existieren nicht im keystore\! 31 | 32 | exc.consumerTypeIsNotUser=Lizenz-Verbrauchertyp ist nicht "User"\! 33 | 34 | exc.consumerAmountIsNotOne=Lizenz-Verbraucheranzahl ist ungleich eins\! 35 | 36 | exc.policy.IllegalPwd=Das Pa\u00DFwort entspricht nicht der voreingestellten Richtlinie\: Mindestens sechs Zeichen bestehend aus Buchstaben und Ziffern\! 37 | 38 | user=Anonymer Benutzer 39 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/resources/DemoSchema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/DefaultKeyStoreParam.java.bak: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2012 Schlichtherle IT Services 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | */ 9 | package de.schlichtherle.license; 10 | 11 | /** 12 | * This is a convenience class implementing the {@link KeyStoreParam} interface. 13 | * 14 | * @author Christian Schlichtherle 15 | * @version $Id$ 16 | */ 17 | public class DefaultKeyStoreParam extends AbstractKeyStoreParam { 18 | 19 | private final String alias, storePwd, keyPwd; 20 | 21 | /** 22 | * Constructs a new instance. 23 | * 24 | * @param clazz Used to retrieve the classloader required to load the 25 | * keystore as a resource. 26 | * @param resource The resource identifier for the keystore 27 | * to be returned by {@link #getStream()}. 28 | * @param alias The alias for the key entry in the key store 29 | * to be returned by {@link #getAlias()}. 30 | * @param storePwd The key store password 31 | * to be returned by {@link #getStorePwd()}. 32 | * @param keyPwd The password for the private key in the key store entry 33 | * to be returned by {@link #getStorePwd()}. 34 | */ 35 | public DefaultKeyStoreParam( 36 | final Class clazz, 37 | final String resource, 38 | final String alias, 39 | final String storePwd, 40 | final String keyPwd) { 41 | super(clazz, resource); 42 | this.alias = alias; 43 | this.storePwd = storePwd; 44 | this.keyPwd = keyPwd; 45 | } 46 | 47 | public String getAlias() { 48 | return alias; 49 | } 50 | 51 | public String getStorePwd() { 52 | return storePwd; 53 | } 54 | 55 | public String getKeyPwd() { 56 | return keyPwd; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/java/com/jason/example/model/Movie.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2015.02.03 at 03:41:20 PM CST 6 | // 7 | 8 | 9 | package com.jason.example.model; 10 | 11 | import javax.xml.bind.annotation.XmlAccessType; 12 | import javax.xml.bind.annotation.XmlAccessorType; 13 | import javax.xml.bind.annotation.XmlElement; 14 | import javax.xml.bind.annotation.XmlRootElement; 15 | import javax.xml.bind.annotation.XmlType; 16 | 17 | 18 | /** 19 | *

Java class for Movie complex type. 20 | * 21 | *

The following schema fragment specifies the expected content contained within this class. 22 | * 23 | *

24 |  * <complexType name="Movie">
25 |  *   <complexContent>
26 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
27 |  *       <sequence>
28 |  *         <element name="object-Infos" type="{http://www.example.org/DemoSchema}ObjectInfos" minOccurs="0"/>
29 |  *       </sequence>
30 |  *     </restriction>
31 |  *   </complexContent>
32 |  * </complexType>
33 |  * 
34 | * 35 | * 36 | */ 37 | @XmlAccessorType(XmlAccessType.FIELD) 38 | @XmlType(name = "Movie", propOrder = { 39 | "objectInfos" 40 | }) 41 | @XmlRootElement 42 | public class Movie { 43 | 44 | @XmlElement(name = "object-Infos") 45 | protected ObjectInfos objectInfos; 46 | 47 | /** 48 | * Gets the value of the objectInfos property. 49 | * 50 | * @return 51 | * possible object is 52 | * {@link ObjectInfos } 53 | * 54 | */ 55 | public ObjectInfos getObjectInfos() { 56 | return objectInfos; 57 | } 58 | 59 | /** 60 | * Sets the value of the objectInfos property. 61 | * 62 | * @param value 63 | * allowed object is 64 | * {@link ObjectInfos } 65 | * 66 | */ 67 | public void setObjectInfos(ObjectInfos value) { 68 | this.objectInfos = value; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/DefaultLicenseParam.java.bak: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2012 Schlichtherle IT Services 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | */ 9 | package de.schlichtherle.license; 10 | 11 | import java.util.prefs.Preferences; 12 | 13 | /** 14 | * This is a convenience class implementing the {@link LicenseParam} interface. 15 | * 16 | * @author Christian Schlichtherle 17 | * @version $Id$ 18 | */ 19 | public class DefaultLicenseParam implements LicenseParam { 20 | 21 | private final String subject; 22 | private final Preferences preferences; 23 | private final KeyStoreParam keyStoreParam; 24 | private final CipherParam cipherParam; 25 | 26 | /** 27 | * Creates a new instance of DefaultLicenseParam. 28 | * 29 | * @param subject The licensing subject 30 | * to be returned by {@link #getSubject()}. 31 | * @param preferences The preferences node used to store the license key 32 | * to be returned by {@link #getPreferences()}. 33 | * @param keyStoreParam The key store parameters 34 | * to be returned by {@link #getKeyStoreParam()}. 35 | * @param cipherParam The cipher parameters 36 | * to be returned by {@link #getCipherParam()}. 37 | */ 38 | public DefaultLicenseParam( 39 | String subject, 40 | Preferences preferences, 41 | KeyStoreParam keyStoreParam, 42 | CipherParam cipherParam) { 43 | this.subject = subject; 44 | this.preferences = preferences; 45 | this.keyStoreParam = keyStoreParam; 46 | this.cipherParam = cipherParam; 47 | } 48 | 49 | public String getSubject() { 50 | return subject; 51 | } 52 | 53 | public Preferences getPreferences() { 54 | return preferences; 55 | } 56 | 57 | public KeyStoreParam getKeyStoreParam() { 58 | return keyStoreParam; 59 | } 60 | 61 | public CipherParam getCipherParam() { 62 | return cipherParam; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/Resources.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2012 Schlichtherle IT Services 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | */ 9 | package zlicense.de.schlichtherle.license; 10 | 11 | import java.text.MessageFormat; 12 | import java.util.ResourceBundle; 13 | 14 | import zlicense.de.schlichtherle.util.ObfuscatedString; 15 | 16 | /** 17 | * Looks up the resources for this package in a Resource Bundle. 18 | * Provided for comfort. 19 | * 20 | * @author Christian Schlichtherle 21 | * @version $Id$ 22 | */ 23 | class Resources { 24 | 25 | private static final String CLASS_NAME = new ObfuscatedString(new long[] { 26 | 0x54087D071FCE4840L, 0x50F993D8A5287E71L, 0x3B4F078A163B6812L, 27 | 0xE97B3E32094E2DB9L, 0x5C18E921228781ECL, 0xDF350057733EC2A7L 28 | }).toString(); /* => "de.schlichtherle.license.Resources" */ 29 | 30 | private static final ResourceBundle resources 31 | = ResourceBundle.getBundle(CLASS_NAME); 32 | 33 | /** 34 | * Looks up a string resource identified by {@code key} in 35 | * {@code resources}. 36 | */ 37 | public static String getString(String key) { 38 | return resources.getString(key); 39 | } 40 | 41 | /** 42 | * Looks up a string resource identified by {@code key} in 43 | * {@code resources} and formats it as a message using 44 | * {@code MessageFormat.format} with the given {@code arguments}. 45 | */ 46 | public static String getString(String key, Object[] arguments) { 47 | return MessageFormat.format(getString(key), arguments); 48 | } 49 | 50 | /** 51 | * Looks up a string resource identified by {@code key} in 52 | * {@code resources} and formats it as a message using 53 | * {@code MessageFormat.format} with the given singular {@code argument}. 54 | */ 55 | public static String getString(String key, Object argument) { 56 | return MessageFormat.format(getString(key), new Object[] { argument }); 57 | } 58 | 59 | /** You cannot instantiate this class. */ 60 | protected Resources() { } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/java/com/jason/example/model/Localized.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2015.02.03 at 03:41:20 PM CST 6 | // 7 | 8 | 9 | package com.jason.example.model; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | import javax.xml.bind.annotation.XmlAccessType; 14 | import javax.xml.bind.annotation.XmlAccessorType; 15 | import javax.xml.bind.annotation.XmlElement; 16 | import javax.xml.bind.annotation.XmlType; 17 | 18 | 19 | /** 20 | *

Java class for Localized complex type. 21 | * 22 | *

The following schema fragment specifies the expected content contained within this class. 23 | * 24 | *

25 |  * <complexType name="Localized">
26 |  *   <complexContent>
27 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
28 |  *       <sequence>
29 |  *         <element name="lang" type="{http://www.example.org/DemoSchema}Lang" maxOccurs="unbounded" minOccurs="0"/>
30 |  *       </sequence>
31 |  *     </restriction>
32 |  *   </complexContent>
33 |  * </complexType>
34 |  * 
35 | * 36 | * 37 | */ 38 | @XmlAccessorType(XmlAccessType.FIELD) 39 | @XmlType(name = "Localized", propOrder = { 40 | "lang" 41 | }) 42 | public class Localized { 43 | 44 | @XmlElement(nillable = true) 45 | protected List lang; 46 | 47 | /** 48 | * Gets the value of the lang property. 49 | * 50 | *

51 | * This accessor method returns a reference to the live list, 52 | * not a snapshot. Therefore any modification you make to the 53 | * returned list will be present inside the JAXB object. 54 | * This is why there is not a set method for the lang property. 55 | * 56 | *

57 | * For example, to add a new item, do as follows: 58 | *

59 |      *    getLang().add(newItem);
60 |      * 
61 | * 62 | * 63 | *

64 | * Objects of the following type(s) are allowed in the list 65 | * {@link Lang } 66 | * 67 | * 68 | */ 69 | public List getLang() { 70 | if (lang == null) { 71 | lang = new ArrayList(); 72 | } 73 | return this.lang; 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/java/com/jason/example/model/ObjectInfos.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2015.02.03 at 03:41:20 PM CST 6 | // 7 | 8 | 9 | package com.jason.example.model; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | import javax.xml.bind.annotation.XmlAccessType; 14 | import javax.xml.bind.annotation.XmlAccessorType; 15 | import javax.xml.bind.annotation.XmlElement; 16 | import javax.xml.bind.annotation.XmlType; 17 | 18 | 19 | /** 20 | *

Java class for ObjectInfos complex type. 21 | * 22 | *

The following schema fragment specifies the expected content contained within this class. 23 | * 24 | *

25 |  * <complexType name="ObjectInfos">
26 |  *   <complexContent>
27 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
28 |  *       <sequence>
29 |  *         <element name="object-info" type="{http://www.example.org/DemoSchema}ObjectInfo" maxOccurs="unbounded" minOccurs="0"/>
30 |  *       </sequence>
31 |  *     </restriction>
32 |  *   </complexContent>
33 |  * </complexType>
34 |  * 
35 | * 36 | * 37 | */ 38 | @XmlAccessorType(XmlAccessType.FIELD) 39 | @XmlType(name = "ObjectInfos", propOrder = { 40 | "objectInfo" 41 | }) 42 | public class ObjectInfos { 43 | 44 | @XmlElement(name = "object-info") 45 | protected List objectInfo; 46 | 47 | /** 48 | * Gets the value of the objectInfo property. 49 | * 50 | *

51 | * This accessor method returns a reference to the live list, 52 | * not a snapshot. Therefore any modification you make to the 53 | * returned list will be present inside the JAXB object. 54 | * This is why there is not a set method for the objectInfo property. 55 | * 56 | *

57 | * For example, to add a new item, do as follows: 58 | *

59 |      *    getObjectInfo().add(newItem);
60 |      * 
61 | * 62 | * 63 | *

64 | * Objects of the following type(s) are allowed in the list 65 | * {@link ObjectInfo } 66 | * 67 | * 68 | */ 69 | public List getObjectInfo() { 70 | if (objectInfo == null) { 71 | objectInfo = new ArrayList(); 72 | } 73 | return this.objectInfo; 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /SpringPattern/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | com.mkyong 5 | SpringPattern 6 | jar 7 | 1.0-SNAPSHOT 8 | SpringPattern 9 | http://maven.apache.org 10 | 11 | 12 | 1.6 13 | 3.2.6.RELEASE 14 | 1.2 15 | 16 | 17 | 18 | 19 | 20 | 21 | jstl 22 | jstl 23 | ${jstl.version} 24 | 25 | 26 | 27 | 28 | org.springframework 29 | spring-core 30 | ${spring.version} 31 | 32 | 33 | 34 | 35 | cglib 36 | cglib 37 | 2.2.2 38 | 39 | 40 | 41 | org.springframework 42 | spring-web 43 | ${spring.version} 44 | 45 | 46 | 47 | org.springframework 48 | spring-webmvc 49 | ${spring.version} 50 | 51 | 52 | 53 | javax.servlet 54 | servlet-api 55 | 2.5 56 | provided 57 | 58 | 59 | 60 | 61 | mitta-webapp 62 | 63 | 64 | org.apache.maven.plugins 65 | maven-eclipse-plugin 66 | 2.9 67 | 68 | true 69 | false 70 | 2.0 71 | 72 | 73 | 74 | org.apache.maven.plugins 75 | maven-compiler-plugin 76 | 2.3.2 77 | 78 | ${jdk.version} 79 | ${jdk.version} 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/java/com/jason/example/model/ObjectFactory.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2015.02.03 at 03:41:20 PM CST 6 | // 7 | 8 | 9 | package com.jason.example.model; 10 | 11 | import javax.xml.bind.JAXBElement; 12 | import javax.xml.bind.annotation.XmlElementDecl; 13 | import javax.xml.bind.annotation.XmlRegistry; 14 | import javax.xml.namespace.QName; 15 | 16 | 17 | /** 18 | * This object contains factory methods for each 19 | * Java content interface and Java element interface 20 | * generated in the com.jason.example.model package. 21 | *

An ObjectFactory allows you to programatically 22 | * construct new instances of the Java representation 23 | * for XML content. The Java representation of XML 24 | * content can consist of schema derived interfaces 25 | * and classes representing the binding of schema 26 | * type definitions, element declarations and model 27 | * groups. Factory methods for each of these are 28 | * provided in this class. 29 | * 30 | */ 31 | @XmlRegistry 32 | public class ObjectFactory { 33 | 34 | private final static QName _Movie_QNAME = new QName("http://www.example.org/DemoSchema", "movie"); 35 | 36 | /** 37 | * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.jason.example.model 38 | * 39 | */ 40 | public ObjectFactory() { 41 | } 42 | 43 | /** 44 | * Create an instance of {@link Movie } 45 | * 46 | */ 47 | public Movie createMovie() { 48 | return new Movie(); 49 | } 50 | 51 | /** 52 | * Create an instance of {@link Lang } 53 | * 54 | */ 55 | public Lang createLang() { 56 | return new Lang(); 57 | } 58 | 59 | /** 60 | * Create an instance of {@link ObjectInfo } 61 | * 62 | */ 63 | public ObjectInfo createObjectInfo() { 64 | return new ObjectInfo(); 65 | } 66 | 67 | /** 68 | * Create an instance of {@link Localized } 69 | * 70 | */ 71 | public Localized createLocalized() { 72 | return new Localized(); 73 | } 74 | 75 | /** 76 | * Create an instance of {@link ObjectInfos } 77 | * 78 | */ 79 | public ObjectInfos createObjectInfos() { 80 | return new ObjectInfos(); 81 | } 82 | 83 | /** 84 | * Create an instance of {@link JAXBElement }{@code <}{@link Movie }{@code >}} 85 | * 86 | */ 87 | @XmlElementDecl(namespace = "http://www.example.org/DemoSchema", name = "movie") 88 | public JAXBElement createMovie(Movie value) { 89 | return new JAXBElement(_Movie_QNAME, Movie.class, null, value); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/AbstractKeyStoreParam.java.bak: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2012 Schlichtherle IT Services 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | */ 9 | package de.schlichtherle.license; 10 | 11 | import java.io.FileNotFoundException; 12 | import java.io.IOException; 13 | import java.io.InputStream; 14 | 15 | /** 16 | * This is a convenience class implementing the 17 | * {@link KeyStoreParam#getStream()} method. 18 | * 19 | * @author Christian Schlichtherle 20 | * @version $Id$ 21 | */ 22 | public abstract class AbstractKeyStoreParam implements KeyStoreParam { 23 | 24 | private final Class clazz; 25 | private final String resource; 26 | 27 | /** 28 | * Creates a new instance of AbstractKeyStoreParam which will look up 29 | * the given resource using the classloader of the given class when 30 | * calling {@link #getStream()}. 31 | */ 32 | protected AbstractKeyStoreParam(final Class clazz, final String resource) { 33 | if (null == clazz || null == resource) 34 | throw new NullPointerException(); 35 | this.clazz = clazz; 36 | this.resource = resource; 37 | } 38 | 39 | /** 40 | * Looks up the resource provided to the constructor using the classloader 41 | * provided to the constructor and returns it as an {@link InputStream}. 42 | */ 43 | public InputStream getStream() throws IOException { 44 | InputStream in = clazz.getResourceAsStream(resource); 45 | if (in == null) 46 | throw new FileNotFoundException(resource); 47 | return in; 48 | } 49 | 50 | /** 51 | * Returns {@code true} if and only if these key store parameters seem to 52 | * address the same key store entry as the given object. 53 | * 54 | * @deprecated Not required. 55 | */ 56 | public final boolean equals(Object object) { 57 | if (!(object instanceof AbstractKeyStoreParam)) 58 | return false; 59 | final AbstractKeyStoreParam that = (AbstractKeyStoreParam) object; 60 | return this.clazz.equals(that.clazz) 61 | && this.resource.equals(that.resource) 62 | && this.getAlias().equals(that.getAlias()); 63 | } 64 | 65 | /** 66 | * Returns a hash code which is consistent with {@link #equals(Object)}. 67 | * 68 | * @return A hash code which is consistent with {@link #equals(Object)}. 69 | * @deprecated Not required. 70 | */ 71 | public final int hashCode() { 72 | int c = 17; 73 | c = 37 * c + hash(this.clazz); 74 | c = 37 * c + hash(this.resource); 75 | return c; 76 | } 77 | 78 | private static int hash(Object object) { 79 | return null == object ? 0 : object.hashCode(); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/verify/RequestVerifyLicense.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package zlicense.verify; 4 | 5 | import java.io.File; 6 | import java.io.FileInputStream; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.util.Properties; 10 | import java.util.prefs.Preferences; 11 | 12 | 13 | 14 | 15 | 16 | import zlicense.de.schlichtherle.license.CipherParam; 17 | import zlicense.de.schlichtherle.license.DefaultCipherParam; 18 | import zlicense.de.schlichtherle.license.DefaultKeyStoreParam; 19 | import zlicense.de.schlichtherle.license.DefaultLicenseParam; 20 | import zlicense.de.schlichtherle.license.KeyStoreParam; 21 | import zlicense.de.schlichtherle.license.LicenseManager; 22 | import zlicense.de.schlichtherle.license.LicenseParam; 23 | 24 | /** 25 | * VerifyLicense 26 | * @author melina 27 | */ 28 | public class RequestVerifyLicense { 29 | //common param 30 | private static String PUBLICALIAS = ""; 31 | private static String STOREPWD = ""; 32 | private static String SUBJECT = ""; 33 | private static String licPath = ""; 34 | private static String pubPath = ""; 35 | 36 | 37 | 38 | public void setParam(String propertiesPath) throws IOException { 39 | // 40 | Properties prop = new Properties(); 41 | System.out.println("propertiesPath="+propertiesPath); 42 | InputStream in = getClass().getResourceAsStream(propertiesPath); 43 | in = new FileInputStream(propertiesPath); 44 | //in = request.getSession().getServletContext().getResourceAsStream("/images/someimage.jpg"); 45 | prop.load(in); 46 | PUBLICALIAS = prop.getProperty("PUBLICALIAS"); 47 | STOREPWD = prop.getProperty("STOREPWD"); 48 | SUBJECT = prop.getProperty("SUBJECT"); 49 | licPath = prop.getProperty("licPath"); 50 | pubPath = prop.getProperty("pubPath"); 51 | } 52 | 53 | public boolean verify() { 54 | 55 | LicenseManager licenseManager = LicenseManagerHolder 56 | .getLicenseManager(initLicenseParams()); 57 | // install license file 58 | try { 59 | licenseManager.install(new File(licPath)); 60 | 61 | } catch (Exception e) { 62 | //e.printStackTrace(); 63 | String moreInfo ="License file verify failure"; 64 | System.out.println("moreInfo="+moreInfo); 65 | } 66 | // verify license file 67 | try { 68 | licenseManager.verify(); 69 | 70 | } catch (Exception e) { 71 | //e.printStackTrace(); 72 | String moreInfo ="License file verify failure"; 73 | System.out.println("moreInfo="+moreInfo); 74 | } 75 | return true; 76 | } 77 | 78 | // 79 | private static LicenseParam initLicenseParams() { 80 | Preferences preference = Preferences 81 | .userNodeForPackage(VerifyLicense.class); 82 | CipherParam cipherParam = new DefaultCipherParam(STOREPWD); 83 | 84 | KeyStoreParam privateStoreParam = new DefaultKeyStoreParam( 85 | VerifyLicense.class, pubPath, PUBLICALIAS, STOREPWD, null); 86 | LicenseParam licenseParams = new DefaultLicenseParam(SUBJECT, 87 | preference, privateStoreParam, cipherParam); 88 | return licenseParams; 89 | } 90 | } -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/verify/VerifyLicense.java: -------------------------------------------------------------------------------- 1 | package zlicense.verify; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileNotFoundException; 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.util.Properties; 9 | import java.util.prefs.Preferences; 10 | 11 | import zlicense.de.schlichtherle.license.CipherParam; 12 | import zlicense.de.schlichtherle.license.DefaultCipherParam; 13 | import zlicense.de.schlichtherle.license.DefaultKeyStoreParam; 14 | import zlicense.de.schlichtherle.license.DefaultLicenseParam; 15 | import zlicense.de.schlichtherle.license.KeyStoreParam; 16 | import zlicense.de.schlichtherle.license.LicenseManager; 17 | import zlicense.de.schlichtherle.license.LicenseParam; 18 | 19 | /** 20 | * VerifyLicense 21 | * @author melina 22 | */ 23 | public class VerifyLicense { 24 | //common param 25 | private static String PUBLICALIAS = ""; 26 | private static String STOREPWD = ""; 27 | private static String SUBJECT = ""; 28 | private static String licPath = ""; 29 | private static String pubPath = ""; 30 | 31 | 32 | 33 | public void setParam(String propertiesPath) throws IOException { 34 | // 35 | Properties prop = new Properties(); 36 | System.out.println("propertiesPath="+propertiesPath); 37 | //InputStream in = getClass().getResourceAsStream(propertiesPath); 38 | InputStream in = new FileInputStream(propertiesPath); 39 | prop.load(in); 40 | PUBLICALIAS = prop.getProperty("PUBLICALIAS"); 41 | STOREPWD = prop.getProperty("STOREPWD"); 42 | SUBJECT = prop.getProperty("SUBJECT"); 43 | licPath = prop.getProperty("licPath"); 44 | pubPath = prop.getProperty("pubPath"); 45 | } 46 | 47 | public boolean verify() throws Exception { 48 | 49 | LicenseManager licenseManager = LicenseManagerHolder 50 | .getLicenseManager(initLicenseParams()); 51 | // install license file 52 | try { 53 | licenseManager.install(new File(licPath)); 54 | System.out.println("License file instal successfully!"); 55 | } catch (Exception e) { 56 | //e.printStackTrace(); 57 | String moreInfo ="License file instal failure"; 58 | System.out.println(moreInfo); 59 | throw e; 60 | } 61 | // verify license file 62 | try { 63 | licenseManager.verify(); 64 | System.out.println("License file verify successfully!"); 65 | } catch (Exception e) { 66 | //e.printStackTrace(); 67 | String moreInfo ="License file verify failure"; 68 | System.out.println(moreInfo); 69 | throw e; 70 | } 71 | return true; 72 | } 73 | 74 | // 75 | private static LicenseParam initLicenseParams() { 76 | Preferences preference = Preferences 77 | .userNodeForPackage(VerifyLicense.class); 78 | CipherParam cipherParam = new DefaultCipherParam(STOREPWD); 79 | 80 | KeyStoreParam privateStoreParam = new DefaultKeyStoreParam( 81 | VerifyLicense.class, pubPath, PUBLICALIAS, STOREPWD, null); 82 | LicenseParam licenseParams = new DefaultLicenseParam(SUBJECT, 83 | preference, privateStoreParam, cipherParam); 84 | return licenseParams; 85 | } 86 | } -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/java/com/jason/example/controller/DemoFileUploadController.java: -------------------------------------------------------------------------------- 1 | 2 | package com.jason.example.controller; 3 | 4 | import java.io.BufferedInputStream; 5 | import java.io.BufferedReader; 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.io.InputStreamReader; 9 | import java.util.Iterator; 10 | import java.util.List; 11 | 12 | import javax.servlet.http.HttpServletResponse; 13 | import javax.xml.bind.JAXBContext; 14 | import javax.xml.bind.JAXBElement; 15 | import javax.xml.bind.JAXBException; 16 | import javax.xml.bind.Unmarshaller; 17 | 18 | import org.apache.commons.logging.Log; 19 | import org.apache.commons.logging.LogFactory; 20 | import org.springframework.stereotype.Controller; 21 | import org.springframework.ui.ModelMap; 22 | import org.springframework.web.bind.annotation.RequestMapping; 23 | import org.springframework.web.bind.annotation.RequestMethod; 24 | import org.springframework.web.multipart.MultipartFile; 25 | import org.springframework.web.multipart.MultipartHttpServletRequest; 26 | import com.jason.example.model.Movie; 27 | import com.jason.example.model.ObjectFactory; 28 | import com.jason.example.model.ObjectInfo; 29 | 30 | 31 | @Controller 32 | public class DemoFileUploadController { 33 | private static final Log logger = LogFactory.getLog(DemoFileUploadController.class); 34 | @RequestMapping(value = "/demoupload", method = RequestMethod.POST) 35 | public String upload(ModelMap model, MultipartHttpServletRequest request, HttpServletResponse response) throws IOException { 36 | String fileName = ""; 37 | StringBuffer content = new StringBuffer(); 38 | Iterator itr1 = request.getFileNames(); 39 | MultipartFile multipartFile = request.getFile(itr1.next()); 40 | fileName = multipartFile.getOriginalFilename(); 41 | InputStream in = multipartFile.getInputStream(); 42 | BufferedInputStream bis = new BufferedInputStream(in); 43 | BufferedReader d = new BufferedReader(new InputStreamReader(bis)); 44 | String xsdPath = this.getClass().getClassLoader().getResource("DemoSchema.xsd").getPath(); 45 | System.out.println("check xsd path=" + xsdPath); 46 | String line = null; 47 | while ((line = d.readLine()) != null) { 48 | System.out.println(line); 49 | content.append(line + "\n"); 50 | } 51 | bis.close(); 52 | d.close(); 53 | try { 54 | JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); 55 | Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); 56 | JAXBElement o = (JAXBElement) jaxbUnmarshaller.unmarshal(multipartFile.getInputStream()); 57 | Movie movie = o.getValue(); 58 | List infoList = movie.getObjectInfos().getObjectInfo(); 59 | DemoCache.setInfoList(infoList); 60 | 61 | } catch (JAXBException ep) { 62 | ep.printStackTrace(); 63 | } catch (Exception ex) { 64 | ex.printStackTrace(); 65 | } 66 | return "successFile"; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/util/ListNets.java: -------------------------------------------------------------------------------- 1 | 2 | package zlicense.util; 3 | 4 | 5 | import java.net.*; 6 | import java.util.*; 7 | 8 | import static java.lang.System.out; 9 | 10 | public class ListNets { 11 | 12 | public static void main(String args[]) throws SocketException { 13 | String ip = "150.236.220.200"; 14 | String mac = "80-00-0B-56-3B-32"; 15 | boolean flag = validatoIpAndMacAddress(ip, mac); 16 | boolean macflag = validateMacAddress( mac); 17 | out.printf("validatoMacAddress flag=%s\n", macflag); 18 | out.printf("validatoIpAndMacAddress flag=%s\n", flag); 19 | } 20 | 21 | static void displayInterfaceInformation(NetworkInterface netint) 22 | throws SocketException { 23 | out.printf("Display name: %s\n", netint.getDisplayName()); 24 | out.printf("Name: %s\n", netint.getName()); 25 | byte[] mac = netint.getHardwareAddress(); 26 | if (mac != null) { 27 | StringBuilder sb = new StringBuilder(); 28 | for (int i = 0; i < mac.length; i++) { 29 | sb.append(String.format("%02X%s", mac[i], 30 | (i < mac.length - 1) ? "-" : "")); 31 | } 32 | System.out.println("mac=" + sb.toString()); 33 | } 34 | 35 | Enumeration inetAddresses = netint.getInetAddresses(); 36 | for (InetAddress inetAddress : Collections.list(inetAddresses)) { 37 | out.printf("InetAddress: %s\n", inetAddress); 38 | System.out 39 | .println("InetAddress ip=" + inetAddress.getHostAddress()); 40 | } 41 | out.printf("\n"); 42 | } 43 | 44 | public static boolean validateMacAddress(String macAddress) 45 | throws SocketException { 46 | boolean returnFlag = false; 47 | Enumeration nets = NetworkInterface 48 | .getNetworkInterfaces(); 49 | for (NetworkInterface netint : Collections.list(nets)) { 50 | byte[] mac = netint.getHardwareAddress(); 51 | StringBuilder sb = new StringBuilder(); 52 | if (mac != null) { 53 | for (int i = 0; i < mac.length; i++) { 54 | sb.append(String.format("%02X%s", mac[i], 55 | (i < mac.length - 1) ? "-" : "")); 56 | } 57 | System.out.println("mac=" + sb.toString()); 58 | } 59 | if (sb.toString().equals(macAddress)) { 60 | returnFlag = true; 61 | } 62 | } 63 | return returnFlag; 64 | 65 | } 66 | 67 | public static boolean validatoIpAndMacAddress(String ipAddress, 68 | String macAddress) throws SocketException { 69 | boolean returnFlag = false; 70 | Enumeration nets = NetworkInterface 71 | .getNetworkInterfaces(); 72 | for (NetworkInterface netint : Collections.list(nets)) { 73 | byte[] mac = netint.getHardwareAddress(); 74 | StringBuilder sb = new StringBuilder(); 75 | if (mac != null) { 76 | for (int i = 0; i < mac.length; i++) { 77 | sb.append(String.format("%02X%s", mac[i], 78 | (i < mac.length - 1) ? "-" : "")); 79 | } 80 | System.out.println("mac=" + sb.toString()); 81 | } 82 | if (sb.toString().equals(macAddress)) { 83 | Enumeration inetAddresses = netint 84 | .getInetAddresses(); 85 | String ip = ""; 86 | for (InetAddress inetAddress : Collections.list(inetAddresses)) { 87 | ip = inetAddress.getHostAddress(); 88 | System.out.println("InetAddress ip=" 89 | + inetAddress.getHostAddress()); 90 | if (ipAddress.toString().equals(ip)) { 91 | returnFlag = true; 92 | } 93 | } 94 | } 95 | } 96 | return returnFlag; 97 | 98 | } 99 | } -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/java/com/jason/example/controller/DemoSeekController.java: -------------------------------------------------------------------------------- 1 | 2 | package com.jason.example.controller; 3 | 4 | import java.io.File; 5 | import java.io.IOException; 6 | import java.io.OutputStream; 7 | 8 | import javax.servlet.ServletContext; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import javax.xml.bind.JAXBContext; 12 | import javax.xml.bind.JAXBException; 13 | import javax.xml.bind.Marshaller; 14 | 15 | import org.springframework.stereotype.Controller; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RequestMethod; 18 | 19 | import com.jason.example.model.Movie; 20 | import com.jason.example.model.ObjectFactory; 21 | import com.jason.example.model.ObjectInfos; 22 | 23 | 24 | @Controller 25 | public class DemoSeekController { 26 | /** 27 | * Size of a byte buffer to read/write file 28 | */ 29 | private static final int BUFFER_SIZE = 4096; 30 | 31 | /** 32 | * Path of the file to be downloaded, relative to application's 33 | * directory 34 | */ 35 | private String filePath = "/demos.xml"; 36 | 37 | @RequestMapping(value = "/getInfoDemo", method = RequestMethod.GET) 38 | public String getInfoObject(HttpServletRequest request, HttpServletResponse response) { 39 | 40 | 41 | ObjectFactory factory = new ObjectFactory(); 42 | Movie demo = factory.createMovie(); 43 | ObjectInfos objectInfos = factory.createObjectInfos(); 44 | System.out.println("-------------DemoCache.getInfoList()------------=" + DemoCache.getInfoList().size()); 45 | objectInfos.getObjectInfo().addAll(DemoCache.getInfoList()); 46 | demo.setObjectInfos(objectInfos); 47 | 48 | System.out.println("movie: " + demo.getObjectInfos().getObjectInfo().size()); 49 | try { 50 | // get absolute path of the application 51 | ServletContext context = request.getSession().getServletContext(); 52 | String appPath = context.getRealPath(""); 53 | System.out.println("appPath = " + appPath); 54 | // construct the complete absolute path of the file 55 | String fullPath = appPath + filePath; 56 | File downloadFile = new File(fullPath); 57 | 58 | // set content attributes for the response 59 | String mimeType = "text/xml"; 60 | response.setContentType(mimeType); 61 | 62 | // set headers for the response 63 | String headerKey = "Content-Disposition"; 64 | String headerValue = String.format("attachment; filename=\"%s\"", downloadFile.getName()); 65 | response.setHeader(headerKey, headerValue); 66 | OutputStream outStream = response.getOutputStream(); 67 | JAXBContext jaxbContext = JAXBContext.newInstance(Movie.class); 68 | Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); 69 | 70 | // output pretty printed 71 | jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); 72 | jaxbMarshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); 73 | jaxbMarshaller.marshal(demo, outStream); 74 | outStream.close(); 75 | } catch (JAXBException e) { 76 | e.printStackTrace(); 77 | } catch (IOException ex) { 78 | ex.printStackTrace(); 79 | } 80 | 81 | return "ok"; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/LicenseContentBeanInfo.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | import java.beans.BeanDescriptor; 4 | import java.beans.EventSetDescriptor; 5 | import java.beans.IntrospectionException; 6 | import java.beans.MethodDescriptor; 7 | import java.beans.PropertyDescriptor; 8 | import java.beans.SimpleBeanInfo; 9 | 10 | public class LicenseContentBeanInfo 11 | extends SimpleBeanInfo 12 | { 13 | private static BeanDescriptor beanDescriptor = null; 14 | private static final int PROPERTY_consumerAmount = 0; 15 | private static final int PROPERTY_consumerType = 1; 16 | private static final int PROPERTY_extra = 2; 17 | private static final int PROPERTY_holder = 3; 18 | private static final int PROPERTY_info = 4; 19 | private static final int PROPERTY_issued = 5; 20 | private static final int PROPERTY_issuer = 6; 21 | private static final int PROPERTY_notAfter = 7; 22 | private static final int PROPERTY_notBefore = 8; 23 | private static final int PROPERTY_subject = 9; 24 | private static EventSetDescriptor[] eventSets = null; 25 | private static MethodDescriptor[] methods = null; 26 | private static final int defaultPropertyIndex = -1; 27 | private static final int defaultEventIndex = -1; 28 | 29 | private static BeanDescriptor getBdescriptor() 30 | { 31 | return beanDescriptor; 32 | } 33 | 34 | private static PropertyDescriptor[] getPdescriptor() 35 | { 36 | PropertyDescriptor[] arrayOfPropertyDescriptor = new PropertyDescriptor[10]; 37 | try 38 | { 39 | arrayOfPropertyDescriptor[0] = new PropertyDescriptor("consumerAmount", LicenseContent.class, "getConsumerAmount", "setConsumerAmount"); 40 | arrayOfPropertyDescriptor[1] = new PropertyDescriptor("consumerType", LicenseContent.class, "getConsumerType", "setConsumerType"); 41 | arrayOfPropertyDescriptor[2] = new PropertyDescriptor("extra", LicenseContent.class, "getExtra", "setExtra"); 42 | arrayOfPropertyDescriptor[3] = new PropertyDescriptor("holder", LicenseContent.class, "getHolder", "setHolder"); 43 | arrayOfPropertyDescriptor[4] = new PropertyDescriptor("info", LicenseContent.class, "getInfo", "setInfo"); 44 | arrayOfPropertyDescriptor[5] = new PropertyDescriptor("issued", LicenseContent.class, "getIssued", "setIssued"); 45 | arrayOfPropertyDescriptor[6] = new PropertyDescriptor("issuer", LicenseContent.class, "getIssuer", "setIssuer"); 46 | arrayOfPropertyDescriptor[7] = new PropertyDescriptor("notAfter", LicenseContent.class, "getNotAfter", "setNotAfter"); 47 | arrayOfPropertyDescriptor[8] = new PropertyDescriptor("notBefore", LicenseContent.class, "getNotBefore", "setNotBefore"); 48 | arrayOfPropertyDescriptor[9] = new PropertyDescriptor("subject", LicenseContent.class, "getSubject", "setSubject"); 49 | } 50 | catch (IntrospectionException localIntrospectionException) 51 | { 52 | localIntrospectionException.printStackTrace(); 53 | } 54 | return arrayOfPropertyDescriptor; 55 | } 56 | 57 | private static EventSetDescriptor[] getEdescriptor() 58 | { 59 | return eventSets; 60 | } 61 | 62 | private static MethodDescriptor[] getMdescriptor() 63 | { 64 | return methods; 65 | } 66 | 67 | public BeanDescriptor getBeanDescriptor() 68 | { 69 | return getBdescriptor(); 70 | } 71 | 72 | public PropertyDescriptor[] getPropertyDescriptors() 73 | { 74 | return getPdescriptor(); 75 | } 76 | 77 | public EventSetDescriptor[] getEventSetDescriptors() 78 | { 79 | return getEdescriptor(); 80 | } 81 | 82 | public MethodDescriptor[] getMethodDescriptors() 83 | { 84 | return getMdescriptor(); 85 | } 86 | 87 | public int getDefaultPropertyIndex() 88 | { 89 | return -1; 90 | } 91 | 92 | public int getDefaultEventIndex() 93 | { 94 | return -1; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/util/ObfuscatedString.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.util; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.util.Random; 5 | 6 | public final class ObfuscatedString 7 | { 8 | private static final String UTF8 = new String(new char[] { 'U', 'T', 'F', '8' }); 9 | private final String s; 10 | 11 | private static final long toLong(byte[] paramArrayOfByte, int paramInt) 12 | { 13 | long l = 0L; 14 | int i = Math.min(paramArrayOfByte.length, paramInt + 8); 15 | int j = i; 16 | for (;;) 17 | { 18 | j--; 19 | if (j < paramInt) { 20 | break; 21 | } 22 | l <<= 8; 23 | l |= paramArrayOfByte[j] & 0xFF; 24 | } 25 | return l; 26 | } 27 | 28 | private static final void toBytes(long paramLong, byte[] paramArrayOfByte, int paramInt) 29 | { 30 | int i = Math.min(paramArrayOfByte.length, paramInt + 8); 31 | for (int j = paramInt; j < i; j++) 32 | { 33 | paramArrayOfByte[j] = ((byte)(int)paramLong); 34 | paramLong >>= 8; 35 | } 36 | } 37 | 38 | public static String obfuscate(String paramString) 39 | { 40 | if (paramString.indexOf(0) != -1) { 41 | throw new IllegalArgumentException(new ObfuscatedString(new long[] { 2598583114197433456L, -2532951909540716745L, 1850312903926917213L, -7324743161950196342L, 3319654553699491298L }).toString()); 42 | } 43 | byte[] arrayOfByte; 44 | try 45 | { 46 | arrayOfByte = paramString.getBytes(UTF8); 47 | } 48 | catch (UnsupportedEncodingException localUnsupportedEncodingException) 49 | { 50 | throw new AssertionError(localUnsupportedEncodingException); 51 | } 52 | Random localRandom = new Random(); 53 | long l1; 54 | do 55 | { 56 | l1 = localRandom.nextLong(); 57 | } while (l1 == 0L); 58 | localRandom = new Random(l1); 59 | StringBuffer localStringBuffer = new StringBuffer(new ObfuscatedString(new long[] { -6733388613909857970L, -557652741307719956L, 563088487624542180L, 5623833171491374716L, -2309350771052518321L, 2627844803624578169L }).toString()); 60 | appendHexLiteral(localStringBuffer, l1); 61 | int i = arrayOfByte.length; 62 | for (int j = 0; j < i; j += 8) 63 | { 64 | long l2 = localRandom.nextLong(); 65 | long l3 = toLong(arrayOfByte, j) ^ l2; 66 | localStringBuffer.append(", "); 67 | appendHexLiteral(localStringBuffer, l3); 68 | } 69 | localStringBuffer.append(new ObfuscatedString(new long[] { 4756003162039514438L, -7241174029104351587L, 2576762727660584163L, 2432800632635846553L }).toString()); 70 | localStringBuffer.append(paramString.replaceAll("\\\\", new ObfuscatedString(new long[] { 7866777055383403009L, -5101749501440392498L }).toString()).replaceAll("\"", new ObfuscatedString(new long[] { -8797265930671803829L, -5738757606858957305L }).toString())); 71 | localStringBuffer.append(new ObfuscatedString(new long[] { -4228881123273879289L, 1823585417647083411L }).toString()); 72 | return localStringBuffer.toString(); 73 | } 74 | 75 | private static final void appendHexLiteral(StringBuffer paramStringBuffer, long paramLong) 76 | { 77 | paramStringBuffer.append("0x"); 78 | paramStringBuffer.append(Long.toHexString(paramLong).toUpperCase()); 79 | paramStringBuffer.append('L'); 80 | } 81 | 82 | public ObfuscatedString(long[] paramArrayOfLong) 83 | { 84 | int i = paramArrayOfLong.length; 85 | byte[] arrayOfByte = new byte[8 * (i - 1)]; 86 | long l1 = paramArrayOfLong[0]; 87 | Random localRandom = new Random(l1); 88 | for (int j = 1; j < i; j++) 89 | { 90 | long l2 = localRandom.nextLong(); 91 | toBytes(paramArrayOfLong[j] ^ l2, arrayOfByte, 8 * (j - 1)); 92 | } 93 | String str; 94 | try 95 | { 96 | str = new String(arrayOfByte, UTF8); 97 | } 98 | catch (UnsupportedEncodingException localUnsupportedEncodingException) 99 | { 100 | throw new AssertionError(localUnsupportedEncodingException); 101 | } 102 | int k = str.indexOf(0); 103 | this.s = (k != -1 ? str.substring(0, k) : str); 104 | } 105 | 106 | public String toString() 107 | { 108 | return this.s; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/java/com/jason/example/model/Lang.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2015.02.03 at 03:41:20 PM CST 6 | // 7 | 8 | 9 | package com.jason.example.model; 10 | 11 | import javax.xml.bind.annotation.XmlAccessType; 12 | import javax.xml.bind.annotation.XmlAccessorType; 13 | import javax.xml.bind.annotation.XmlElement; 14 | import javax.xml.bind.annotation.XmlType; 15 | 16 | 17 | /** 18 | *

Java class for Lang complex type. 19 | * 20 | *

The following schema fragment specifies the expected content contained within this class. 21 | * 22 | *

 23 |  * <complexType name="Lang">
 24 |  *   <complexContent>
 25 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 26 |  *       <sequence>
 27 |  *         <element name="code" type="{http://www.w3.org/2001/XMLSchema}string"/>
 28 |  *         <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
 29 |  *         <element name="attribute" type="{http://www.w3.org/2001/XMLSchema}string"/>
 30 |  *         <element name="description" type="{http://www.w3.org/2001/XMLSchema}string"/>
 31 |  *       </sequence>
 32 |  *     </restriction>
 33 |  *   </complexContent>
 34 |  * </complexType>
 35 |  * 
36 | * 37 | * 38 | */ 39 | @XmlAccessorType(XmlAccessType.FIELD) 40 | @XmlType(name = "Lang", propOrder = { 41 | "code", 42 | "name", 43 | "attribute", 44 | "description" 45 | }) 46 | public class Lang { 47 | 48 | @XmlElement(required = true) 49 | protected String code; 50 | @XmlElement(required = true, nillable = true) 51 | protected String name; 52 | @XmlElement(required = true, nillable = true) 53 | protected String attribute; 54 | @XmlElement(required = true, nillable = true) 55 | protected String description; 56 | 57 | /** 58 | * Gets the value of the code property. 59 | * 60 | * @return 61 | * possible object is 62 | * {@link String } 63 | * 64 | */ 65 | public String getCode() { 66 | return code; 67 | } 68 | 69 | /** 70 | * Sets the value of the code property. 71 | * 72 | * @param value 73 | * allowed object is 74 | * {@link String } 75 | * 76 | */ 77 | public void setCode(String value) { 78 | this.code = value; 79 | } 80 | 81 | /** 82 | * Gets the value of the name property. 83 | * 84 | * @return 85 | * possible object is 86 | * {@link String } 87 | * 88 | */ 89 | public String getName() { 90 | return name; 91 | } 92 | 93 | /** 94 | * Sets the value of the name property. 95 | * 96 | * @param value 97 | * allowed object is 98 | * {@link String } 99 | * 100 | */ 101 | public void setName(String value) { 102 | this.name = value; 103 | } 104 | 105 | /** 106 | * Gets the value of the attribute property. 107 | * 108 | * @return 109 | * possible object is 110 | * {@link String } 111 | * 112 | */ 113 | public String getAttribute() { 114 | return attribute; 115 | } 116 | 117 | /** 118 | * Sets the value of the attribute property. 119 | * 120 | * @param value 121 | * allowed object is 122 | * {@link String } 123 | * 124 | */ 125 | public void setAttribute(String value) { 126 | this.attribute = value; 127 | } 128 | 129 | /** 130 | * Gets the value of the description property. 131 | * 132 | * @return 133 | * possible object is 134 | * {@link String } 135 | * 136 | */ 137 | public String getDescription() { 138 | return description; 139 | } 140 | 141 | /** 142 | * Sets the value of the description property. 143 | * 144 | * @param value 145 | * allowed object is 146 | * {@link String } 147 | * 148 | */ 149 | public void setDescription(String value) { 150 | this.description = value; 151 | } 152 | 153 | } 154 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/src/main/java/com/jason/example/model/ObjectInfo.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2015.02.03 at 03:41:20 PM CST 6 | // 7 | 8 | 9 | package com.jason.example.model; 10 | 11 | import javax.xml.bind.annotation.XmlAccessType; 12 | import javax.xml.bind.annotation.XmlAccessorType; 13 | import javax.xml.bind.annotation.XmlElement; 14 | import javax.xml.bind.annotation.XmlType; 15 | 16 | 17 | /** 18 | *

Java class for ObjectInfo complex type. 19 | * 20 | *

The following schema fragment specifies the expected content contained within this class. 21 | * 22 | *

 23 |  * <complexType name="ObjectInfo">
 24 |  *   <complexContent>
 25 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 26 |  *       <sequence>
 27 |  *         <element name="id" type="{http://www.w3.org/2001/XMLSchema}string"/>
 28 |  *         <element name="image-url" type="{http://www.w3.org/2001/XMLSchema}string"/>
 29 |  *         <element name="priority" type="{http://www.w3.org/2001/XMLSchema}int"/>
 30 |  *         <element name="localized" type="{http://www.example.org/DemoSchema}Localized"/>
 31 |  *       </sequence>
 32 |  *     </restriction>
 33 |  *   </complexContent>
 34 |  * </complexType>
 35 |  * 
36 | * 37 | * 38 | */ 39 | @XmlAccessorType(XmlAccessType.FIELD) 40 | @XmlType(name = "ObjectInfo", propOrder = { 41 | "id", 42 | "imageUrl", 43 | "priority", 44 | "localized" 45 | }) 46 | public class ObjectInfo { 47 | 48 | @XmlElement(required = true) 49 | protected String id; 50 | @XmlElement(name = "image-url", required = true, nillable = true) 51 | protected String imageUrl; 52 | @XmlElement(required = true, type = Integer.class, nillable = true) 53 | protected Integer priority; 54 | @XmlElement(required = true, nillable = true) 55 | protected Localized localized; 56 | 57 | /** 58 | * Gets the value of the id property. 59 | * 60 | * @return 61 | * possible object is 62 | * {@link String } 63 | * 64 | */ 65 | public String getId() { 66 | return id; 67 | } 68 | 69 | /** 70 | * Sets the value of the id property. 71 | * 72 | * @param value 73 | * allowed object is 74 | * {@link String } 75 | * 76 | */ 77 | public void setId(String value) { 78 | this.id = value; 79 | } 80 | 81 | /** 82 | * Gets the value of the imageUrl property. 83 | * 84 | * @return 85 | * possible object is 86 | * {@link String } 87 | * 88 | */ 89 | public String getImageUrl() { 90 | return imageUrl; 91 | } 92 | 93 | /** 94 | * Sets the value of the imageUrl property. 95 | * 96 | * @param value 97 | * allowed object is 98 | * {@link String } 99 | * 100 | */ 101 | public void setImageUrl(String value) { 102 | this.imageUrl = value; 103 | } 104 | 105 | /** 106 | * Gets the value of the priority property. 107 | * 108 | * @return 109 | * possible object is 110 | * {@link Integer } 111 | * 112 | */ 113 | public Integer getPriority() { 114 | return priority; 115 | } 116 | 117 | /** 118 | * Sets the value of the priority property. 119 | * 120 | * @param value 121 | * allowed object is 122 | * {@link Integer } 123 | * 124 | */ 125 | public void setPriority(Integer value) { 126 | this.priority = value; 127 | } 128 | 129 | /** 130 | * Gets the value of the localized property. 131 | * 132 | * @return 133 | * possible object is 134 | * {@link Localized } 135 | * 136 | */ 137 | public Localized getLocalized() { 138 | return localized; 139 | } 140 | 141 | /** 142 | * Sets the value of the localized property. 143 | * 144 | * @param value 145 | * allowed object is 146 | * {@link Localized } 147 | * 148 | */ 149 | public void setLocalized(Localized value) { 150 | this.localized = value; 151 | } 152 | 153 | } 154 | -------------------------------------------------------------------------------- /data-ingestion-demo-war/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | demo.batch 4 | data-ingestion-demo 5 | war 6 | 0.0.1-SNAPSHOT 7 | XML Batch 8 | http://maven.apache.org 9 | 10 | 11 | javax.servlet 12 | javax.servlet-api 13 | 3.0.1 14 | 15 | 16 | javax.validation 17 | validation-api 18 | 1.1.0.Final 19 | 20 | 21 | org.hibernate 22 | hibernate-validator 23 | 5.1.0.Final 24 | 25 | 26 | commons-io 27 | commons-io 28 | 2.4 29 | 30 | 31 | commons-fileupload 32 | commons-fileupload 33 | 1.3.1 34 | 35 | 36 | jstl 37 | jstl 38 | 1.2 39 | 40 | 41 | 42 | jaxen 43 | jaxen 44 | 1.1.6 45 | 46 | 47 | 48 | javax.xml 49 | jaxb-api 50 | 2.1 51 | 52 | 53 | org.springframework 54 | spring-context 55 | 4.0.6.RELEASE 56 | 57 | 58 | 59 | org.springframework 60 | spring-core 61 | ${springframework.version} 62 | 63 | 64 | org.springframework 65 | spring-web 66 | ${springframework.version} 67 | 68 | 69 | 70 | org.springframework 71 | spring-webmvc 72 | ${springframework.version} 73 | 74 | 75 | 76 | org.springframework 77 | spring-oxm 78 | ${springframework.version} 79 | 80 | 81 | org.springframework 82 | spring-jdbc 83 | ${springframework.version} 84 | 85 | 86 | org.eclipse.persistence 87 | org.eclipse.persistence.moxy 88 | 2.5.0 89 | 90 | 91 | 92 | 93 | data-ingestion-demo-war 94 | 95 | 96 | org.apache.maven.plugins 97 | maven-compiler-plugin 98 | 3.1 99 | 100 | 1.7 101 | 1.7 102 | true 103 | ${JAVA_HOME}/bin/javac 104 | UTF-8 105 | 106 | 107 | 108 | org.apache.maven.plugins 109 | maven-assembly-plugin 110 | 2.3 111 | 112 | 113 | maven-antrun-plugin 114 | 115 | 116 | install 117 | 118 | 119 | 122 | 123 | 124 | 125 | run 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 4.0.6.RELEASE 135 | 3.0.1.RELEASE 136 | 5.1.31 137 | 2.3 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/create/CreateLicense.java: -------------------------------------------------------------------------------- 1 | package zlicense.create; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.IOException; 6 | import java.io.InputStream; 7 | import java.text.DateFormat; 8 | import java.text.ParseException; 9 | import java.text.SimpleDateFormat; 10 | import java.util.Properties; 11 | import java.util.prefs.Preferences; 12 | 13 | import javax.security.auth.x500.X500Principal; 14 | 15 | 16 | 17 | 18 | 19 | 20 | import zlicense.de.schlichtherle.license.CipherParam; 21 | import zlicense.de.schlichtherle.license.DefaultCipherParam; 22 | import zlicense.de.schlichtherle.license.DefaultKeyStoreParam; 23 | import zlicense.de.schlichtherle.license.DefaultLicenseParam; 24 | import zlicense.de.schlichtherle.license.KeyStoreParam; 25 | import zlicense.de.schlichtherle.license.LicenseContent; 26 | import zlicense.de.schlichtherle.license.LicenseManager; 27 | import zlicense.de.schlichtherle.license.LicenseParam; 28 | import zlicense.util.LicenseCheckModel; 29 | 30 | /** 31 | * CreateLicense 32 | * @author melina 33 | */ 34 | public class CreateLicense { 35 | //common param 36 | private static String PRIVATEALIAS = ""; 37 | private static String KEYPWD = ""; 38 | private static String STOREPWD = ""; 39 | private static String SUBJECT = ""; 40 | private static String licPath = ""; 41 | private static String priPath = ""; 42 | //license content 43 | private static String issuedTime = ""; 44 | private static String notBefore = ""; 45 | private static String notAfter = ""; 46 | private static String ipAddress = ""; 47 | private static String macAddress = ""; 48 | private static String consumerType = ""; 49 | private static int consumerAmount = 0; 50 | private static String info = ""; 51 | 52 | 53 | private final static X500Principal DEFAULTHOLDERANDISSUER = new X500Principal( 54 | "CN=Duke、OU=JavaSoft、O=Sun Microsystems、C=US"); 55 | 56 | public void setParam(String propertiesPath) { 57 | // 58 | Properties prop = new Properties(); 59 | //InputStream in = getClass().getResourceAsStream(propertiesPath); 60 | 61 | try { 62 | InputStream in = new FileInputStream(propertiesPath); 63 | prop.load(in); 64 | } catch (IOException e) { 65 | // TODO Auto-generated catch block 66 | e.printStackTrace(); 67 | } 68 | PRIVATEALIAS = prop.getProperty("PRIVATEALIAS"); 69 | KEYPWD = prop.getProperty("KEYPWD"); 70 | STOREPWD = prop.getProperty("STOREPWD"); 71 | SUBJECT = prop.getProperty("SUBJECT"); 72 | KEYPWD = prop.getProperty("KEYPWD"); 73 | licPath = prop.getProperty("licPath"); 74 | priPath = prop.getProperty("priPath"); 75 | //license content 76 | issuedTime = prop.getProperty("issuedTime"); 77 | notBefore = prop.getProperty("notBefore"); 78 | notAfter = prop.getProperty("notAfter"); 79 | 80 | ipAddress = prop.getProperty("ipAddress"); 81 | macAddress = prop.getProperty("macAddress"); 82 | 83 | consumerType = prop.getProperty("consumerType"); 84 | consumerAmount = Integer.valueOf(prop.getProperty("consumerAmount")); 85 | info = prop.getProperty("info"); 86 | 87 | } 88 | 89 | public boolean create() { 90 | try { 91 | 92 | LicenseManager licenseManager = LicenseManagerHolder 93 | .getLicenseManager(initLicenseParams0()); 94 | licenseManager.store((createLicenseContent()), new File(licPath)); 95 | } catch (Exception e) { 96 | e.printStackTrace(); 97 | System.out.println("create license file failure"); 98 | return false; 99 | } 100 | System.out.println("create license file successfully"); 101 | return true; 102 | } 103 | 104 | 105 | private static LicenseParam initLicenseParams0() { 106 | Preferences preference = Preferences 107 | .userNodeForPackage(CreateLicense.class); 108 | 109 | CipherParam cipherParam = new DefaultCipherParam(STOREPWD); 110 | 111 | KeyStoreParam privateStoreParam = new DefaultKeyStoreParam( 112 | CreateLicense.class, priPath, PRIVATEALIAS, STOREPWD, KEYPWD); 113 | LicenseParam licenseParams = new DefaultLicenseParam(SUBJECT, 114 | preference, privateStoreParam, cipherParam); 115 | return licenseParams; 116 | } 117 | 118 | 119 | public final static LicenseContent createLicenseContent() { 120 | DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); 121 | 122 | LicenseCheckModel licenseCheckModel = new LicenseCheckModel(); 123 | licenseCheckModel.setIpAddress(ipAddress); 124 | licenseCheckModel.setIpMacAddress(macAddress); 125 | 126 | LicenseContent content = null; 127 | content = new LicenseContent(); 128 | content.setSubject(SUBJECT); 129 | content.setHolder(DEFAULTHOLDERANDISSUER); 130 | content.setIssuer(DEFAULTHOLDERANDISSUER); 131 | try { 132 | content.setIssued(format.parse(issuedTime)); 133 | content.setNotBefore(format.parse(notBefore)); 134 | content.setNotAfter(format.parse(notAfter)); 135 | content.setExtra(licenseCheckModel); 136 | } catch (ParseException e) { 137 | // TODO Auto-generated catch block 138 | e.printStackTrace(); 139 | } 140 | content.setConsumerType(consumerType); 141 | content.setConsumerAmount(consumerAmount); 142 | content.setInfo(info); 143 | 144 | 145 | return content; 146 | } 147 | } -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/PrivacyGuard.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.io.ByteArrayOutputStream; 5 | import java.io.IOException; 6 | import java.io.InputStream; 7 | import java.security.InvalidAlgorithmParameterException; 8 | import java.security.InvalidKeyException; 9 | import java.security.NoSuchAlgorithmException; 10 | import java.security.spec.AlgorithmParameterSpec; 11 | import java.security.spec.InvalidKeySpecException; 12 | import java.util.zip.GZIPInputStream; 13 | import java.util.zip.GZIPOutputStream; 14 | 15 | import javax.crypto.Cipher; 16 | import javax.crypto.CipherOutputStream; 17 | import javax.crypto.NoSuchPaddingException; 18 | import javax.crypto.SecretKey; 19 | import javax.crypto.SecretKeyFactory; 20 | import javax.crypto.spec.PBEKeySpec; 21 | import javax.crypto.spec.PBEParameterSpec; 22 | 23 | import zlicense.de.schlichtherle.util.ObfuscatedString; 24 | import zlicense.de.schlichtherle.xml.GenericCertificate; 25 | import zlicense.de.schlichtherle.xml.PersistenceService; 26 | import zlicense.de.schlichtherle.xml.PersistenceServiceException; 27 | 28 | public class PrivacyGuard 29 | { 30 | private static final String PBE_WITH_MD5_AND_DES = new ObfuscatedString(new long[] { 2860604316472308139L, 5030391952891038168L, -6110818099732428353L }).toString(); 31 | private CipherParam param; 32 | private Cipher cipher; 33 | private SecretKey key; 34 | private AlgorithmParameterSpec algoParamSpec; 35 | 36 | protected PrivacyGuard() {} 37 | 38 | public PrivacyGuard(CipherParam paramCipherParam) 39 | { 40 | setCipherParam(paramCipherParam); 41 | } 42 | 43 | public CipherParam getCipherParam() 44 | { 45 | return this.param; 46 | } 47 | 48 | public void setCipherParam(CipherParam paramCipherParam) 49 | throws NullPointerException, IllegalPasswordException 50 | { 51 | if (paramCipherParam == null) { 52 | throw new NullPointerException(LicenseNotary.PARAM); 53 | } 54 | Policy.getCurrent().checkPwd(paramCipherParam.getKeyPwd()); 55 | this.param = paramCipherParam; 56 | this.cipher = null; 57 | this.key = null; 58 | this.algoParamSpec = null; 59 | } 60 | 61 | public byte[] cert2key(GenericCertificate paramGenericCertificate) 62 | throws Exception 63 | { 64 | ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream(); 65 | GZIPOutputStream localGZIPOutputStream = new GZIPOutputStream(new CipherOutputStream(localByteArrayOutputStream, getCipher4Encryption())); 66 | try 67 | { 68 | PersistenceService.store(paramGenericCertificate, localGZIPOutputStream); 69 | } 70 | catch (PersistenceServiceException localPersistenceServiceException) 71 | { 72 | throw new AssertionError(localPersistenceServiceException); 73 | } 74 | return localByteArrayOutputStream.toByteArray(); 75 | } 76 | 77 | public GenericCertificate key2cert(byte[] paramArrayOfByte) 78 | throws Exception 79 | { 80 | GZIPInputStream localGZIPInputStream = new GZIPInputStream(new ByteArrayInputStream(getCipher4Decryption().doFinal(paramArrayOfByte))); 81 | try 82 | { 83 | GenericCertificate localGenericCertificate = (GenericCertificate)PersistenceService.load(localGZIPInputStream); 84 | return localGenericCertificate; 85 | } 86 | finally 87 | { 88 | try 89 | { 90 | localGZIPInputStream.close(); 91 | } 92 | catch (IOException localIOException2) {} 93 | } 94 | } 95 | 96 | /** 97 | * @deprecated 98 | */ 99 | protected Cipher getCipher4Encryption() 100 | { 101 | Cipher localCipher = getCipher(); 102 | try 103 | { 104 | localCipher.init(1, this.key, this.algoParamSpec); 105 | } 106 | catch (InvalidKeyException localInvalidKeyException) 107 | { 108 | throw new AssertionError(localInvalidKeyException); 109 | } 110 | catch (InvalidAlgorithmParameterException localInvalidAlgorithmParameterException) 111 | { 112 | throw new AssertionError(localInvalidAlgorithmParameterException); 113 | } 114 | return localCipher; 115 | } 116 | 117 | /** 118 | * @deprecated 119 | */ 120 | protected Cipher getCipher4Decryption() 121 | { 122 | Cipher localCipher = getCipher(); 123 | try 124 | { 125 | localCipher.init(2, this.key, this.algoParamSpec); 126 | } 127 | catch (InvalidKeyException localInvalidKeyException) 128 | { 129 | throw new AssertionError(localInvalidKeyException); 130 | } 131 | catch (InvalidAlgorithmParameterException localInvalidAlgorithmParameterException) 132 | { 133 | throw new AssertionError(localInvalidAlgorithmParameterException); 134 | } 135 | return localCipher; 136 | } 137 | 138 | /** 139 | * @deprecated 140 | */ 141 | protected Cipher getCipher() 142 | { 143 | if (this.cipher != null) { 144 | return this.cipher; 145 | } 146 | this.algoParamSpec = new PBEParameterSpec(new byte[] { -50, -5, -34, -84, 5, 2, 25, 113 }, 2005); 147 | try 148 | { 149 | PBEKeySpec localPBEKeySpec = new PBEKeySpec(getCipherParam().getKeyPwd().toCharArray()); 150 | SecretKeyFactory localSecretKeyFactory = SecretKeyFactory.getInstance(PBE_WITH_MD5_AND_DES); 151 | this.key = localSecretKeyFactory.generateSecret(localPBEKeySpec); 152 | this.cipher = Cipher.getInstance(PBE_WITH_MD5_AND_DES); 153 | } 154 | catch (NoSuchAlgorithmException localNoSuchAlgorithmException) 155 | { 156 | throw new AssertionError(localNoSuchAlgorithmException); 157 | } 158 | catch (InvalidKeySpecException localInvalidKeySpecException) 159 | { 160 | throw new AssertionError(localInvalidKeySpecException); 161 | } 162 | catch (NoSuchPaddingException localNoSuchPaddingException) 163 | { 164 | throw new AssertionError(localNoSuchPaddingException); 165 | } 166 | return this.cipher; 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/LicenseNotary.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | import java.io.BufferedInputStream; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.security.KeyStore; 7 | import java.security.KeyStoreException; 8 | import java.security.NoSuchAlgorithmException; 9 | import java.security.PrivateKey; 10 | import java.security.PublicKey; 11 | import java.security.Signature; 12 | import java.security.UnrecoverableKeyException; 13 | import java.security.cert.Certificate; 14 | import java.security.cert.CertificateException; 15 | 16 | import zlicense.de.schlichtherle.util.ObfuscatedString; 17 | import zlicense.de.schlichtherle.xml.GenericCertificate; 18 | 19 | public class LicenseNotary { 20 | private static final int BUFSIZE = 5120; 21 | static final String PARAM = new ObfuscatedString(new long[] { 22 | 668274362144012114L, -2115765889337599212L }).toString(); 23 | private static final String ALIAS = new ObfuscatedString(new long[] { 24 | 1112708769776922148L, 6703392504509681290L }).toString(); 25 | private static final String EXC_NO_KEY_PWD = new ObfuscatedString( 26 | new long[] { -7210613020960449599L, 222075784786550139L, 27 | 9025728610804768010L }).toString(); 28 | private static final String EXC_NO_KEY_ENTRY = new ObfuscatedString( 29 | new long[] { -1386002024146642540L, 4133952825992554401L, 30 | -8020387964636761861L }).toString(); 31 | private static final String EXC_PRIVATE_KEY_OR_PWD_IS_NOT_ALLOWED = new ObfuscatedString( 32 | new long[] { -2960555953270849419L, 3827258740935670554L, 33 | -3005417608224527600L, 1939660993088349256L, 34 | 4750831951568910874L }).toString(); 35 | private static final String EXC_NO_CERTIFICATE_ENTRY = new ObfuscatedString( 36 | new long[] { -3872127676557769698L, -2469202953083814859L, 37 | 6713970776812571709L, -482260351456063412L }).toString(); 38 | private static final String SHA1_WITH_DSA = new ObfuscatedString( 39 | new long[] { -1509550478491572167L, 1688274905166048601L, 40 | -4620167493569680976L }).toString(); 41 | private static final String JKS = new ObfuscatedString(new long[] { 42 | -6234396975553918200L, 2370155821952859770L }).toString(); 43 | private KeyStoreParam param; 44 | private KeyStore keyStore; 45 | private PrivateKey privateKey; 46 | private PublicKey publicKey; 47 | 48 | protected LicenseNotary() { 49 | } 50 | 51 | public LicenseNotary(KeyStoreParam paramKeyStoreParam) 52 | throws NullPointerException, IllegalPasswordException { 53 | setKeyStoreParam(paramKeyStoreParam); 54 | } 55 | 56 | public KeyStoreParam getKeyStoreParam() { 57 | return this.param; 58 | } 59 | 60 | public void setKeyStoreParam(KeyStoreParam paramKeyStoreParam) 61 | throws NullPointerException, IllegalPasswordException { 62 | if (paramKeyStoreParam == null) { 63 | throw new NullPointerException(PARAM); 64 | } 65 | if (paramKeyStoreParam.getAlias() == null) { 66 | throw new NullPointerException(ALIAS); 67 | } 68 | Policy localPolicy = Policy.getCurrent(); 69 | String str1 = paramKeyStoreParam.getStorePwd(); 70 | localPolicy.checkPwd(str1); 71 | String str2 = paramKeyStoreParam.getKeyPwd(); 72 | if (str2 != null) { 73 | localPolicy.checkPwd(str2); 74 | } 75 | this.param = paramKeyStoreParam; 76 | this.keyStore = null; 77 | this.privateKey = null; 78 | this.publicKey = null; 79 | } 80 | 81 | public GenericCertificate sign(Object paramObject) throws Exception { 82 | GenericCertificate localGenericCertificate = new GenericCertificate(); 83 | sign(localGenericCertificate, paramObject); 84 | return localGenericCertificate; 85 | } 86 | 87 | /** 88 | * @deprecated 89 | */ 90 | public void sign(GenericCertificate paramGenericCertificate, 91 | Object paramObject) throws Exception { 92 | paramGenericCertificate.sign(paramObject, getPrivateKey(), 93 | getSignatureEngine()); 94 | } 95 | 96 | public void verify(GenericCertificate paramGenericCertificate) 97 | throws Exception { 98 | paramGenericCertificate.verify(getPublicKey(), getSignatureEngine()); 99 | } 100 | 101 | /** 102 | * @deprecated 103 | */ 104 | protected PrivateKey getPrivateKey() throws LicenseNotaryException, 105 | IOException, CertificateException, NoSuchAlgorithmException, 106 | UnrecoverableKeyException { 107 | if (this.privateKey == null) { 108 | KeyStoreParam localKeyStoreParam = getKeyStoreParam(); 109 | String str1 = localKeyStoreParam.getKeyPwd(); 110 | String str2 = localKeyStoreParam.getAlias(); 111 | if (str1 == null) { 112 | throw new LicenseNotaryException(EXC_NO_KEY_PWD, str2); 113 | } 114 | KeyStore localKeyStore = getKeyStore(); 115 | try { 116 | this.privateKey = ((PrivateKey) localKeyStore.getKey(str2, 117 | str1.toCharArray())); 118 | } catch (KeyStoreException localKeyStoreException) { 119 | throw new AssertionError(localKeyStoreException); 120 | } 121 | if (this.privateKey == null) { 122 | throw new LicenseNotaryException(EXC_NO_KEY_ENTRY, str2); 123 | } 124 | } 125 | return this.privateKey; 126 | } 127 | 128 | /** 129 | * @deprecated 130 | */ 131 | protected PublicKey getPublicKey() throws LicenseNotaryException, 132 | IOException, CertificateException, NoSuchAlgorithmException { 133 | if (this.publicKey == null) { 134 | String str = getKeyStoreParam().getAlias(); 135 | KeyStore localKeyStore = getKeyStore(); 136 | try { 137 | if ((getKeyStoreParam().getKeyPwd() != null) != localKeyStore 138 | .isKeyEntry(str)) { 139 | throw new LicenseNotaryException( 140 | EXC_PRIVATE_KEY_OR_PWD_IS_NOT_ALLOWED, str); 141 | } 142 | Certificate localCertificate = localKeyStore 143 | .getCertificate(str); 144 | if (localCertificate == null) { 145 | throw new LicenseNotaryException(EXC_NO_CERTIFICATE_ENTRY, 146 | str); 147 | } 148 | this.publicKey = localCertificate.getPublicKey(); 149 | } catch (KeyStoreException localKeyStoreException) { 150 | throw new AssertionError(localKeyStoreException); 151 | } 152 | } 153 | return this.publicKey; 154 | } 155 | 156 | /** 157 | * @deprecated 158 | */ 159 | protected Signature getSignatureEngine() { 160 | try { 161 | return Signature.getInstance(SHA1_WITH_DSA); 162 | } catch (NoSuchAlgorithmException localNoSuchAlgorithmException) { 163 | throw new AssertionError(localNoSuchAlgorithmException); 164 | } 165 | } 166 | 167 | /** 168 | * @deprecated 169 | */ 170 | protected KeyStore getKeyStore() throws IOException, CertificateException, 171 | NoSuchAlgorithmException { 172 | if (this.keyStore != null) { 173 | return this.keyStore; 174 | } 175 | BufferedInputStream localBufferedInputStream = null; 176 | try { 177 | this.keyStore = KeyStore.getInstance(JKS); 178 | localBufferedInputStream = new BufferedInputStream( 179 | this.param.getStream(), 5120); 180 | this.keyStore.load(localBufferedInputStream, getKeyStoreParam() 181 | .getStorePwd().toCharArray()); 182 | return this.keyStore; 183 | } catch (KeyStoreException localKeyStoreException) { 184 | throw new AssertionError(localKeyStoreException); 185 | } finally { 186 | try { 187 | localBufferedInputStream.close(); 188 | } catch (Exception localException2) { 189 | } 190 | } 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/LicenseContent.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | import java.beans.DefaultPersistenceDelegate; 4 | import java.beans.PropertyChangeEvent; 5 | import java.beans.PropertyChangeListener; 6 | import java.beans.PropertyChangeSupport; 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | 10 | import javax.security.auth.x500.X500Principal; 11 | 12 | import zlicense.de.schlichtherle.xml.PersistenceService; 13 | 14 | public class LicenseContent 15 | implements Serializable, Cloneable 16 | { 17 | 18 | 19 | static { 20 | 21 | PersistenceService.setPersistenceDelegate( 22 | X500Principal.class, 23 | 24 | new DefaultPersistenceDelegate(new String[] { "name" })); // NOI18N 25 | } 26 | 27 | 28 | 29 | 30 | private X500Principal holder; 31 | private X500Principal issuer; 32 | private String subject; 33 | private Date issued; 34 | private Date notBefore; 35 | private Date notAfter; 36 | private String consumerType; 37 | private int consumerAmount = 1; 38 | private String info; 39 | private Object extra; 40 | private transient PropertyChangeSupport propertySupport; 41 | 42 | /** 43 | * @deprecated 44 | */ 45 | protected Object clone() 46 | { 47 | try 48 | { 49 | LicenseContent localLicenseContent = (LicenseContent)super.clone(); 50 | localLicenseContent.issued = ((Date)this.issued.clone()); 51 | localLicenseContent.notBefore = ((Date)this.notBefore.clone()); 52 | localLicenseContent.notAfter = ((Date)this.notAfter.clone()); 53 | return localLicenseContent; 54 | } 55 | catch (CloneNotSupportedException localCloneNotSupportedException) 56 | { 57 | throw new AssertionError(localCloneNotSupportedException); 58 | } 59 | } 60 | 61 | public X500Principal getHolder() 62 | { 63 | return this.holder; 64 | } 65 | 66 | public synchronized void setHolder(X500Principal paramX500Principal) 67 | { 68 | X500Principal localX500Principal = this.holder; 69 | this.holder = paramX500Principal; 70 | firePropertyChange("holder", localX500Principal, paramX500Principal); 71 | } 72 | 73 | public X500Principal getIssuer() 74 | { 75 | return this.issuer; 76 | } 77 | 78 | public synchronized void setIssuer(X500Principal paramX500Principal) 79 | { 80 | X500Principal localX500Principal = this.issuer; 81 | this.issuer = paramX500Principal; 82 | firePropertyChange("issuer", localX500Principal, paramX500Principal); 83 | } 84 | 85 | public String getSubject() 86 | { 87 | return this.subject; 88 | } 89 | 90 | public synchronized void setSubject(String paramString) 91 | { 92 | String str = this.subject; 93 | this.subject = paramString; 94 | firePropertyChange("subject", str, paramString); 95 | } 96 | 97 | public Date getIssued() 98 | { 99 | return this.issued; 100 | } 101 | 102 | public void setIssued(Date paramDate) 103 | { 104 | Date localDate = this.issued; 105 | this.issued = paramDate; 106 | firePropertyChange("issued", localDate, paramDate); 107 | } 108 | 109 | public Date getNotBefore() 110 | { 111 | return this.notBefore; 112 | } 113 | 114 | public void setNotBefore(Date paramDate) 115 | { 116 | Date localDate = this.notBefore; 117 | this.notBefore = paramDate; 118 | firePropertyChange("notBefore", localDate, paramDate); 119 | } 120 | 121 | public Date getNotAfter() 122 | { 123 | return this.notAfter; 124 | } 125 | 126 | public void setNotAfter(Date paramDate) 127 | { 128 | Date localDate = this.notAfter; 129 | this.notAfter = paramDate; 130 | firePropertyChange("notAfter", localDate, paramDate); 131 | } 132 | 133 | public String getConsumerType() 134 | { 135 | return this.consumerType; 136 | } 137 | 138 | public void setConsumerType(String paramString) 139 | { 140 | String str = this.consumerType; 141 | this.consumerType = paramString; 142 | firePropertyChange("consumerType", str, paramString); 143 | } 144 | 145 | public int getConsumerAmount() 146 | { 147 | return this.consumerAmount; 148 | } 149 | 150 | public void setConsumerAmount(int paramInt) 151 | { 152 | int i = this.consumerAmount; 153 | this.consumerAmount = paramInt; 154 | firePropertyChange("consumerAmount", new Integer(i), new Integer(paramInt)); 155 | } 156 | 157 | public String getInfo() 158 | { 159 | return this.info; 160 | } 161 | 162 | public void setInfo(String paramString) 163 | { 164 | String str = this.info; 165 | this.info = paramString; 166 | firePropertyChange("info", str, paramString); 167 | } 168 | 169 | public Object getExtra() 170 | { 171 | return this.extra; 172 | } 173 | 174 | public void setExtra(Object paramObject) 175 | { 176 | Object localObject = this.extra; 177 | this.extra = paramObject; 178 | firePropertyChange("extra", localObject, paramObject); 179 | } 180 | 181 | public int hashCode() 182 | { 183 | return getConsumerAmount() + hashCode(getConsumerType()) + hashCode(getHolder()) + hashCode(getInfo()) + hashCode(getIssued()) + hashCode(getIssuer()) + hashCode(getNotAfter()) + hashCode(getNotBefore()) + hashCode(getSubject()); 184 | } 185 | 186 | private static final int hashCode(Object paramObject) 187 | { 188 | return paramObject != null ? paramObject.hashCode() : 0; 189 | } 190 | 191 | public boolean equals(Object paramObject) 192 | { 193 | if (!(paramObject instanceof LicenseContent)) { 194 | return false; 195 | } 196 | LicenseContent localLicenseContent = (LicenseContent)paramObject; 197 | return (localLicenseContent.getConsumerAmount() == getConsumerAmount()) && (isNullOrEquals(localLicenseContent.getConsumerType(), getConsumerType())) && (isNullOrEquals(localLicenseContent.getHolder(), getHolder())) && (isNullOrEquals(localLicenseContent.getInfo(), getInfo())) && (isNullOrEquals(localLicenseContent.getIssued(), getIssued())) && (isNullOrEquals(localLicenseContent.getIssuer(), getIssuer())) && (isNullOrEquals(localLicenseContent.getNotAfter(), getNotAfter())) && (isNullOrEquals(localLicenseContent.getNotBefore(), getNotBefore())) && (isNullOrEquals(localLicenseContent.getSubject(), getSubject())); 198 | } 199 | 200 | private static final boolean isNullOrEquals(Object paramObject1, Object paramObject2) 201 | { 202 | return paramObject2 == null ? true : paramObject1 != null ? paramObject1.equals(paramObject2) : false; 203 | } 204 | 205 | public final synchronized void addPropertyChangeListener(PropertyChangeListener paramPropertyChangeListener) 206 | { 207 | if (this.propertySupport == null) { 208 | this.propertySupport = new PropertyChangeSupport(this); 209 | } 210 | this.propertySupport.addPropertyChangeListener(paramPropertyChangeListener); 211 | } 212 | 213 | public final synchronized void removePropertyChangeListener(PropertyChangeListener paramPropertyChangeListener) 214 | { 215 | if (this.propertySupport == null) { 216 | return; 217 | } 218 | this.propertySupport.removePropertyChangeListener(paramPropertyChangeListener); 219 | } 220 | 221 | protected final void firePropertyChange(PropertyChangeEvent paramPropertyChangeEvent) 222 | { 223 | if (this.propertySupport == null) { 224 | return; 225 | } 226 | this.propertySupport.firePropertyChange(paramPropertyChangeEvent); 227 | } 228 | 229 | protected final void firePropertyChange(String paramString, Object paramObject1, Object paramObject2) 230 | { 231 | if (this.propertySupport == null) { 232 | return; 233 | } 234 | this.propertySupport.firePropertyChange(paramString, paramObject1, paramObject2); 235 | } 236 | 237 | } 238 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/xml/PersistenceService.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.xml; 2 | 3 | import java.beans.Encoder; 4 | import java.beans.ExceptionListener; 5 | import java.beans.PersistenceDelegate; 6 | import java.beans.XMLDecoder; 7 | import java.beans.XMLEncoder; 8 | import java.io.BufferedInputStream; 9 | import java.io.BufferedOutputStream; 10 | import java.io.ByteArrayInputStream; 11 | import java.io.ByteArrayOutputStream; 12 | import java.io.File; 13 | import java.io.FileInputStream; 14 | import java.io.FileOutputStream; 15 | import java.io.InputStream; 16 | import java.io.OutputStream; 17 | import java.io.UnsupportedEncodingException; 18 | import java.lang.reflect.UndeclaredThrowableException; 19 | import java.util.HashMap; 20 | import java.util.Iterator; 21 | import java.util.Map; 22 | import java.util.Map.Entry; 23 | import java.util.Set; 24 | 25 | public class PersistenceService 26 | implements XMLConstants 27 | { 28 | private static final HashMap allPDs = new HashMap(); 29 | public static int BUFSIZE = 10240; 30 | 31 | private static final ExceptionListener createExceptionListener() 32 | { 33 | return new ExceptionListener() 34 | { 35 | public void exceptionThrown(Exception paramAnonymousException) 36 | { 37 | throw ((paramAnonymousException instanceof UndeclaredThrowableException) ? (UndeclaredThrowableException)paramAnonymousException : new UndeclaredThrowableException(paramAnonymousException)); 38 | } 39 | }; 40 | } 41 | 42 | public static final synchronized void setPersistenceDelegate(Class paramClass, PersistenceDelegate paramPersistenceDelegate) 43 | { 44 | allPDs.put(paramClass, paramPersistenceDelegate); 45 | } 46 | 47 | protected static synchronized void installPersistenceDelegates(Encoder paramEncoder) 48 | { 49 | Iterator localIterator = allPDs.entrySet().iterator(); 50 | while (localIterator.hasNext()) 51 | { 52 | Map.Entry localEntry = (Map.Entry)localIterator.next(); 53 | paramEncoder.setPersistenceDelegate((Class)localEntry.getKey(), (PersistenceDelegate)localEntry.getValue()); 54 | } 55 | } 56 | 57 | public static void store(Object paramObject, OutputStream paramOutputStream) 58 | throws NullPointerException, PersistenceServiceException 59 | { 60 | if (paramOutputStream == null) { 61 | throw new NullPointerException(); 62 | } 63 | try 64 | { 65 | BufferedOutputStream localBufferedOutputStream = null; 66 | XMLEncoder localXMLEncoder = null; 67 | try 68 | { 69 | localBufferedOutputStream = new BufferedOutputStream(paramOutputStream, BUFSIZE); 70 | localXMLEncoder = new XMLEncoder(localBufferedOutputStream); 71 | installPersistenceDelegates(localXMLEncoder); 72 | localXMLEncoder.setExceptionListener(createExceptionListener()); 73 | if (paramObject != null) { 74 | synchronized (paramObject) 75 | { 76 | localXMLEncoder.writeObject(paramObject); 77 | } 78 | } 79 | localXMLEncoder.writeObject(paramObject); 80 | } 81 | finally 82 | { 83 | if (localXMLEncoder != null) { 84 | try 85 | { 86 | localXMLEncoder.close(); 87 | } 88 | catch (Throwable localThrowable2) 89 | { 90 | localBufferedOutputStream.close(); 91 | throw localThrowable2; 92 | } 93 | } else if (localBufferedOutputStream != null) { 94 | localBufferedOutputStream.close(); 95 | } else { 96 | paramOutputStream.close(); 97 | } 98 | } 99 | } 100 | catch (UndeclaredThrowableException localUndeclaredThrowableException) 101 | { 102 | throw new PersistenceServiceException(localUndeclaredThrowableException.getCause()); 103 | } 104 | catch (Throwable localThrowable1) 105 | { 106 | throw new PersistenceServiceException(localThrowable1); 107 | } 108 | } 109 | 110 | public static void store(Object paramObject, File paramFile) 111 | throws NullPointerException, PersistenceServiceException 112 | { 113 | if (paramFile == null) { 114 | throw new NullPointerException(); 115 | } 116 | File localFile = null; 117 | boolean bool = false; 118 | try 119 | { 120 | localFile = getRenamedFile(paramFile); 121 | bool = paramFile.renameTo(localFile); 122 | store(paramObject, new FileOutputStream(paramFile)); 123 | if (bool) { 124 | localFile.delete(); 125 | } 126 | } 127 | catch (Throwable localThrowable1) 128 | { 129 | Throwable localObject = null; 130 | if (bool) 131 | { 132 | try 133 | { 134 | paramFile.delete(); 135 | } 136 | catch (Throwable localThrowable2) 137 | { 138 | localObject = localThrowable2; 139 | } 140 | try 141 | { 142 | localFile.renameTo(paramFile); 143 | } 144 | catch (Throwable localThrowable3) 145 | { 146 | localObject = localThrowable3; 147 | } 148 | } 149 | throw ((localObject instanceof PersistenceServiceException) ? (PersistenceServiceException)localObject : new PersistenceServiceException(localObject)); 150 | } 151 | } 152 | 153 | private static File getRenamedFile(File paramFile) 154 | { 155 | String str = paramFile.getPath(); 156 | File localFile; 157 | do 158 | { 159 | str = str + '~'; 160 | localFile = new File(str); 161 | } while (localFile.exists()); 162 | return localFile; 163 | } 164 | 165 | public static byte[] store2ByteArray(Object paramObject) 166 | throws PersistenceServiceException 167 | { 168 | try 169 | { 170 | ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream(); 171 | store(paramObject, localByteArrayOutputStream); 172 | return localByteArrayOutputStream.toByteArray(); 173 | } 174 | catch (PersistenceServiceException localPersistenceServiceException) 175 | { 176 | throw localPersistenceServiceException; 177 | } 178 | catch (Throwable localThrowable) 179 | { 180 | throw new PersistenceServiceException(localThrowable); 181 | } 182 | } 183 | 184 | public static String store2String(Object paramObject) 185 | throws PersistenceServiceException 186 | { 187 | try 188 | { 189 | ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream(); 190 | store(paramObject, localByteArrayOutputStream); 191 | return localByteArrayOutputStream.toString("UTF-8"); 192 | } 193 | catch (UnsupportedEncodingException localUnsupportedEncodingException) 194 | { 195 | throw new AssertionError(localUnsupportedEncodingException); 196 | } 197 | catch (PersistenceServiceException localPersistenceServiceException) 198 | { 199 | throw localPersistenceServiceException; 200 | } 201 | catch (Throwable localThrowable) 202 | { 203 | throw new PersistenceServiceException(localThrowable); 204 | } 205 | } 206 | 207 | public static Object load(InputStream paramInputStream) 208 | throws NullPointerException, PersistenceServiceException 209 | { 210 | if (paramInputStream == null) { 211 | throw new NullPointerException(); 212 | } 213 | XMLDecoder localXMLDecoder = null; 214 | try 215 | { 216 | localXMLDecoder = new XMLDecoder(new BufferedInputStream(paramInputStream, BUFSIZE), null, createExceptionListener()); 217 | Object localObject1 = localXMLDecoder.readObject(); 218 | return localObject1; 219 | } 220 | catch (UndeclaredThrowableException localUndeclaredThrowableException) 221 | { 222 | throw new PersistenceServiceException(localUndeclaredThrowableException.getCause()); 223 | } 224 | catch (Throwable localThrowable1) 225 | { 226 | throw new PersistenceServiceException(localThrowable1); 227 | } 228 | finally 229 | { 230 | if (localXMLDecoder != null) { 231 | try 232 | { 233 | localXMLDecoder.close(); 234 | } 235 | catch (Throwable localThrowable2) 236 | { 237 | throw new PersistenceServiceException(localThrowable2); 238 | } 239 | } 240 | } 241 | } 242 | 243 | public static Object load(File paramFile) 244 | throws NullPointerException, PersistenceServiceException 245 | { 246 | if (paramFile == null) { 247 | throw new NullPointerException(); 248 | } 249 | try 250 | { 251 | return load(new FileInputStream(paramFile)); 252 | } 253 | catch (PersistenceServiceException localPersistenceServiceException) 254 | { 255 | throw localPersistenceServiceException; 256 | } 257 | catch (Throwable localThrowable) 258 | { 259 | throw new PersistenceServiceException(localThrowable); 260 | } 261 | } 262 | 263 | public static Object load(byte[] paramArrayOfByte) 264 | throws NullPointerException, PersistenceServiceException 265 | { 266 | if (paramArrayOfByte == null) { 267 | throw new NullPointerException(); 268 | } 269 | try 270 | { 271 | return load(new ByteArrayInputStream(paramArrayOfByte)); 272 | } 273 | catch (PersistenceServiceException localPersistenceServiceException) 274 | { 275 | throw localPersistenceServiceException; 276 | } 277 | catch (Throwable localThrowable) 278 | { 279 | throw new PersistenceServiceException(localThrowable); 280 | } 281 | } 282 | 283 | public static Object load(String paramString) 284 | throws NullPointerException, PersistenceServiceException 285 | { 286 | if (paramString == null) { 287 | throw new NullPointerException(); 288 | } 289 | try 290 | { 291 | return load(paramString.getBytes("UTF-8")); 292 | } 293 | catch (UnsupportedEncodingException localUnsupportedEncodingException) 294 | { 295 | throw new AssertionError(localUnsupportedEncodingException); 296 | } 297 | catch (PersistenceServiceException localPersistenceServiceException) 298 | { 299 | throw localPersistenceServiceException; 300 | } 301 | catch (Throwable localThrowable) 302 | { 303 | throw new PersistenceServiceException(localThrowable); 304 | } 305 | } 306 | } 307 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/LocalLicenseManager.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | /* 3 | * LicenseManager.java 4 | * 5 | * Created on 22. Februar 2005, 13:27 6 | */ 7 | /* 8 | * Copyright 2005 Schlichtherle IT Services 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | 24 | 25 | import java.net.URISyntaxException; 26 | import java.util.*; 27 | import java.util.prefs.*; 28 | 29 | import javax.swing.filechooser.FileFilter; 30 | 31 | import zlicense.de.schlichtherle.license.LicenseContent; 32 | import zlicense.de.schlichtherle.license.LicenseNotary; 33 | import zlicense.de.schlichtherle.license.Resources; 34 | import zlicense.de.schlichtherle.util.ObfuscatedString; 35 | import zlicense.de.schlichtherle.xml.*; 36 | 37 | 38 | 39 | 40 | /** 41 | * This is the top level class which manages all licensing aspects like for 42 | * instance the creation, installation and verification of license keys. 43 | * The license manager knows how to install, verify and uninstall full and 44 | * trial licenses for a given subject and ensures the privacy of the license 45 | * content in its persistent form (i.e. the license key). 46 | * For signing, verifying and validating licenses, this class cooperates with 47 | * a {@link LicenseNotary}. 48 | *

49 | * This class is designed to be thread safe. 50 | * 51 | * @author Christian Schlichtherle 52 | */ 53 | public class LocalLicenseManager extends zlicense.de.schlichtherle.license.LicenseManager { 54 | /** The timeout for the license content cache. */ 55 | private static final long TIMEOUT = 30 * 60 * 1000; // half an hour 56 | 57 | /** The key in the preferences used to store the license key. */ 58 | private static final String PREFERENCES_KEY 59 | = new ObfuscatedString(new long[] { 60 | 0xD65FA96737AE2CB5L, 0xE804D1A38CF9A413L 61 | }).toString(); /* => "license" */ 62 | 63 | /** 64 | * The suffix for files which hold license certificates. 65 | */ 66 | public static final String LICENSE_SUFFIX 67 | = new ObfuscatedString(new long[] { 68 | 0x97187B3A07E79CEEL, 0x469144B7E0D475E2L 69 | }).toString(); /* => ".lic" - must be lowercase! */ 70 | static { 71 | assert LICENSE_SUFFIX.equals(LICENSE_SUFFIX.toLowerCase()); // paranoid 72 | } 73 | 74 | private static final String PARAM = LicenseNotary.PARAM; 75 | 76 | private static final String SUBJECT = new ObfuscatedString(new long[] { 77 | 0xA1CB7D9B4D5E81E4L, 0xD9500F23E58132B6L 78 | }).toString(); /* => "subject" */ 79 | 80 | private static final String KEY_STORE_PARAM = new ObfuscatedString(new long[] { 81 | 0x449C8CDCBA1A80CEL, 0x6FEE3A101634D30BL, 0xD9D7B61A44A2606CL 82 | }).toString(); /* => "keyStoreParam" */ 83 | 84 | private static final String CIPHER_PARAM = new ObfuscatedString(new long[] { 85 | 0xCD54DEE1845B54E4L, 0x1AC47C8C827054BCL, 0x16E53B3A590D62B6L 86 | }).toString(); /* => "cipherParam" */ 87 | 88 | protected static final String CN = new ObfuscatedString(new long[] { 89 | 0x636F59E1FF007F64L, 0xAC9CE58690A43DD0L 90 | }).toString(); /* => "CN=" */ 91 | 92 | private static final String CN_USER = CN + Resources.getString( 93 | new ObfuscatedString(new long[] { 94 | 0xF3BE4EA2CCDD7EADL, 0x5B6A9F59A1183108L 95 | }).toString()); /* => "user" */ 96 | 97 | private static final String USER = new ObfuscatedString(new long[] { 98 | 0x9F89522C9F6F4A13L, 0xFFDB7A316241AC79L 99 | }).toString(); /* => "User" */ 100 | 101 | private static final String SYSTEM = new ObfuscatedString(new long[] { 102 | 0xEC006BE1C1F75BD6L, 0x54D650CDD244774BL 103 | }).toString(); /* => "System" */ 104 | 105 | private static final String EXC_INVALID_SUBJECT = new ObfuscatedString(new long[] { 106 | 0x8029CDF4E32A76ECL, 0x56FA623D9AEE8C1L, 0x99E7882A708663ACL, 107 | 0x5888C0D72E548FF4L 108 | }).toString(); /* => "exc.invalidSubject" */ 109 | 110 | private static final String EXC_HOLDER_IS_NULL = new ObfuscatedString(new long[] { 111 | 0x6339FEFCDFD84427L, 0x57A2FA0735E47CBEL, 0xED1D06E6EED72950L 112 | }).toString(); /* => "exc.holderIsNull" */ 113 | 114 | private static final String EXC_ISSUER_IS_NULL = new ObfuscatedString(new long[] { 115 | 0xD5E29AC879334756L, 0xF1F7421CD6A06536L, 0x5E086D6468FECBF2L 116 | }).toString(); /* => "exc.issuerIsNull" */ 117 | 118 | private static final String EXC_ISSUED_IS_NULL = new ObfuscatedString(new long[] { 119 | 0xAB8FF89F2DA6C32CL, 0x2A089A9CA80D970EL, 0xCF15F8842FCCD9D5L 120 | }).toString(); /* => "exc.issuedIsNull" */ 121 | 122 | private static final String EXC_LICENSE_IS_NOT_YET_VALID = new ObfuscatedString(new long[] { 123 | 0x4B6BB2804EE7DDB1L, 0xD0BB0A33A41543C5L, 0x5FCEC6DF3725CEE4L, 124 | 0xA165775BBD625344L 125 | }).toString(); /* => "exc.licenseIsNotYetValid" */ 126 | 127 | private static final String EXC_LICENSE_HAS_EXPIRED = new ObfuscatedString(new long[] { 128 | 0xDE2B2A7ACD6DA6DL, 0x9EE12DDECB3D4C0DL, 0xB3CF760B522E8688L, 129 | 0x316BD3E92C17CC40L 130 | }).toString(); /* => "exc.licenseHasExpired" */ 131 | 132 | private static final String EXC_CONSUMER_TYPE_IS_NULL = new ObfuscatedString(new long[] { 133 | 0xD29019F7B1D95C66L, 0xE859C44ACC3EB2FEL, 0xF041027C9003B031L, 134 | 0x27E84AD8870D6063L 135 | }).toString(); /* => "exc.consumerTypeIsNull" */ 136 | 137 | private static final String EXC_CONSUMER_TYPE_IS_NOT_USER = new ObfuscatedString(new long[] { 138 | 0xCE99D49CE98D1E47L, 0x7A3BA300A7DFCEABL, 0x2D2E4B624AD7C4E0L, 139 | 0x2C86A28A075E71C6L, 0x79BCB920E5FB351DL 140 | }).toString(); /* => "exc.consumerTypeIsNotUser" */ 141 | 142 | private static final String EXC_CONSUMER_AMOUNT_IS_NOT_ONE = new ObfuscatedString(new long[] { 143 | 0x5F20CBB98126BB0AL, 0xE8BB696B25D24011L, 0x435CC3AA7263BAE7L, 144 | 0x9DA3066F501717E4L, 0x62FFA4899FBBA3F8L 145 | }).toString(); /* => "exc.consumerAmountIsNotOne" */ 146 | 147 | private static final String EXC_CONSUMER_AMOUNT_IS_NOT_POSITIVE = new ObfuscatedString(new long[] { 148 | 0xB14EB6259B4D7249L, 0xCD02F577511528D8L, 0x39B8CF1E258756DDL, 149 | 0x67488F05891DF916L, 0x4256DE0CFFF62DCAL 150 | }).toString(); /* => "exc.consumerAmountIsNotPositive" */ 151 | 152 | private static final String FILE_FILTER_DESCRIPTION = new ObfuscatedString(new long[] { 153 | 0x2BDDE408C7B71604L, 0xDFCA7DA8912DE4C1L, 0xADA1FC1C1D5F1047L, 154 | 0xD08EAA6CCDC342F3L 155 | }).toString(); /* => "fileFilter.description" */ 156 | 157 | private static final String FILE_FILTER_SUFFIX = new ObfuscatedString(new long[] { 158 | 0xA4BCC907D9FD1290L, 0x614A0A9015D3D8DDL 159 | }).toString(); /* => " (*.lic)" */ 160 | 161 | /** 162 | * Returns midnight local time today. 163 | */ 164 | 165 | private LicenseParam param; // initialized by setLicenseParam() - should be accessed via getLicenseParam() only! 166 | 167 | // 168 | // Data computed and cached from the license configuration parameters. 169 | // 170 | 171 | private LicenseNotary notary; // lazy initialized 172 | 173 | private PrivacyGuard guard; // lazy initialized 174 | 175 | /** The cached certificate of the current license key. */ 176 | private GenericCertificate certificate; // lazy initialized 177 | 178 | /** The time when the certificate was last set. */ 179 | private long certificateTime; // lazy initialized 180 | 181 | /** A suitable file filter for the subject of this license manager. */ 182 | private FileFilter fileFilter; // lazy initialized 183 | 184 | /** The preferences node used to store the license key. */ 185 | private Preferences preferences; // lazy initialized 186 | public LocalLicenseManager() throws URISyntaxException { 187 | super(); 188 | // TODO Auto-generated constructor stub 189 | } 190 | public LocalLicenseManager(LicenseParam param) 191 | throws NullPointerException, 192 | IllegalPasswordException { 193 | setLicenseParam(param); 194 | } 195 | /** 196 | * 197 | */ 198 | private static final long serialVersionUID = 1L; 199 | 200 | protected synchronized void validate(final LicenseContent content) 201 | throws LicenseContentException { 202 | final LicenseParam param = getLicenseParam(); 203 | if (!param.getSubject().equals(content.getSubject())) 204 | throw new LicenseContentException(EXC_INVALID_SUBJECT); 205 | if (content.getHolder() == null) 206 | throw new LicenseContentException(EXC_HOLDER_IS_NULL); 207 | if (content.getIssuer() == null) 208 | throw new LicenseContentException(EXC_ISSUER_IS_NULL); 209 | if (content.getIssued() == null) 210 | throw new LicenseContentException(EXC_ISSUED_IS_NULL); 211 | final Date now = new Date(); 212 | final Date notBefore = content.getNotBefore(); 213 | if (notBefore != null && now.before(notBefore)) 214 | throw new LicenseContentException(EXC_LICENSE_IS_NOT_YET_VALID); 215 | final Date notAfter = content.getNotAfter(); 216 | // if (notAfter != null && now.after(notAfter)) 217 | // throw new LicenseContentException(EXC_LICENSE_HAS_EXPIRED); 218 | final String consumerType = content.getConsumerType(); 219 | if (consumerType == null) 220 | throw new LicenseContentException(EXC_CONSUMER_TYPE_IS_NULL); 221 | final Preferences prefs = param.getPreferences(); 222 | if (prefs != null && prefs.isUserNode()) { 223 | if (!USER.equalsIgnoreCase(consumerType)) 224 | throw new LicenseContentException(EXC_CONSUMER_TYPE_IS_NOT_USER); 225 | if (content.getConsumerAmount() != 1) 226 | throw new LicenseContentException(EXC_CONSUMER_AMOUNT_IS_NOT_ONE); 227 | } else { 228 | if (content.getConsumerAmount() <= 0) 229 | throw new LicenseContentException(EXC_CONSUMER_AMOUNT_IS_NOT_POSITIVE); 230 | } 231 | } 232 | } 233 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/xml/GenericCertificate.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.xml; 2 | 3 | import java.beans.PropertyChangeEvent; 4 | import java.beans.PropertyChangeListener; 5 | import java.beans.PropertyChangeSupport; 6 | import java.beans.PropertyVetoException; 7 | import java.beans.VetoableChangeListener; 8 | import java.beans.VetoableChangeSupport; 9 | import java.io.Serializable; 10 | import java.io.UnsupportedEncodingException; 11 | import java.security.InvalidKeyException; 12 | import java.security.PrivateKey; 13 | import java.security.PublicKey; 14 | import java.security.Signature; 15 | import java.security.SignatureException; 16 | import org.apache.commons.codec.binary.Base64; 17 | 18 | public final class GenericCertificate 19 | implements Serializable, XMLConstants 20 | { 21 | private static final String BASE64_CHARSET = "US-ASCII"; 22 | private static final String SIGNATURE_ENCODING = "US-ASCII/Base64"; 23 | private transient boolean locked; 24 | private String encoded; 25 | private String signature; 26 | private String signatureAlgorithm; 27 | private String signatureEncoding; 28 | private transient PropertyChangeSupport propertyChangeSupport; 29 | private transient VetoableChangeSupport vetoableChangeSupport; 30 | 31 | public GenericCertificate() {} 32 | 33 | public GenericCertificate(GenericCertificate paramGenericCertificate) 34 | { 35 | try 36 | { 37 | setEncoded(paramGenericCertificate.getEncoded()); 38 | setSignature(paramGenericCertificate.getSignature()); 39 | setSignatureAlgorithm(paramGenericCertificate.getSignatureAlgorithm()); 40 | setSignatureEncoding(paramGenericCertificate.getSignatureEncoding()); 41 | } 42 | catch (PropertyVetoException localPropertyVetoException) 43 | { 44 | throw new AssertionError(localPropertyVetoException); 45 | } 46 | } 47 | 48 | public final synchronized void sign(Object paramObject, PrivateKey paramPrivateKey, Signature paramSignature) 49 | throws NullPointerException, GenericCertificateIsLockedException, PropertyVetoException, PersistenceServiceException, InvalidKeyException 50 | { 51 | if (paramPrivateKey == null) { 52 | throw new NullPointerException("signingKey"); 53 | } 54 | if (paramSignature == null) { 55 | throw new NullPointerException("signingEngine"); 56 | } 57 | PropertyChangeEvent localPropertyChangeEvent = new PropertyChangeEvent(this, "locked", Boolean.valueOf(isLocked()), Boolean.TRUE); 58 | if (isLocked()) { 59 | throw new GenericCertificateIsLockedException(localPropertyChangeEvent); 60 | } 61 | fireVetoableChange(localPropertyChangeEvent); 62 | try 63 | { 64 | byte[] arrayOfByte1 = PersistenceService.store2ByteArray(paramObject); 65 | paramSignature.initSign(paramPrivateKey); 66 | paramSignature.update(arrayOfByte1); 67 | byte[] arrayOfByte2 = Base64.encodeBase64(paramSignature.sign()); 68 | String str = new String(arrayOfByte2, 0, arrayOfByte2.length, "US-ASCII"); 69 | setEncoded(new String(arrayOfByte1, "UTF-8")); 70 | setSignature(str); 71 | setSignatureAlgorithm(paramSignature.getAlgorithm()); 72 | setSignatureEncoding("US-ASCII/Base64"); 73 | } 74 | catch (UnsupportedEncodingException localUnsupportedEncodingException) 75 | { 76 | throw new AssertionError(localUnsupportedEncodingException); 77 | } 78 | catch (SignatureException localSignatureException) 79 | { 80 | throw new AssertionError(localSignatureException); 81 | } 82 | this.locked = true; 83 | firePropertyChange(localPropertyChangeEvent); 84 | } 85 | 86 | public final synchronized void verify(PublicKey paramPublicKey, Signature paramSignature) 87 | throws NullPointerException, GenericCertificateIsLockedException, PropertyVetoException, InvalidKeyException, SignatureException, GenericCertificateIntegrityException 88 | { 89 | if (paramPublicKey == null) { 90 | throw new NullPointerException("verificationKey"); 91 | } 92 | if (paramSignature == null) { 93 | throw new NullPointerException("verificationEngine"); 94 | } 95 | PropertyChangeEvent localPropertyChangeEvent = new PropertyChangeEvent(this, "locked", Boolean.valueOf(isLocked()), Boolean.TRUE); 96 | if (isLocked()) { 97 | throw new GenericCertificateIsLockedException(localPropertyChangeEvent); 98 | } 99 | fireVetoableChange(localPropertyChangeEvent); 100 | try 101 | { 102 | byte[] arrayOfByte1 = getEncoded().getBytes("UTF-8"); 103 | paramSignature.initVerify(paramPublicKey); 104 | paramSignature.update(arrayOfByte1); 105 | byte[] arrayOfByte2 = Base64.decodeBase64(getSignature().getBytes("US-ASCII")); 106 | if (!paramSignature.verify(arrayOfByte2)) { 107 | throw new GenericCertificateIntegrityException(); 108 | } 109 | setSignatureAlgorithm(paramSignature.getAlgorithm()); 110 | setSignatureEncoding("US-ASCII/Base64"); 111 | } 112 | catch (UnsupportedEncodingException localUnsupportedEncodingException) 113 | { 114 | throw new AssertionError(localUnsupportedEncodingException); 115 | } 116 | this.locked = true; 117 | firePropertyChange(localPropertyChangeEvent); 118 | } 119 | 120 | public final boolean isLocked() 121 | { 122 | return this.locked; 123 | } 124 | 125 | public Object getContent() 126 | throws GenericCertificateNotLockedException, PersistenceServiceException 127 | { 128 | if (!isLocked()) { 129 | throw new GenericCertificateNotLockedException(); 130 | } 131 | return PersistenceService.load(getEncoded()); 132 | } 133 | 134 | public final String getEncoded() 135 | { 136 | return this.encoded; 137 | } 138 | 139 | public synchronized void setEncoded(String paramString) 140 | throws GenericCertificateIsLockedException 141 | { 142 | if (paramString == null) 143 | { 144 | if (this.encoded != null) {} 145 | } 146 | else if (paramString.equals(this.encoded)) { 147 | return; 148 | } 149 | PropertyChangeEvent localPropertyChangeEvent = new PropertyChangeEvent(this, "encoded", getEncoded(), paramString); 150 | if (isLocked()) { 151 | throw new GenericCertificateIsLockedException(localPropertyChangeEvent); 152 | } 153 | this.encoded = paramString; 154 | firePropertyChange(localPropertyChangeEvent); 155 | } 156 | 157 | public final String getSignature() 158 | { 159 | return this.signature; 160 | } 161 | 162 | public synchronized void setSignature(String paramString) 163 | throws GenericCertificateIsLockedException 164 | { 165 | if (paramString == null) 166 | { 167 | if (this.signature != null) {} 168 | } 169 | else if (paramString.equals(this.signature)) { 170 | return; 171 | } 172 | PropertyChangeEvent localPropertyChangeEvent = new PropertyChangeEvent(this, "signature", getSignature(), paramString); 173 | if (isLocked()) { 174 | throw new GenericCertificateIsLockedException(localPropertyChangeEvent); 175 | } 176 | this.signature = paramString; 177 | firePropertyChange(localPropertyChangeEvent); 178 | } 179 | 180 | public final String getSignatureAlgorithm() 181 | { 182 | return this.signatureAlgorithm; 183 | } 184 | 185 | public synchronized void setSignatureAlgorithm(String paramString) 186 | throws GenericCertificateIsLockedException 187 | { 188 | if (paramString == null) 189 | { 190 | if (this.signatureAlgorithm != null) {} 191 | } 192 | else if (paramString.equals(this.signatureAlgorithm)) { 193 | return; 194 | } 195 | PropertyChangeEvent localPropertyChangeEvent = new PropertyChangeEvent(this, "signatureAlgorithm", getSignatureAlgorithm(), paramString); 196 | if (isLocked()) { 197 | throw new GenericCertificateIsLockedException(localPropertyChangeEvent); 198 | } 199 | this.signatureAlgorithm = paramString; 200 | firePropertyChange(localPropertyChangeEvent); 201 | } 202 | 203 | public final String getSignatureEncoding() 204 | { 205 | return this.signatureEncoding; 206 | } 207 | 208 | /** 209 | * @deprecated 210 | */ 211 | public synchronized void setSignatureEncoding(String paramString) 212 | throws GenericCertificateIsLockedException 213 | { 214 | if (paramString == null) 215 | { 216 | if (this.signatureEncoding != null) {} 217 | } 218 | else if (paramString.equals(this.signatureEncoding)) { 219 | return; 220 | } 221 | PropertyChangeEvent localPropertyChangeEvent = new PropertyChangeEvent(this, "signatureEncoding", getSignatureEncoding(), paramString); 222 | if (isLocked()) { 223 | throw new GenericCertificateIsLockedException(localPropertyChangeEvent); 224 | } 225 | this.signatureEncoding = paramString; 226 | firePropertyChange(localPropertyChangeEvent); 227 | } 228 | 229 | public final synchronized void addVetoableChangeListener(VetoableChangeListener paramVetoableChangeListener) 230 | { 231 | if (this.vetoableChangeSupport == null) { 232 | this.vetoableChangeSupport = new VetoableChangeSupport(this); 233 | } 234 | this.vetoableChangeSupport.addVetoableChangeListener(paramVetoableChangeListener); 235 | } 236 | 237 | public final void removeVetoableChangeListener(VetoableChangeListener paramVetoableChangeListener) 238 | { 239 | if (this.vetoableChangeSupport == null) { 240 | return; 241 | } 242 | this.vetoableChangeSupport.removeVetoableChangeListener(paramVetoableChangeListener); 243 | } 244 | 245 | protected final void fireVetoableChange(PropertyChangeEvent paramPropertyChangeEvent) 246 | throws PropertyVetoException 247 | { 248 | if (this.vetoableChangeSupport == null) { 249 | return; 250 | } 251 | this.vetoableChangeSupport.fireVetoableChange(paramPropertyChangeEvent); 252 | } 253 | 254 | public final synchronized void addPropertyChangeListener(PropertyChangeListener paramPropertyChangeListener) 255 | { 256 | if (this.propertyChangeSupport == null) { 257 | this.propertyChangeSupport = new PropertyChangeSupport(this); 258 | } 259 | this.propertyChangeSupport.addPropertyChangeListener(paramPropertyChangeListener); 260 | } 261 | 262 | public final void removePropertyChangeListener(PropertyChangeListener paramPropertyChangeListener) 263 | { 264 | if (this.propertyChangeSupport == null) { 265 | return; 266 | } 267 | this.propertyChangeSupport.removePropertyChangeListener(paramPropertyChangeListener); 268 | } 269 | 270 | protected final void firePropertyChange(PropertyChangeEvent paramPropertyChangeEvent) 271 | { 272 | if (this.propertyChangeSupport == null) { 273 | return; 274 | } 275 | this.propertyChangeSupport.firePropertyChange(paramPropertyChangeEvent); 276 | } 277 | } 278 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/PrivacyGuard.java.bak: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2012 Schlichtherle IT Services 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | */ 9 | package de.schlichtherle.license; 10 | 11 | import de.schlichtherle.util.ObfuscatedString; 12 | import de.schlichtherle.xml.GenericCertificate; 13 | import de.schlichtherle.xml.PersistenceService; 14 | import de.schlichtherle.xml.PersistenceServiceException; 15 | import java.io.ByteArrayInputStream; 16 | import java.io.ByteArrayOutputStream; 17 | import java.io.IOException; 18 | import java.io.InputStream; 19 | import java.io.OutputStream; 20 | import java.security.InvalidAlgorithmParameterException; 21 | import java.security.InvalidKeyException; 22 | import java.security.NoSuchAlgorithmException; 23 | import java.security.spec.AlgorithmParameterSpec; 24 | import java.security.spec.InvalidKeySpecException; 25 | import java.security.spec.KeySpec; 26 | import java.util.zip.GZIPInputStream; 27 | import java.util.zip.GZIPOutputStream; 28 | import javax.crypto.Cipher; 29 | import javax.crypto.CipherOutputStream; 30 | import javax.crypto.NoSuchPaddingException; 31 | import javax.crypto.SecretKey; 32 | import javax.crypto.SecretKeyFactory; 33 | import javax.crypto.spec.PBEKeySpec; 34 | import javax.crypto.spec.PBEParameterSpec; 35 | 36 | /** 37 | * This class provides encoding and encryption services to provide long time 38 | * persistence for {@link GenericCertificate}s and protect the privacy of its 39 | * data. 40 | *

41 | * This class is not thread safe. 42 | * 43 | * @author Christian Schlichtherle 44 | * @version $Id$ 45 | */ 46 | public class PrivacyGuard { 47 | 48 | private static final String PBE_WITH_MD5_AND_DES = new ObfuscatedString(new long[] { 49 | 0x27B2E8783E47F1ABL, 0x45CF8AD4390DC9D8L, 0xAB320350966BC9BFL 50 | }).toString(); /* => "PBEWithMD5AndDES" */ 51 | 52 | private CipherParam param; // initialized by setCipherParam() - should be accessed via getCipherParam() only! 53 | 54 | // 55 | // Data computed and cached from the cipher configuration parameters. 56 | // 57 | 58 | private Cipher cipher; 59 | private SecretKey key; 60 | private AlgorithmParameterSpec algoParamSpec; 61 | 62 | /** 63 | * Creates a new Privacy Guard. 64 | *

65 | * Warning: The guard created by this constructor is not 66 | * valid and cannot be used unless {@link #setCipherParam(CipherParam)} 67 | * is called! 68 | */ 69 | protected PrivacyGuard() { 70 | } 71 | 72 | /** 73 | * Creates a new Privacy Guard. 74 | * 75 | * @param param The cipher configuration parameters 76 | * - may not be {@code null}. 77 | */ 78 | public PrivacyGuard(CipherParam param) { 79 | setCipherParam0(param); 80 | } 81 | 82 | /** 83 | * Returns the cipher configuration parameters. 84 | */ 85 | public CipherParam getCipherParam() { 86 | return param; 87 | } 88 | 89 | /** 90 | * Sets the cipher configuration parameters. 91 | * Calling this method resets the guard as if it had been 92 | * newly created. 93 | * Some plausibility checks are applied to the given parameter object 94 | * to ensure that it adheres to the contract of the parameter interfaces. 95 | * 96 | * @param param the cipher configuration parameters 97 | * - may not be {@code null}. 98 | * @throws NullPointerException if the given parameter object does not 99 | * obey the contract of its interface due to a {@code null} 100 | * pointer. 101 | * @throws IllegalPasswordException if any password in the parameter object 102 | * does not comply to the current policy. 103 | */ 104 | public void setCipherParam(CipherParam param) { 105 | setCipherParam0(param); 106 | } 107 | 108 | private void setCipherParam0(CipherParam param) { 109 | // Check parameters to implement fail-fast behaviour. 110 | if (param == null) 111 | throw new NullPointerException(LicenseNotary.PARAM); 112 | Policy.getCurrent().checkPwd(param.getKeyPwd()); 113 | 114 | this.param = param; 115 | cipher = null; 116 | key = null; 117 | algoParamSpec = null; 118 | } 119 | 120 | /** 121 | * Encodes, compresses and encrypts the given license certificate 122 | * and returns the result as a license key. 123 | * Please note that this method does not sign the certificate. 124 | * 125 | * @param certificate The license certificate 126 | * - may not be {@code null}. 127 | * 128 | * @return The license key 129 | * - {@code null} is never returned. 130 | * 131 | * @throws Exception An instance of a subclass of this class for various 132 | * reasons. 133 | * Note that you should always use 134 | * {@link Throwable#getLocalizedMessage()} to get a (possibly 135 | * localized) meaningful detail message. 136 | */ 137 | public byte[] cert2key(final GenericCertificate certificate) 138 | throws Exception { 139 | // Encode the certificate and store it to a file. 140 | final ByteArrayOutputStream keyOut = new ByteArrayOutputStream(); 141 | final OutputStream out = new GZIPOutputStream( 142 | new CipherOutputStream( 143 | keyOut, 144 | getCipher4Encryption())); 145 | try { 146 | PersistenceService.store(certificate, out); 147 | } 148 | catch (PersistenceServiceException cannotHappen) { 149 | throw new AssertionError(cannotHappen); 150 | } 151 | return keyOut.toByteArray(); 152 | } 153 | 154 | /** 155 | * Decrypts, decompresses and decodes the given license key 156 | * and returns the result as a license certificate. 157 | * Please note that this method does not verify the certificate. 158 | * 159 | * @param key The license key to process 160 | * - may not be {@code null}. 161 | * 162 | * @return The license certificate 163 | * - {@code null} is never returned. 164 | * 165 | * @throws Exception An instance of a subclass of this class for various 166 | * reasons. 167 | * Note that you should always use 168 | * {@link Throwable#getLocalizedMessage()} to get a (possibly 169 | * localized) meaningful detail message. 170 | */ 171 | public GenericCertificate key2cert(final byte[] key) 172 | throws Exception { 173 | final InputStream in = new GZIPInputStream( 174 | new ByteArrayInputStream( 175 | getCipher4Decryption().doFinal(key))); 176 | final GenericCertificate certificate; 177 | try { 178 | certificate = (GenericCertificate) PersistenceService.load(in); 179 | } 180 | finally { 181 | try { in.close(); } 182 | catch (IOException weDontCare) { } 183 | } 184 | return certificate; 185 | } 186 | 187 | /** 188 | * Returns a cipher object which is initialised for encryption 189 | * - {@code null} is never returned. 190 | * 191 | * @deprecated Experimental: Methods marked with this note have 192 | * been tested to be functional but may change or disappear 193 | * at will in one of the next releases because they are still 194 | * a topic for research on extended functionality. 195 | * Most likely the methods will prevail however and this note 196 | * will just vanish, so you may use them with a certain risk. 197 | */ 198 | protected Cipher getCipher4Encryption() { 199 | Cipher cipher = getCipher(); 200 | try { 201 | cipher.init(Cipher.ENCRYPT_MODE, key, algoParamSpec); 202 | } 203 | catch (InvalidKeyException cannotHappen) { 204 | throw new AssertionError(cannotHappen); 205 | } 206 | catch (InvalidAlgorithmParameterException cannotHappen) { 207 | throw new AssertionError(cannotHappen); 208 | } 209 | 210 | return cipher; 211 | } 212 | 213 | /** 214 | * Returns a cipher object which is initialised for decryption 215 | * - {@code null} is never returned. 216 | * 217 | * @deprecated Experimental: Methods marked with this note have 218 | * been tested to be functional but may change or disappear 219 | * at will in one of the next releases because they are still 220 | * a topic for research on extended functionality. 221 | * Most likely the methods will prevail however and this note 222 | * will just vanish, so you may use them with a certain risk. 223 | */ 224 | protected Cipher getCipher4Decryption() { 225 | Cipher cipher = getCipher(); 226 | try { 227 | cipher.init(Cipher.DECRYPT_MODE, key, algoParamSpec); 228 | } 229 | catch (InvalidKeyException cannotHappen) { 230 | throw new AssertionError(cannotHappen); 231 | } 232 | catch (InvalidAlgorithmParameterException cannotHappen) { 233 | throw new AssertionError(cannotHappen); 234 | } 235 | 236 | return cipher; 237 | } 238 | 239 | /** 240 | * Returns a cipher object which needs to be configured for encryption or 241 | * decryption 242 | * - {@code null} is never returned. 243 | * 244 | * @deprecated Experimental: Methods marked with this note have 245 | * been tested to be functional but may change or disappear 246 | * at will in one of the next releases because they are still 247 | * a topic for research on extended functionality. 248 | * Most likely the methods will prevail however and this note 249 | * will just vanish, so you may use them with a certain risk. 250 | */ 251 | protected Cipher getCipher() { 252 | if (cipher != null) 253 | return cipher; 254 | algoParamSpec = new PBEParameterSpec( 255 | new byte[] { 256 | (byte)0xce, (byte)0xfb, (byte)0xde, (byte)0xac, 257 | (byte)0x05, (byte)0x02, (byte)0x19, (byte)0x71 258 | }, 259 | 2005); 260 | try { 261 | KeySpec keySpec = new PBEKeySpec(getCipherParam().getKeyPwd().toCharArray()); 262 | SecretKeyFactory keyFac = SecretKeyFactory.getInstance(PBE_WITH_MD5_AND_DES); 263 | key = keyFac.generateSecret(keySpec); 264 | cipher = Cipher.getInstance(PBE_WITH_MD5_AND_DES); 265 | } catch (NoSuchAlgorithmException cannotHappen) { 266 | throw new AssertionError(cannotHappen); 267 | } catch (InvalidKeySpecException cannotHappen) { 268 | throw new AssertionError(cannotHappen); 269 | } catch (NoSuchPaddingException cannotHappen) { 270 | throw new AssertionError(cannotHappen); 271 | } 272 | return cipher; 273 | } 274 | } 275 | -------------------------------------------------------------------------------- /java-license-jar/src/main/java/zlicense/de/schlichtherle/license/LicenseManager.java: -------------------------------------------------------------------------------- 1 | package zlicense.de.schlichtherle.license; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileOutputStream; 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.io.OutputStream; 9 | import java.net.SocketException; 10 | import java.util.Calendar; 11 | import java.util.Date; 12 | import java.util.prefs.Preferences; 13 | 14 | import javax.security.auth.x500.X500Principal; 15 | import javax.swing.filechooser.FileFilter; 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | import zlicense.de.schlichtherle.util.ObfuscatedString; 26 | import zlicense.de.schlichtherle.xml.GenericCertificate; 27 | import zlicense.util.LicenseCheckModel; 28 | import zlicense.util.ListNets; 29 | 30 | 31 | 32 | public class LicenseManager implements LicenseCreator, LicenseVerifier { 33 | private static final long TIMEOUT = 1800000L; 34 | private static final String PREFERENCES_KEY; 35 | public static final String LICENSE_SUFFIX; 36 | private static final String PARAM = LicenseNotary.PARAM; 37 | private static final String SUBJECT = new ObfuscatedString(new long[] { 38 | -6788193907359448604L, -2787711522493615434L }).toString(); 39 | private static final String KEY_STORE_PARAM = new ObfuscatedString( 40 | new long[] { 4943981370588954830L, 8065447823433585419L, 41 | -2749528823549501332L }).toString(); 42 | private static final String CIPHER_PARAM = new ObfuscatedString(new long[] { 43 | -3651048337721043740L, 1928803483347080380L, 1649789960289346230L }) 44 | .toString(); 45 | protected static final String CN = new ObfuscatedString(new long[] { 46 | 7165044359350484836L, -6008675436704023088L }).toString(); 47 | private static final String CN_USER = CN 48 | + new ObfuscatedString(new long[] { -883182015789302099L, 49 | 6587252612286394632L }).toString(); 50 | private static final String USER = new ObfuscatedString(new long[] { 51 | -6950934198262740461L, -10280221617836935L }).toString(); 52 | private static final String SYSTEM = new ObfuscatedString(new long[] { 53 | -1441033263392531498L, 6113162389128247115L }).toString(); 54 | private static final String EXC_INVALID_SUBJECT = new ObfuscatedString( 55 | new long[] { -9211605111142713620L, 391714365510707393L, 56 | -7356761750428556372L, 6379560902598103028L }).toString(); 57 | private static final String EXC_HOLDER_IS_NULL = new ObfuscatedString( 58 | new long[] { 7150026245468079143L, 6314884536402738366L, 59 | -1360923923476698800L }).toString(); 60 | private static final String EXC_ISSUER_IS_NULL = new ObfuscatedString( 61 | new long[] { -3034693013076752554L, -1011266899694033610L, 62 | 6775785917404597234L }).toString(); 63 | private static final String EXC_ISSUED_IS_NULL = new ObfuscatedString( 64 | new long[] { -6084371209004858580L, 3028840747031697166L, 65 | -3524637886726219307L }).toString(); 66 | private static final String EXC_LICENSE_IS_NOT_YET_VALID = new ObfuscatedString( 67 | new long[] { 5434633639502011825L, -3406117476263181371L, 68 | 6903673940810780388L, -6816911225052310716L }).toString(); 69 | private static final String EXC_LICENSE_HAS_EXPIRED = new ObfuscatedString( 70 | new long[] { 1000558500458715757L, -6998261911041258483L, 71 | -5490039629745846648L, 3561172928787106880L }).toString(); 72 | private static final String EXC_CONSUMER_TYPE_IS_NULL = new ObfuscatedString( 73 | new long[] { -3274088377466921882L, -1704115158449736962L, 74 | -1134622897105293263L, 2875630655915253859L }).toString(); 75 | private static final String EXC_CONSUMER_TYPE_IS_NOT_USER = new ObfuscatedString( 76 | new long[] { -3559580260061340089L, 8807812719464926891L, 77 | 3255622466169980128L, 3208430498260873670L, 78 | 8772089725159421213L }).toString(); 79 | private static final String EXC_CONSUMER_AMOUNT_IS_NOT_ONE = new ObfuscatedString( 80 | new long[] { 6854702630454082314L, -1676630527348424687L, 81 | 4853969635229547239L, -7087814313396201500L, 82 | 7133601245775504376L }).toString(); 83 | private static final String EXC_CONSUMER_AMOUNT_IS_NOT_POSITIVE = new ObfuscatedString( 84 | new long[] { -5670394608177286583L, -3674104453170648872L, 85 | 4159301984262248157L, 7442355638167795990L, 86 | 4780252201915657674L }).toString(); 87 | private static final String FILE_FILTER_DESCRIPTION = new ObfuscatedString( 88 | new long[] { 3160933239845492228L, -2320904495012387647L, 89 | -5935185636215549881L, -3418607682842311949L }).toString(); 90 | private static final String FILE_FILTER_SUFFIX = new ObfuscatedString( 91 | new long[] { -6576160320308571504L, 7010427383913371869L }) 92 | .toString(); 93 | private LicenseParam param; 94 | private LicenseNotary notary; 95 | private PrivacyGuard guard; 96 | private GenericCertificate certificate; 97 | private long certificateTime; 98 | private FileFilter fileFilter; 99 | private Preferences preferences; 100 | 101 | protected static final Date midnight() { 102 | Calendar localCalendar = Calendar.getInstance(); 103 | localCalendar.set(11, 0); 104 | localCalendar.set(12, 0); 105 | localCalendar.set(13, 0); 106 | localCalendar.set(14, 0); 107 | return localCalendar.getTime(); 108 | } 109 | 110 | protected LicenseManager() { 111 | } 112 | 113 | public LicenseManager(LicenseParam paramLicenseParam) 114 | throws NullPointerException, IllegalPasswordException { 115 | setLicenseParam(paramLicenseParam); 116 | } 117 | 118 | public LicenseParam getLicenseParam() { 119 | return this.param; 120 | } 121 | 122 | public synchronized void setLicenseParam(LicenseParam paramLicenseParam) 123 | throws NullPointerException, IllegalPasswordException { 124 | if (paramLicenseParam == null) { 125 | throw new NullPointerException(PARAM); 126 | } 127 | if (paramLicenseParam.getSubject() == null) { 128 | throw new NullPointerException(SUBJECT); 129 | } 130 | if (paramLicenseParam.getKeyStoreParam() == null) { 131 | throw new NullPointerException(KEY_STORE_PARAM); 132 | } 133 | CipherParam localCipherParam = paramLicenseParam.getCipherParam(); 134 | if (localCipherParam == null) { 135 | throw new NullPointerException(CIPHER_PARAM); 136 | } 137 | Policy.getCurrent().checkPwd(localCipherParam.getKeyPwd()); 138 | this.param = paramLicenseParam; 139 | this.notary = null; 140 | this.certificate = null; 141 | this.certificateTime = 0L; 142 | this.fileFilter = null; 143 | this.preferences = null; 144 | } 145 | 146 | public final synchronized void store(LicenseContent paramLicenseContent, 147 | File paramFile) throws Exception { 148 | store(paramLicenseContent, getLicenseNotary(), paramFile); 149 | } 150 | 151 | /** 152 | * @deprecated 153 | */ 154 | protected synchronized void store(LicenseContent paramLicenseContent, 155 | LicenseNotary paramLicenseNotary, File paramFile) throws Exception { 156 | storeLicenseKey(create(paramLicenseContent, paramLicenseNotary), 157 | paramFile); 158 | } 159 | 160 | public final synchronized byte[] create(LicenseContent paramLicenseContent) 161 | throws Exception { 162 | return create(paramLicenseContent, getLicenseNotary()); 163 | } 164 | 165 | /** 166 | * @deprecated 167 | */ 168 | protected synchronized byte[] create(LicenseContent paramLicenseContent, 169 | LicenseNotary paramLicenseNotary) throws Exception { 170 | initialize(paramLicenseContent); 171 | create_validate(paramLicenseContent); 172 | GenericCertificate localGenericCertificate = paramLicenseNotary 173 | .sign(paramLicenseContent); 174 | byte[] arrayOfByte = getPrivacyGuard() 175 | .cert2key(localGenericCertificate); 176 | return arrayOfByte; 177 | } 178 | 179 | public final synchronized LicenseContent install(File paramFile) 180 | throws Exception { 181 | return install(paramFile, getLicenseNotary()); 182 | } 183 | 184 | /** 185 | * @deprecated 186 | */ 187 | protected synchronized LicenseContent install(File paramFile, 188 | LicenseNotary paramLicenseNotary) throws Exception { 189 | return install(loadLicenseKey(paramFile), paramLicenseNotary); 190 | } 191 | 192 | /** 193 | * @deprecated 194 | */ 195 | protected synchronized LicenseContent install(byte[] paramArrayOfByte, 196 | LicenseNotary paramLicenseNotary) throws Exception { 197 | GenericCertificate localGenericCertificate = getPrivacyGuard() 198 | .key2cert(paramArrayOfByte); 199 | paramLicenseNotary.verify(localGenericCertificate); 200 | LicenseContent localLicenseContent = (LicenseContent) localGenericCertificate 201 | .getContent(); 202 | validate(localLicenseContent); 203 | setLicenseKey(paramArrayOfByte); 204 | setCertificate(localGenericCertificate); 205 | return localLicenseContent; 206 | } 207 | 208 | public final synchronized LicenseContent verify() throws Exception { 209 | return verify(getLicenseNotary()); 210 | } 211 | 212 | /** 213 | * @deprecated 214 | */ 215 | protected synchronized LicenseContent verify( 216 | LicenseNotary paramLicenseNotary) throws Exception { 217 | GenericCertificate localGenericCertificate = getCertificate(); 218 | if (localGenericCertificate != null) { 219 | return (LicenseContent) localGenericCertificate.getContent(); 220 | } 221 | byte[] arrayOfByte = getLicenseKey(); 222 | if (arrayOfByte == null) { 223 | throw new NoLicenseInstalledException(getLicenseParam() 224 | .getSubject()); 225 | } 226 | localGenericCertificate = getPrivacyGuard().key2cert(arrayOfByte); 227 | paramLicenseNotary.verify(localGenericCertificate); 228 | LicenseContent localLicenseContent = (LicenseContent) localGenericCertificate 229 | .getContent(); 230 | validate(localLicenseContent); 231 | setCertificate(localGenericCertificate); 232 | return localLicenseContent; 233 | } 234 | 235 | public final synchronized LicenseContent verify(byte[] paramArrayOfByte) 236 | throws Exception { 237 | return verify(paramArrayOfByte, getLicenseNotary()); 238 | } 239 | 240 | /** 241 | * @deprecated 242 | */ 243 | protected synchronized LicenseContent verify(byte[] paramArrayOfByte, 244 | LicenseNotary paramLicenseNotary) throws Exception { 245 | GenericCertificate localGenericCertificate = getPrivacyGuard() 246 | .key2cert(paramArrayOfByte); 247 | paramLicenseNotary.verify(localGenericCertificate); 248 | LicenseContent localLicenseContent = (LicenseContent) localGenericCertificate 249 | .getContent(); 250 | validate(localLicenseContent); 251 | return localLicenseContent; 252 | } 253 | 254 | public synchronized void uninstall() throws Exception { 255 | setLicenseKey(null); 256 | setCertificate(null); 257 | } 258 | 259 | protected synchronized void initialize(LicenseContent paramLicenseContent) { 260 | if (paramLicenseContent.getHolder() == null) { 261 | paramLicenseContent.setHolder(new X500Principal(CN_USER)); 262 | } 263 | if (paramLicenseContent.getSubject() == null) { 264 | paramLicenseContent.setSubject(getLicenseParam().getSubject()); 265 | } 266 | if (paramLicenseContent.getConsumerType() == null) { 267 | Preferences localPreferences = getLicenseParam().getPreferences(); 268 | if (localPreferences != null) { 269 | if (localPreferences.isUserNode()) { 270 | paramLicenseContent.setConsumerType(USER); 271 | } else { 272 | paramLicenseContent.setConsumerType(SYSTEM); 273 | } 274 | paramLicenseContent.setConsumerAmount(1); 275 | } 276 | } 277 | if (paramLicenseContent.getIssuer() == null) { 278 | paramLicenseContent.setIssuer(new X500Principal(CN 279 | + getLicenseParam().getSubject())); 280 | } 281 | if (paramLicenseContent.getIssued() == null) { 282 | paramLicenseContent.setIssued(new Date()); 283 | } 284 | if (paramLicenseContent.getNotBefore() == null) { 285 | paramLicenseContent.setNotBefore(midnight()); 286 | } 287 | } 288 | 289 | 290 | protected synchronized void create_validate(LicenseContent paramLicenseContent) 291 | throws LicenseContentException { 292 | LicenseParam localLicenseParam = getLicenseParam(); 293 | if (!localLicenseParam.getSubject().equals( 294 | paramLicenseContent.getSubject())) { 295 | throw new LicenseContentException(EXC_INVALID_SUBJECT); 296 | } 297 | if (paramLicenseContent.getHolder() == null) { 298 | throw new LicenseContentException(EXC_HOLDER_IS_NULL); 299 | } 300 | if (paramLicenseContent.getIssuer() == null) { 301 | throw new LicenseContentException(EXC_ISSUER_IS_NULL); 302 | } 303 | if (paramLicenseContent.getIssued() == null) { 304 | throw new LicenseContentException(EXC_ISSUED_IS_NULL); 305 | } 306 | Date localDate1 = new Date(); 307 | Date localDate2 = paramLicenseContent.getNotBefore(); 308 | if ((localDate2 != null) && (localDate1.before(localDate2))) { 309 | throw new LicenseContentException(EXC_LICENSE_IS_NOT_YET_VALID); 310 | } 311 | Date localDate3 = paramLicenseContent.getNotAfter(); 312 | if ((localDate3 != null) && (localDate1.after(localDate3))) { 313 | throw new LicenseContentException(EXC_LICENSE_HAS_EXPIRED); 314 | } 315 | 316 | String str = paramLicenseContent.getConsumerType(); 317 | if (str == null) { 318 | throw new LicenseContentException(EXC_CONSUMER_TYPE_IS_NULL); 319 | } 320 | Preferences localPreferences = localLicenseParam.getPreferences(); 321 | if ((localPreferences != null) && (localPreferences.isUserNode())) { 322 | if (!USER.equalsIgnoreCase(str)) { 323 | throw new LicenseContentException(EXC_CONSUMER_TYPE_IS_NOT_USER); 324 | } 325 | if (paramLicenseContent.getConsumerAmount() != 1) { 326 | throw new LicenseContentException( 327 | EXC_CONSUMER_AMOUNT_IS_NOT_ONE); 328 | } 329 | } else if (paramLicenseContent.getConsumerAmount() <= 0) { 330 | throw new LicenseContentException( 331 | EXC_CONSUMER_AMOUNT_IS_NOT_POSITIVE); 332 | } 333 | } 334 | 335 | protected synchronized void validate(LicenseContent paramLicenseContent) 336 | throws LicenseContentException { 337 | LicenseParam localLicenseParam = getLicenseParam(); 338 | if (!localLicenseParam.getSubject().equals( 339 | paramLicenseContent.getSubject())) { 340 | throw new LicenseContentException(EXC_INVALID_SUBJECT); 341 | } 342 | if (paramLicenseContent.getHolder() == null) { 343 | throw new LicenseContentException(EXC_HOLDER_IS_NULL); 344 | } 345 | if (paramLicenseContent.getIssuer() == null) { 346 | throw new LicenseContentException(EXC_ISSUER_IS_NULL); 347 | } 348 | if (paramLicenseContent.getIssued() == null) { 349 | throw new LicenseContentException(EXC_ISSUED_IS_NULL); 350 | } 351 | Date localDate1 = new Date(); 352 | Date localDate2 = paramLicenseContent.getNotBefore(); 353 | if ((localDate2 != null) && (localDate1.before(localDate2))) { 354 | throw new LicenseContentException(EXC_LICENSE_IS_NOT_YET_VALID); 355 | } 356 | Date localDate3 = paramLicenseContent.getNotAfter(); 357 | if ((localDate3 != null) && (localDate1.after(localDate3))) { 358 | throw new LicenseContentException(EXC_LICENSE_HAS_EXPIRED); 359 | } 360 | 361 | LicenseCheckModel licenseCheckModel = (LicenseCheckModel)paramLicenseContent.getExtra(); 362 | String macAddress = licenseCheckModel.getIpMacAddress(); 363 | 364 | try { 365 | if (!ListNets.validateMacAddress(macAddress)) { 366 | throw new LicenseContentException(EXC_LICENSE_HAS_EXPIRED); 367 | } 368 | } catch (SocketException e) { 369 | // TODO Auto-generated catch block 370 | throw new LicenseContentException(EXC_LICENSE_HAS_EXPIRED); 371 | } 372 | 373 | 374 | String str = paramLicenseContent.getConsumerType(); 375 | if (str == null) { 376 | throw new LicenseContentException(EXC_CONSUMER_TYPE_IS_NULL); 377 | } 378 | Preferences localPreferences = localLicenseParam.getPreferences(); 379 | if ((localPreferences != null) && (localPreferences.isUserNode())) { 380 | if (!USER.equalsIgnoreCase(str)) { 381 | throw new LicenseContentException(EXC_CONSUMER_TYPE_IS_NOT_USER); 382 | } 383 | if (paramLicenseContent.getConsumerAmount() != 1) { 384 | throw new LicenseContentException( 385 | EXC_CONSUMER_AMOUNT_IS_NOT_ONE); 386 | } 387 | } else if (paramLicenseContent.getConsumerAmount() <= 0) { 388 | throw new LicenseContentException( 389 | EXC_CONSUMER_AMOUNT_IS_NOT_POSITIVE); 390 | } 391 | } 392 | 393 | /** 394 | * @deprecated 395 | */ 396 | protected GenericCertificate getCertificate() { 397 | if ((this.certificate != null) 398 | && (System.currentTimeMillis() < this.certificateTime + 1800000L)) { 399 | return this.certificate; 400 | } 401 | return null; 402 | } 403 | 404 | /** 405 | * @deprecated 406 | */ 407 | protected synchronized void setCertificate( 408 | GenericCertificate paramGenericCertificate) { 409 | this.certificate = paramGenericCertificate; 410 | this.certificateTime = System.currentTimeMillis(); 411 | } 412 | 413 | /** 414 | * @deprecated 415 | */ 416 | protected byte[] getLicenseKey() { 417 | return getLicenseParam().getPreferences().getByteArray(PREFERENCES_KEY, 418 | null); 419 | } 420 | 421 | /** 422 | * @deprecated 423 | */ 424 | protected synchronized void setLicenseKey(byte[] paramArrayOfByte) { 425 | Preferences localPreferences = getLicenseParam().getPreferences(); 426 | if (paramArrayOfByte != null) { 427 | localPreferences.putByteArray(PREFERENCES_KEY, paramArrayOfByte); 428 | } else { 429 | localPreferences.remove(PREFERENCES_KEY); 430 | } 431 | } 432 | 433 | protected static void storeLicenseKey(byte[] paramArrayOfByte, 434 | File paramFile) throws IOException { 435 | FileOutputStream localFileOutputStream = new FileOutputStream(paramFile); 436 | try { 437 | localFileOutputStream.write(paramArrayOfByte); 438 | return; 439 | } finally { 440 | try { 441 | localFileOutputStream.close(); 442 | } catch (IOException localIOException2) { 443 | } 444 | } 445 | } 446 | 447 | /* 448 | * protected static byte[] loadLicenseKey(File paramFile) throws IOException 449 | * { int i = Math.min((int)paramFile.length(), 1048576); FileInputStream 450 | * localFileInputStream = new FileInputStream(paramFile); arrayOfByte = new 451 | * byte[i]; try { localFileInputStream.read(arrayOfByte); return 452 | * arrayOfByte; } finally { try { localFileInputStream.close(); } catch 453 | * (IOException localIOException2) {} } } 454 | */ 455 | 456 | protected static byte[] loadLicenseKey(final File keyFile) 457 | throws IOException { 458 | // Allow max 1MB size files and let the verifier detect a partial read 459 | final int size = Math.min((int) keyFile.length(), 1024 * 1024); 460 | final byte[] b = new byte[size]; 461 | final InputStream in = new FileInputStream(keyFile); 462 | try { 463 | // Let the verifier detect a partial read as an error 464 | in.read(b); 465 | } finally { 466 | in.close(); 467 | } 468 | return b; 469 | } 470 | 471 | protected synchronized LicenseNotary getLicenseNotary() { 472 | if (this.notary == null) { 473 | this.notary = new LicenseNotary(getLicenseParam() 474 | .getKeyStoreParam()); 475 | } 476 | return this.notary; 477 | } 478 | 479 | protected synchronized PrivacyGuard getPrivacyGuard() { 480 | if (this.guard == null) { 481 | this.guard = new PrivacyGuard(getLicenseParam().getCipherParam()); 482 | } 483 | return this.guard; 484 | } 485 | 486 | /* 487 | * public synchronized FileFilter getFileFilter() { if (this.fileFilter != 488 | * null) { return this.fileFilter; } final String str = 489 | * Resources.getString(FILE_FILTER_DESCRIPTION, 490 | * getLicenseParam().getSubject()); if (File.separatorChar == '\\') { 491 | * this.fileFilter = new FileFilter() { private final String 492 | * val$description; 493 | * 494 | * public boolean accept(File paramAnonymousFile) { return 495 | * (paramAnonymousFile.isDirectory()) || 496 | * (paramAnonymousFile.getPath().toLowerCase 497 | * ().endsWith(LicenseManager.LICENSE_SUFFIX)); } 498 | * 499 | * public String getDescription() { return str + 500 | * LicenseManager.FILE_FILTER_SUFFIX; } }; } else { this.fileFilter = new 501 | * FileFilter() { private final String val$description; 502 | * 503 | * public boolean accept(File paramAnonymousFile) { return 504 | * (paramAnonymousFile.isDirectory()) || 505 | * (paramAnonymousFile.getPath().endsWith(LicenseManager.LICENSE_SUFFIX)); } 506 | * 507 | * public String getDescription() { return str + 508 | * LicenseManager.FILE_FILTER_SUFFIX; } }; } return this.fileFilter; } 509 | */ 510 | 511 | public synchronized FileFilter getFileFilter() { 512 | if (fileFilter != null) 513 | return fileFilter; 514 | final String description = Resources.getString(FILE_FILTER_DESCRIPTION, 515 | getLicenseParam().getSubject()); 516 | if (File.separatorChar == '\\') { 517 | fileFilter = new FileFilter() { 518 | public boolean accept(File f) { 519 | return f.isDirectory() 520 | || f.getPath().toLowerCase() 521 | .endsWith(LICENSE_SUFFIX); 522 | } 523 | 524 | public String getDescription() { 525 | return description + FILE_FILTER_SUFFIX; 526 | } 527 | }; 528 | } else { 529 | fileFilter = new FileFilter() { 530 | public boolean accept(File f) { 531 | return f.isDirectory() 532 | || f.getPath().endsWith(LICENSE_SUFFIX); 533 | } 534 | 535 | public String getDescription() { 536 | return description + FILE_FILTER_SUFFIX; 537 | } 538 | }; 539 | } 540 | return fileFilter; 541 | } 542 | 543 | static { 544 | PREFERENCES_KEY = new ObfuscatedString(new long[] { 545 | -2999492566024573771L, -1728025856628382701L }).toString(); 546 | LICENSE_SUFFIX = new ObfuscatedString(new long[] { 547 | -7559156485370438418L, 5084921010819724770L }).toString(); 548 | assert (LICENSE_SUFFIX.equals(LICENSE_SUFFIX.toLowerCase())); 549 | } 550 | } 551 | --------------------------------------------------------------------------------