Sunday, July 28, 2013

How to upgrade svn to 1.7 for Mac OS X Mountain Lion

upgradesvn.sh    Select all
svn --version
cd ~/Downloads/
curl -o subversion-latest.tar.gz http://apache.mirrors.tds.net/subversion/subversion-1.7.11.tar.gz
tar -xvf subversion-latest.tar.gz
cd subversion-1.7.11/
sh get-deps.sh neon
cd neon/
./configure --with-ssl
make
sudo make install
cd ..
./configure --prefix=/usr --with-neon
make
sudo make install
svn --version


One of the major changes in this release 1.7 is a move to a new metadata format that does not require multiple .svn directories in working copies. Instead, working copies will have a single metadata directory.



Monday, July 8, 2013

How to install watir on Windows XP / 7 (32 bit) for IE Webapp testing

(1) Goto http://rubyinstaller.org/downloads and download
Ruby 1.9.3-p429
DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe


(2) Download IEDriverServer_Win32_2.33.0.zip from
http://code.google.com/p/selenium/downloads/list
and extract to C:\Windows\


(3) install Ruby 1.9.3-p429 using Administrator
Choose Add Ruby executables to PATH and Associate .rb and .rbw
Install to say C:\Ruby193

(4) Double click and extract DevKit-tdm to say C:\Ruby193\DevKit


(5) Use Command Prompt (cmd.exe) and enter into DOS shell and run
cd C:\Ruby193\DevKit
ruby dk.rb init
ruby dk.rb install
gem install watir --no-ri --no-rdoc
# might have some errors after the last step
gem install nokogiri
gem install mini_magick -v 3.5
gem install watir --no-ri --no-rdoc
gem install watir-webdriver --no-ri --no-rdoc


(6) Use irb to test interative session on IE
require "watir"
browser = Watir::Browser.new
browser.goto("www.google.com")
browser.text_field(:name => 'q').set 'Watir Example'
browser.button(:name => 'btnK').click
browser.close

require "watir-webdriver"
browser = Watir::Browser.new :ie
browser.goto 'http://bit.ly/watir-example'
browser.text_field(:name => 'entry.0.single').set 'Watir'
browser.radio(:value => 'Watir').set




Saturday, June 29, 2013

Personal Migration Guide for Google App Engine from python 2.5 to 2.7

app.yaml    Select all
#change application name to new id that enable HRD #application: myapp application: myapp-hrd #change runtime #runtime: python runtime: python27 #add threadsafe threadsafe: true #change remote_api handlers: #- url: /remote_api # script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py # login: admin - url: /remoteapi.* script: google.appengine.ext.remote_api.handler.app login: admin #change url for app - url: .* script: myapp.app # script: myapp.py #add libraries libraries: - name: webapp2 version: "2.5.2" - name: jinja2 version: "2.6" #add services inbound_services: - warmup




myapp.py    Select all
#import webapp2 and jinja2 import webapp2 import jinja2 #import wsgiref.handlers #from google.appengine.ext import webapp #from google.appengine.ext.webapp import RequestHandler #from google.appengine.ext.webapp import template #from google.appengine.ext.webapp.util import run_wsgi_app #use ndb instead of db #from google.appengine.ext import db #class Greeting(db.Model): # author = db.UserProperty() # content = db.StringProperty(indexed=False) # role = db.StringProperty(required=True, choices=set(["executive", "manager", "helper"])) # date = db.DateTimeProperty(auto_now_add=True) from google.appengine.ext import ndb class Greeting(ndb.Model): """Models an individual Guestbook entry with author, content, and date.""" author = ndb.UserProperty() content = ndb.StringProperty(indexed=False) role = ndb.StringProperty(required=True, choices=set(["executive", "manager", "helper"])) date = ndb.DateTimeProperty(auto_now_add=True) #use TEMPLATE_DIR and JINJA_ENVIRONMENT TEMPLATE_DIR = 'templates' JINJA_ENVIRONMENT = jinja2.Environment( loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), TEMPLATE_DIR)), # loader=jinja2.FileSystemLoader(os.path.dirname(__file__)), extensions=['jinja2.ext.autoescape']) #use jinja2 template # path = os.path.abspath(os.path.join(os.path.dirname(__file__), TEMPLATE_DIR, fileName)) # self.response.out.write(template.render(path, values)) template = JINJA_ENVIRONMENT.get_template(fileName) self.response.write(template.render(values)) #use webapp2 instead of webapp #def main(): #application = webapp.WSGIApplication( app = webapp2.WSGIApplication( [('/', MainHandler) # %3D does not work now # ,(r'/id%3D([A-Za-z0-9-.]*)', IDHandler) ,(r'/id=([A-Za-z0-9-.]*)', IDHandler) ], debug=True) # run_wsgi_app(application) #if __name__ == '__main__': # main()




Then, Duplicate Application Settings to a new application id say myapp-hrd

Finally, Migrate the app to the High Replication Datastore (HRD) in Google App Engine admin before uploading the python 2.7 code to the newly converted application id myapp-hrd

At the end of the migration process, the new HRD app (myapp-hrd) will be aliased to the old appid.




Tuesday, April 9, 2013

How to enable Java 6 Web plug-in for Max OS X Lion / Mountain Lion / Mavericks

http://support.apple.com/kb/ht5559

JAVA SE6 (OS X v10.7/10.8/10.9) -> http://support.apple.com/kb/DL1572
JAVA SE6 (OS X v10.6) -> http://support.apple.com/kb/DL1573
JAVA SE5 & SE6 (OS X v10.5) -> http://support.apple.com/kb/DL1359



Tuesday, November 20, 2012

Saturday, September 15, 2012

How to create java project in XCode 4

(1) Download the required file here and unzip it after download. http://www.2shared.com/file/vt3Flvvs/hellojava.html

Please choose the bottom blue download button in the download page.



(2) Create a new project in XCode 4, Choose "Other" -> "External Build System"


(3) Enter the Product Name say "project1".  For Build Tool enter /usr/bin/ant


(4) Save the project in your disk

(5) Right click your "project1" in XCode 4 and Choose "Add Files to project1"


(6) Choose the file (build.xml) and folders (lib, resources, resources_macosx and src) in the unzipped file downloaded in step 1
Select "Copy items into destination group's folder (if needed)" and "Create groups for any added folders" and Press "Add" button.

(7) Edit build.xml and change the Project name attribute from "hellojava" to your Product Name say "project1"


(8) Edit Manifest and change the Main-Class from "hellojava" to your Product Name say "project1"


(9) Edit the filename hellojava.icns to Product Name say "project1.icns"


(10) Edit the filename hellojava.java to Product Name say "project1.java"


(11) Edit the class name in "project1.java" and change from "hellojava" to your Product Name say "project1" and then press "Command S" to save


(12) Press "Command B" to build


(13) Right click your "project1" in XCode 4 and Choose "Add Files to project1" again


(14) Choose folders (bin, dist and jars) from your save project location.
Select "Copy items into destination group's folder (if needed)" and "Create folder references for any added folders" and Press "Add" button.


(15) Select "Product" -> "Edit Scheme..." menu


(16) Select the "Run" Scheme and change the Executable "None"


(17) And Choose the "project1" app under the "dist" folder of the saved project location.


(18) Repeat the steps 16 and 17 but for the "Profile" Scheme.

(19) Press "Command R" to run. And a simple Hello World app is created with java source code.


(20) Modify the source code in "project1.java" to proceed further.



Here is the Xcode 4 Template for Java (v2)
http://www.2shared.com/file/hExLjJ1X/Java_Xcode4_template2.html

To install the template in Mac, use Terminal command
mkdir -p ~/Library/Developer/Xcode/Templates/
unzip ~/Downloads/Java_Xcode4_template2.zip -d ~/Library/Developer/Xcode/Templates/


To Run after build (Command R), you have to do steps 15 to 18 above.

Saturday, September 8, 2012

How to decompile and recompile java program under Mac OS X

This Tutorial use XMind as an example.

1. Install JAVA SE6 (OS X v10.7/10.8) -> http://support.apple.com/kb/DL1572
JAVA SE6 (OS X v10.6) -> http://support.apple.com/kb/DL1573
JAVA SE5 & SE6 (OS X v10.5) -> http://support.apple.com/kb/DL1359
and install XMind (http://www.xmind.net/download/mac/)

2. Create environment folders and required library jar files for ant build
mkdir -p ~/xmind.verify/lib

mkdir -p ~/xmind.verify/src/net/xmind/verify/internal

cd ~/xmind.verify/lib

jar xvf /Applications/XMind.app/Contents/Resources/plugins/org.bouncycastle_1.4.7.jar bcprov-jdk15on-147.jar

cp /Applications/XMind.app/Contents/Resources/plugins/net.xmind.verify_3.3.0.201208102038.jar .



3. Use Java decompiler JD-GUI http://java.decompiler.free.fr/?q=jdgui to open/decompile the file ~/xmind.verify/lib/net.xmind.verify_3.3.0.201208102038.jar

4. save source code in JD-GUI for net.xmind.verify -> internal -> LicenseVerifier to folder ~/xmind.verify/src/net/xmind/verify/internal/

5. Modify LicenseVerifier.java as below
LicenseVerifier.java    Select all
/* 1 */ package net.xmind.verify.internal; /* 2 */ /* 3 */ import java.util.ArrayList; /* 4 */ import java.util.Collection; /* 5 */ import java.util.Iterator; /* 6 */ import java.util.List; /* 7 */ import java.util.Properties; /* 8 */ import java.util.Random; /* 9 */ import net.xmind.signin.IAccountInfo; /* 10 */ import net.xmind.signin.IAuthenticationListener; /* 11 */ import net.xmind.signin.IDataStore; /* 12 */ import net.xmind.signin.IXMindNetCommand; /* 13 */ import net.xmind.signin.IXMindNetCommandHandler; /* 14 */ import net.xmind.signin.XMindNet; /* 15 */ import net.xmind.signin.internal.InternalXMindNet; /* 16 */ import net.xmind.signin.internal.LicenseInfo; /* 17 */ import net.xmind.signin.internal.XMindLicenseAgent; /* 18 */ import net.xmind.signin.internal.XMindNetAccount; /* 19 */ import net.xmind.signin.internal.XMindNetRequest; /* 20 */ import net.xmind.verify.IValidity; /* 21 */ import net.xmind.verify.IVerifyListener; /* 22 */ import net.xmind.verify.ui.internal.ActivateProDialog; /* 23 */ import org.bouncycastle.asn1.ASN1InputStream; /* 24 */ import org.bouncycastle.asn1.ASN1Sequence; /* 25 */ import org.bouncycastle.asn1.pkcs.RSAPublicKey; /* 26 */ import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; /* 27 */ import org.bouncycastle.crypto.CipherParameters; /* 28 */ import org.bouncycastle.crypto.digests.MD5Digest; /* 29 */ import org.bouncycastle.crypto.engines.RSAEngine; /* 30 */ import org.bouncycastle.crypto.params.RSAKeyParameters; /* 31 */ import org.bouncycastle.crypto.signers.PSSSigner; /* 32 */ import org.bouncycastle.util.encoders.Base64; /* 33 */ import org.eclipse.core.runtime.IProgressMonitor; /* 34 */ import org.eclipse.core.runtime.IStatus; /* 35 */ import org.eclipse.core.runtime.SafeRunner; /* 36 */ import org.eclipse.core.runtime.jobs.IJobChangeEvent; /* 37 */ import org.eclipse.core.runtime.jobs.Job; /* 38 */ import org.eclipse.core.runtime.jobs.JobChangeAdapter; /* 39 */ import org.eclipse.core.runtime.preferences.IEclipsePreferences; /* 40 */ import org.eclipse.core.runtime.preferences.IScopeContext; /* 41 */ import org.eclipse.core.runtime.preferences.InstanceScope; /* 42 */ import org.eclipse.jface.preference.IPreferenceStore; /* 43 */ import org.eclipse.jface.util.SafeRunnable; /* 44 */ import org.eclipse.swt.widgets.Display; /* 45 */ import org.eclipse.swt.widgets.Shell; /* 46 */ import org.eclipse.ui.IWorkbench; /* 47 */ import org.eclipse.ui.IWorkbenchWindow; /* 48 */ import org.eclipse.ui.PlatformUI; /* 49 */ /* 50 */ public class LicenseVerifier /* 51 */ implements IAuthenticationListener, IXMindNetCommandHandler /* 52 */ { /* 53 */ private static LicenseVerifier INSTANCE = null; /* 54 */ private static final int SALT_LENGTH = 32; /* 55 */ private static final int PREFIX_LENGTH = 8; /* 56 */ private static List<String> invalidLicenseKeys = new ArrayList<String>(); /* 57 */ private IValidity validity = null; /* 58 */ private VerificationJob verifyJob = null; /* 59 */ private Object jobLock = new Object(); /* 60 */ private List<ValidityNotifier> listeners = new ArrayList<ValidityNotifier>(); /* 61 */ private List<ValidityNotifier> callbacks = new ArrayList<ValidityNotifier>(); /* 62 */ /* 63 */ private LicenseVerifier() { /* 64 */ XMindNet.addAuthenticationListener(this); /* 65 */ XMindNet.addXMindNetCommandHandler("refresh", this); /* 66 */ } /* 67 */ /* 68 */ public void verify(int paramInt) { /* 69 */ verify(null, paramInt, null, 0); /* 70 */ } /* 71 */ /* 72 */ public void verify(int paramInt, IVerifyListener paramIVerifyListener) { /* 73 */ verify(null, paramInt, paramIVerifyListener, 0); /* 74 */ } /* 75 */ /* 76 */ public void verify(int paramInt1, IVerifyListener paramIVerifyListener, int paramInt2) /* 77 */ { /* 78 */ verify(null, paramInt1, paramIVerifyListener, paramInt2); /* 79 */ } /* 80 */ /* 81 */ public void verify(String paramString, int paramInt1, IVerifyListener paramIVerifyListener, int paramInt2) /* 82 */ { /* 83 */ if (((paramInt2 & 0x1) == 0) && (checkValid(this.validity, paramInt1))) { /* 84 */ if (paramIVerifyListener != null) /* 85 */ paramIVerifyListener.notifyValidity(this.validity); /* 86 */ return; /* 87 */ } /* 88 */ if (paramIVerifyListener != null) /* 89 */ synchronized (this.callbacks) { /* 90 */ this.callbacks.add(new ValidityNotifier(paramIVerifyListener)); /* 91 */ } /* 92 */ synchronized (this.jobLock) { /* 93 */ if (this.verifyJob == null) { /* 94 */ VerificationJob localVerificationJob = new VerificationJob( /* 95 */ paramString, paramInt1, paramInt2); /* 96 */ localVerificationJob /* 97 */ .addJobChangeListener(new JobChangeAdapter() /* 98 */ { /* 99 */ public void done(IJobChangeEvent paramAnonymousIJobChangeEvent) { /* 100 */ synchronized (LicenseVerifier.this.jobLock) { /* 101 */ LicenseVerifier.this.verifyJob = null; /* 102 */ } /* 103 */ LicenseVerifier.this /* 104 */ .setValidity((IValidity)paramAnonymousIJobChangeEvent /* 105 */ .getResult()); /* 106 */ } /* 107 */ }); /* 108 */ localVerificationJob.schedule(); /* 109 */ this.verifyJob = localVerificationJob; /* 110 */ } else { /* 111 */ this.verifyJob.updateActionName(paramString); /* 112 */ this.verifyJob.updateRequiredStatus(paramInt1); /* 113 */ this.verifyJob.updateStyle(paramInt2); /* 114 */ } /* 115 */ } /* 116 */ } /* 117 */ /* 118 */ public void addVerifyListener(IVerifyListener paramIVerifyListener) { /* 119 */ synchronized (this.listeners) { /* 120 */ this.listeners.add(new ValidityNotifier(paramIVerifyListener)); /* 121 */ } /* 122 */ } /* 123 */ /* 124 */ public void removeVerifyListener(IVerifyListener paramIVerifyListener) { /* 125 */ synchronized (this.listeners) { /* 126 */ Object[] arrayOfObject = this.listeners.toArray(); /* 127 */ this.listeners.clear(); /* 128 */ for (int i = 0; i < arrayOfObject.length; i++) { /* 129 */ ValidityNotifier localValidityNotifier = (ValidityNotifier)arrayOfObject[i]; /* 130 */ if (localValidityNotifier.listener != paramIVerifyListener) /* 131 */ this.listeners.add(localValidityNotifier); /* 132 */ } /* 133 */ } /* 134 */ } /* 135 */ /* 136 */ private void setValidity(IValidity paramIValidity) { /* 137 */ paramIValidity = cloneValidity(paramIValidity); /* 138 */ IValidity localIValidity = cloneValidity(paramIValidity); /* 139 */ if (notifyAllCallbacks(localIValidity)) /* 140 */ return; /* 141 */ notifyAllListeners(localIValidity); /* 142 */ notifyLicenseAgent(localIValidity); /* 143 */ this.validity = paramIValidity; /* 144 */ if ((paramIValidity.getCode() & 0x6) != 0) /* 145 */ verifyLicenseKeyValidity(); /* 146 */ } /* 147 */ /* 148 */ private void verifyLicenseKeyValidity() { /* 149 */ IPreferenceStore localIPreferenceStore = VerifyPlugin.getDefault() /* 150 */ .getPreferenceStore(); /* 151 */ final String str1 = localIPreferenceStore.getString("licenseKey"); /* 152 */ final String str2 = localIPreferenceStore.getString("licenseEmail"); /* 153 */ Thread localThread = new Thread(new Runnable() { /* 154 */ public void run() { /* 155 */ if (!LicenseVerifier.checkLicenseKeyValidity(str2, str1)) { /* 156 */ LicenseVerifier.invalidLicenseKeys.add(str2 + "|" + str1); /* 157 */ LicenseVerifier.this.verify(7, null, 3); /* 158 */ } /* 159 */ } /* 160 */ }); /* 161 */ localThread.setDaemon(true); /* 162 */ localThread.setPriority(1); /* 163 */ localThread.start(); /* 164 */ } /* 165 */ /* 166 */ private static boolean checkLicenseKeyValidity(String paramString1, String paramString2) /* 167 */ { /* 168 */ return true; /* 169 */ } /* 170 */ /* 171 */ private boolean notifyAllCallbacks(IValidity paramIValidity) /* 172 */ { /* 173 */ ArrayList localArrayList=null; /* 174 */ synchronized (this.callbacks) { /* 175 */ localArrayList = new ArrayList<ValidityNotifier>(this.callbacks); /* 176 */ this.callbacks.clear(); /* 177 */ } /* 178 */ Iterator localIterator = localArrayList.iterator(); /* 179 */ while (localIterator.hasNext()) { /* 180 */ ValidityNotifier vn = (ValidityNotifier)localIterator.next(); /* 181 */ if (vn.notifyValidityCallback(paramIValidity)) /* 182 */ return true; /* 183 */ } /* 184 */ return false; /* 185 */ } /* 186 */ /* 187 */ private void notifyAllListeners(IValidity paramIValidity) { /* 188 */ Object[] arrayOfObject1 = this.listeners.toArray(); /* 189 */ for (Object localObject : arrayOfObject1) /* 190 */ ((ValidityNotifier)localObject) /* 191 */ .notifyValidityListener(paramIValidity); /* 192 */ } /* 193 */ /* 194 */ private void notifyLicenseAgent(IValidity paramIValidity) /* 195 */ { /* 196 */ InternalXMindNet.getInstance() /* 197 */ .getLicenseAgent() /* 198 */ .licenseVerified( /* 199 */ new LicenseInfo(paramIValidity.getCode(), /* 200 */ paramIValidity.getException(), paramIValidity /* 201 */ .getLicensedTo())); /* 202 */ } /* 203 */ /* 204 */ public void postSignIn(IAccountInfo paramIAccountInfo) { /* 205 */ verify(7, null, 3); /* 206 */ } /* 207 */ /* 208 */ public void postSignOut(IAccountInfo paramIAccountInfo) { /* 209 */ if ((this.validity != null) && ((this.validity.getCode() & 0x1) != 0)) { /* 210 */ saveLocalData(null, null, null, null); /* 211 */ setValidity(createValidity(1024)); /* 212 */ } /* 213 */ } /* 214 */ /* 215 */ public boolean handleXMindNetCommand(IXMindNetCommand paramIXMindNetCommand) { /* 216 */ refreshValidity(paramIXMindNetCommand.getContent()); /* 217 */ return true; /* 218 */ } /* 219 */ /* 220 */ private void refreshValidity(IDataStore paramIDataStore) { /* 221 */ if (paramIDataStore == null) /* 222 */ return; /* 223 */ if ((this.validity != null) && ((this.validity.getCode() & 0x6) != 0)) /* 224 */ return; /* 225 */ String str1 = paramIDataStore.getString("user"); /* 226 */ String str2 = paramIDataStore.getString("uid"); /* 227 */ if ((str1 == null) || (str2 == null)) /* 228 */ return; /* 229 */ IAccountInfo localIAccountInfo = XMindNet.getAccountInfo(); /* 230 */ if ((localIAccountInfo == null) || /* 231 */ (!str1.equals(localIAccountInfo.getUser()))) /* 232 */ return; /* 233 */ String str3 = extractExpiration(paramIDataStore, str2); /* 234 */ int i; /* 235 */ //int i; /* 236 */ if (str3 == null) /* 237 */ i = 4096; /* 238 */ else /* 239 */ i = parseExpiration(str3, str2); /* 240 */ saveLocalData(str2, str3, null, null); /* 241 */ this.validity = createValidity(i, str1); /* 242 */ } /* 243 */ /* 244 */ private static boolean checkValid(IStatus paramIStatus, int paramInt) { /* 245 */ return (paramIStatus != null) && (hasValidity(paramIStatus, paramInt)); /* 246 */ } /* 247 */ /* 248 */ private static boolean hasValidity(IStatus paramIStatus, int paramInt) { /* 249 */ return (paramIStatus.getCode() & paramInt) != 0; /* 250 */ } /* 251 */ /* 252 */ private static void saveLocalData(String paramString1, String paramString2, String paramString3, String paramString4) /* 253 */ { /* 254 */ IPreferenceStore localIPreferenceStore = VerifyPlugin.getDefault() /* 255 */ .getPreferenceStore(); /* 256 */ savePreference(localIPreferenceStore, "licenseEmail", paramString4); /* 257 */ savePreference(localIPreferenceStore, "licenseKey", paramString3); /* 258 */ savePreference(localIPreferenceStore, "uid", paramString1); /* 259 */ savePreference(localIPreferenceStore, "expiration", paramString2); /* 260 */ flushStore(); /* 261 */ } /* 262 */ /* 263 */ private static void savePreference(IPreferenceStore paramIPreferenceStore, String paramString1, String paramString2) /* 264 */ { /* 265 */ if ((paramString2 != null) && (!"".equals(paramString2))) /* 266 */ paramIPreferenceStore.setValue(paramString1, paramString2); /* 267 */ else /* 268 */ paramIPreferenceStore.setValue(paramString1, ""); /* 269 */ } /* 270 */ /* 271 */ private static void flushStore() { /* 272 */ IEclipsePreferences localIEclipsePreferences = InstanceScope.INSTANCE /* 273 */ .getNode("net.xmind.varify"); /* 274 */ if (localIEclipsePreferences != null) /* 275 */ try { /* 276 */ localIEclipsePreferences.flush(); /* 277 */ } /* 278 */ catch (Throwable localThrowable) { /* 279 */ } /* 280 */ } /* 281 */ /* 282 */ private static String extractExpiration(IDataStore paramIDataStore, String paramString) { /* 283 */ if (!paramIDataStore.has("expireDate")) /* 284 */ return null; /* 285 */ long l = paramIDataStore.getLong("expireDate"); /* 286 */ if (l <= 0L) /* 287 */ return null; /* 288 */ if (paramIDataStore.getBoolean("expired")) /* 289 */ l = 0L; /* 290 */ StringBuffer localStringBuffer = new StringBuffer(64); /* 291 */ localStringBuffer.append('`'); /* 292 */ localStringBuffer.append('\t'); /* 293 */ localStringBuffer.append('\n'); /* 294 */ localStringBuffer.append(Long.toString(l, 16)); /* 295 */ String str = Cryptus.encrypt(localStringBuffer.toString(), paramString); /* 296 */ return str; /* 297 */ } /* 298 */ /* 299 */ private static int parseExpiration(String paramString1, String paramString2) { /* 300 */ String str = Cryptus.decrypt(paramString1, paramString2); /* 301 */ if ((str != null) && (!"".equals(str)) && (str.startsWith("`\t\n"))) { /* 302 */ long l = Long.parseLong(str.substring(3), 16); /* 303 */ if (System.currentTimeMillis() < l) /* 304 */ return 1; /* 305 */ return 2048; /* 306 */ } /* 307 */ return 1024; /* 308 */ } /* 309 */ /* 310 */ private static IValidity cloneValidity(IValidity paramIValidity) { /* 311 */ return new Validity(paramIValidity.getSeverity(), /* 312 */ paramIValidity.getPlugin(), paramIValidity.getCode(), /* 313 */ paramIValidity.getMessage(), paramIValidity.getException(), /* 314 */ paramIValidity.getLicensedTo()); /* 315 */ } /* 316 */ /* 317 */ private static IValidity createValidity(int paramInt) { /* 318 */ return createValidity(paramInt, null, null, false); /* 319 */ } /* 320 */ /* 321 */ private static IValidity createValidity(int paramInt, String paramString) { /* 322 */ return createValidity(paramInt, paramString, null, false); /* 323 */ } /* 324 */ /* 325 */ private static IValidity createValidity(int paramInt, Throwable paramThrowable) /* 326 */ { /* 327 */ return createValidity(paramInt, null, paramThrowable, false); /* 328 */ } /* 329 */ /* 330 */ private static IValidity createValidity(int paramInt, String paramString, Throwable paramThrowable, boolean paramBoolean) /* 331 */ { /* 332 */ if (paramBoolean) /* 333 */ return new Validity(8, "net.xmind.varify", 1, null, paramThrowable, /* 334 */ paramString); /* 335 */ return new Validity(0, "net.xmind.varify", 1, null, paramThrowable, /* 336 */ paramString); /* 337 */ } /* 338 */ /* 339 */ public static LicenseVerifier getInstance() /* 340 */ { /* 341 */ if (INSTANCE == null) /* 342 */ INSTANCE = new LicenseVerifier(); /* 343 */ return INSTANCE; /* 344 */ } /* 345 */ private static class ValidityNotifier { /* 346 */ private IVerifyListener listener; /* 347 */ private Display display; /* 348 */ /* 349 */ public ValidityNotifier(IVerifyListener paramIVerifyListener) { /* 350 */ this.listener = paramIVerifyListener; /* 351 */ this.display = Display.getCurrent(); /* 352 */ } /* 353 */ /* 354 */ public void notifyValidityListener(final IValidity paramIValidity) { /* 355 */ if (this.display != null) { /* 356 */ if (!this.display.isDisposed()) /* 357 */ this.display.syncExec(new Runnable() { /* 358 */ public void run() { /* 359 */ SafeRunner.run(new SafeRunnable() { /* 360 */ public void run() throws Exception { /* 361 */ LicenseVerifier.ValidityNotifier.this.listener /* 362 */ .notifyValidity(paramIValidity); /* 363 */ } /* 364 */ }); /* 365 */ } /* 366 */ }); /* 367 */ } /* 368 */ else SafeRunner.run(new SafeRunnable() { /* 369 */ public void run() throws Exception { /* 370 */ LicenseVerifier.ValidityNotifier.this.listener /* 371 */ .notifyValidity(paramIValidity); /* 372 */ } /* 373 */ }); /* 374 */ } /* 375 */ /* 376 */ public boolean notifyValidityCallback(final IValidity paramIValidity) /* 377 */ { /* 378 */ if ((this.listener instanceof IVerifyCallback)) { /* 379 */ final boolean[] arrayOfBoolean = new boolean[1]; /* 380 */ arrayOfBoolean[0] = false; /* 381 */ if (this.display != null) { /* 382 */ if (!this.display.isDisposed()) /* 383 */ this.display.syncExec(new Runnable() { /* 384 */ public void run() { /* 385 */ SafeRunner.run(new SafeRunnable() { /* 386 */ public void run() throws Exception { /* 387 */ ((IVerifyCallback)LicenseVerifier.ValidityNotifier.this.listener) /* 388 */ .handleValidity(paramIValidity); /* 389 */ } /* 390 */ }); /* 391 */ } /* 392 */ }); /* 393 */ } /* 394 */ else SafeRunner.run(new SafeRunnable() { /* 395 */ public void run() throws Exception { /* 396 */ arrayOfBoolean[0] = ((IVerifyCallback)LicenseVerifier.ValidityNotifier.this.listener) /* 397 */ .handleValidity(paramIValidity); /* 398 */ } /* 399 */ }); /* 400 */ return arrayOfBoolean[0]; /* 401 */ } /* 402 */ notifyValidityListener(paramIValidity); /* 403 */ return false; /* 404 */ } /* 405 */ } /* 406 */ /* 407 */ private static class VerificationJob extends Job { /* 408 */ private List<String> actionNames = new ArrayList<String>(2); /* 409 */ private int requiredStatus; /* 410 */ private int style; /* 411 */ private IPreferenceStore prefStore; /* 412 */ private IStatus validity; /* 413 */ private String licenseKey = null; /* 414 */ private String licenseEmail = null; /* 415 */ private String user = null; /* 416 */ private String authToken = null; /* 417 */ private String uid = null; /* 418 */ private String expiration = null; /* 419 */ private XMindNetRequest retrieveUIDRequest = new XMindNetRequest(true); /* 420 */ private XMindNetRequest retrieveSubscriptionRequest = new XMindNetRequest( /* 421 */ true); /* 422 */ /* 423 */ private ActivateProDialog inputDialog = null; /* 424 */ /* 425 */ public VerificationJob(String paramString, int paramInt1, int paramInt2) { /* 426 */ super(""); /* 427 */ if (paramString != null) /* 428 */ this.actionNames.add(paramString); /* 429 */ this.requiredStatus = paramInt1; /* 430 */ this.style = paramInt2; /* 431 */ this.prefStore = VerifyPlugin.getDefault().getPreferenceStore(); /* 432 */ this.validity = LicenseVerifier.createValidity(1024); /* 433 */ setSystem(true); /* 434 */ } /* 435 */ /* 436 */ public void updateActionName(String paramString) { /* 437 */ if (paramString != null) /* 438 */ this.actionNames.add(paramString); /* 439 */ } /* 440 */ /* 441 */ public void updateRequiredStatus(int paramInt) { /* 442 */ this.requiredStatus &= paramInt; /* 443 */ } /* 444 */ /* 445 */ public void updateStyle(int paramInt) { /* 446 */ this.style = mergeStyle(this.style, paramInt, 1, true); /* 447 */ this.style = mergeStyle(this.style, paramInt, 2, true); /* 448 */ this.style = mergeStyle(this.style, paramInt, 4, false); /* 449 */ this.style = mergeStyle(this.style, paramInt, 8, false); /* 450 */ } /* 451 */ /* 452 */ private static int mergeStyle(int paramInt1, int paramInt2, int paramInt3, boolean paramBoolean) /* 453 */ { /* 454 */ if (paramBoolean) /* 455 */ return paramInt1 & ( /* 456 */ paramInt2 & paramInt3 | paramInt3 ^ 0xFFFFFFFF); /* 457 */ return paramInt1 | paramInt2 & paramInt3; /* 458 */ } /* 459 */ /* 460 */ protected IStatus run(IProgressMonitor paramIProgressMonitor) { /* 461 */ verify(paramIProgressMonitor); /* 462 */ if ((paramIProgressMonitor.isCanceled()) && /* 463 */ (!LicenseVerifier.checkValid(this.validity, 7))) /* 464 */ this.validity = LicenseVerifier.createValidity(1024, null, /* 465 */ null, true); /* 466 */ LicenseVerifier.saveLocalData(this.uid, this.expiration, /* 467 */ this.licenseKey, this.licenseEmail); /* 468 */ return this.validity; /* 469 */ } /* 470 */ /* 471 */ private boolean isValid() { /* 472 */ return LicenseVerifier.checkValid(this.validity, /* 473 */ this.requiredStatus); /* 474 */ } /* 475 */ /* 476 */ private void verify(IProgressMonitor paramIProgressMonitor) { /* 477 */ verifyVindy(paramIProgressMonitor); /* 478 */ if (paramIProgressMonitor.isCanceled()) /* 479 */ return; /* 480 */ if (isValid()) /* 481 */ return; /* 482 */ verifyLocalData(paramIProgressMonitor); /* 483 */ if (paramIProgressMonitor.isCanceled()) /* 484 */ return; /* 485 */ if (((this.style & 0x8) == 0) && ( /* 486 */ (isValid()) || ((this.style & 0x2) != 0))) /* 487 */ return; /* 488 */ waitForWorkbenchReady(paramIProgressMonitor); /* 489 */ if (paramIProgressMonitor.isCanceled()) /* 490 */ return; /* 491 */ openInputDialog(paramIProgressMonitor); /* 492 */ } /* 493 */ /* 494 */ private void waitForWorkbenchReady(IProgressMonitor paramIProgressMonitor) /* 495 */ { /* 496 */ if (System.getProperty("org.xmind.cathy.app.status") == null) /* 497 */ return; /* 498 */ try { /* 499 */ do { /* 500 */ if (paramIProgressMonitor.isCanceled()) /* 501 */ return; /* 502 */ Thread.sleep(500L); /* 503 */ } /* 504 */ while (! /* 505 */ isWorkbenchReady()); /* 506 */ } catch (InterruptedException localInterruptedException) { /* 507 */ } /* 508 */ } /* 509 */ /* 510 */ private boolean isWorkbenchReady() { /* 511 */ return "workbenchReady".equals( /* 512 */ System.getProperty("org.xmind.cathy.app.status")); /* 513 */ } /* 514 */ /* 515 */ private void verifyLocalData(IProgressMonitor paramIProgressMonitor) { /* 516 */ loadLocalLicenseKey(paramIProgressMonitor); /* 517 */ if (paramIProgressMonitor.isCanceled()) /* 518 */ return; /* 519 */ if ((hasLicenseKey()) && (hasLicenseEmail())) { /* 520 */ verifyProLicenseKey(paramIProgressMonitor); /* 521 */ if (paramIProgressMonitor.isCanceled()) /* 522 */ return; /* 523 */ if (!isValid()) /* 524 */ verifyPlusLicenseKey(paramIProgressMonitor); /* 525 */ } /* 526 */ if (paramIProgressMonitor.isCanceled()) /* 527 */ return; /* 528 */ IStatus localIStatus = this.validity; /* 529 */ boolean bool = LicenseVerifier.checkValid(localIStatus, 2); /* 530 */ if (bool) /* 531 */ return; /* 532 */ loadLocalUserInfo(paramIProgressMonitor); /* 533 */ if (paramIProgressMonitor.isCanceled()) /* 534 */ return; /* 535 */ if ((hasUser()) && (hasAuthToken())) { /* 536 */ loadLocalSubscriptionInfo(paramIProgressMonitor); /* 537 */ if (paramIProgressMonitor.isCanceled()) /* 538 */ return; /* 539 */ if ((hasUID()) && (hasExpiration())) { /* 540 */ verifyLocalSubscriptionInfo(paramIProgressMonitor); /* 541 */ if (isValid()) /* 542 */ return; /* 543 */ } /* 544 */ if (paramIProgressMonitor.isCanceled()) /* 545 */ return; /* 546 */ verifySubscription(paramIProgressMonitor); /* 547 */ if (isValid()) /* 548 */ return; /* 549 */ this.validity = localIStatus; /* 550 */ } /* 551 */ } /* 552 */ /* 553 */ private void loadLocalLicenseKey(IProgressMonitor paramIProgressMonitor) { /* 554 */ this.licenseKey = this.prefStore.getString("licenseKey"); /* 555 */ this.licenseEmail = this.prefStore.getString("licenseEmail"); /* 556 */ } /* 557 */ /* 558 */ private void loadLocalUserInfo(IProgressMonitor paramIProgressMonitor) { /* 559 */ IAccountInfo localIAccountInfo = XMindNet.getAccountInfo(); /* 560 */ this.user = (localIAccountInfo == null ? null : localIAccountInfo /* 561 */ .getUser()); /* 562 */ this.authToken = (localIAccountInfo == null ? null : /* 563 */ localIAccountInfo.getAuthToken()); /* 564 */ } /* 565 */ /* 566 */ private void loadLocalSubscriptionInfo(IProgressMonitor paramIProgressMonitor) /* 567 */ { /* 568 */ this.uid = this.prefStore.getString("uid"); /* 569 */ this.expiration = this.prefStore.getString("expiration"); /* 570 */ } /* 571 */ /* 572 */ private void verifyLocalSubscriptionInfo(IProgressMonitor paramIProgressMonitor) /* 573 */ { /* 574 */ this.validity = LicenseVerifier.createValidity( /* 575 */ LicenseVerifier.parseExpiration(this.expiration, this.uid), /* 576 */ this.user); /* 577 */ } /* 578 */ /* 579 */ private void verifyProLicenseKey(IProgressMonitor paramIProgressMonitor) { /* 580 */ if (LicenseVerifier.invalidLicenseKeys.contains(this.licenseEmail + /* 581 */ "|" + this.licenseKey)) /* 582 */ this.validity = LicenseVerifier.createValidity(8192); /* 583 */ else /* 584 */ verifySignature(this.licenseEmail, this.licenseKey, /* 585 */ "`_xmind.org\n9527\t", getProPublicKey(), 2, /* 586 */ paramIProgressMonitor); /* 587 */ } /* 588 */ /* 589 */ private void verifyPlusLicenseKey(IProgressMonitor paramIProgressMonitor) { /* 590 */ if (LicenseVerifier.invalidLicenseKeys.contains(this.licenseEmail + /* 591 */ "|" + this.licenseKey)) /* 592 */ this.validity = LicenseVerifier.createValidity(8192); /* 593 */ else /* 594 */ verifySignature(this.licenseEmail, this.licenseKey, /* 595 */ "*#xmind\nnet.3914\t", getPlusPublicKey(), 4, /* 596 */ paramIProgressMonitor); /* 597 */ } /* 598 */ /* 599 */ private void verifySignature(String paramString1, String paramString2, String paramString3, byte[] paramArrayOfByte, int paramInt, IProgressMonitor paramIProgressMonitor) /* 600 */ { /* 601 */ if (paramString2.length() < 8) { /* 602 */ this.validity = LicenseVerifier.createValidity(8192); /* 603 */ return; /* 604 */ } /* 605 */ try { /* 606 */ paramString1 = paramString2.substring(0, 8) + paramString1; /* 607 */ paramString2 = paramString2.substring(8); /* 608 */ byte[] arrayOfByte = Base32.decode(paramString2); /* 609 */ if (isSignatureValid((paramString1 + paramString3).getBytes(), /* 610 */ arrayOfByte, paramArrayOfByte)) /* 611 */ this.validity = LicenseVerifier.createValidity(paramInt, /* 612 */ this.licenseEmail); /* 613 */ else /* 614 */ this.validity = LicenseVerifier.createValidity(8192); /* 615 */ } catch (Exception localException) { /* 616 */ this.validity = LicenseVerifier.createValidity(1073741824, /* 617 */ localException); /* 618 */ } /* 619 */ } /* 620 */ /* 621 */ private boolean isSignatureValid(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2, byte[] paramArrayOfByte3) /* 622 */ throws Exception /* 623 */ { /* 624 */ RSAEngine localRSAEngine = new RSAEngine(); /* 625 */ MD5Digest localMD5Digest = new MD5Digest(); /* 626 */ PSSSigner localPSSSigner = new PSSSigner(localRSAEngine, /* 627 */ localMD5Digest, 32); /* 628 */ localPSSSigner.init(false, parsePublicKey(paramArrayOfByte3)); /* 629 */ localPSSSigner.update(paramArrayOfByte1, 0, /* 630 */ paramArrayOfByte1.length); /* 631 */ return localPSSSigner.verifySignature(paramArrayOfByte2); /* 632 */ } /* 633 */ /* 634 */ private byte[] getProPublicKey() { /* 635 */ return new byte[] { 77, 73, 71, 102, 77, 65, 48, 71, 67, 83, 113, /* 636 */ 71, 83, 73, 98, 51, 68, 81, 69, 66, 65, 81, 85, 65, 65, 52, /* 637 */ 71, 78, 65, 68, 67, 66, 105, 81, 75, 66, 103, 81, 67, 100, /* 638 */ 54, 74, 99, 100, 109, 118, 100, 85, 83, 84, 112, 66, 78, /* 639 */ 118, 114, 119, 55, 83, 49, 73, 100, 114, 110, 76, 106, 70, /* 640 */ 79, 110, 50, 117, 112, 89, 120, 67, 52, 85, 101, 71, 121, /* 641 */ 112, 101, 43, 68, 119, 85, 122, 52, 83, 113, 54, 115, 100, /* 642 */ 67, 100, 119, 68, 83, 118, 56, 107, 114, 52, 82, 99, 77, /* 643 */ 82, 83, 75, 55, 110, 77, 78, 55, 57, 79, 57, 104, 99, 121, /* 644 */ 106, 90, 69, 103, 105, 119, 120, 57, 101, 75, 69, 74, 85, /* 645 */ 99, 68, 82, 101, 112, 97, 48, 66, 121, 72, 115, 49, 56, /* 646 */ 102, 71, 113, 74, 105, 52, 51, 110, 57, 47, 118, 71, 104, /* 647 */ 99, 78, 84, 86, 120, 85, 109, 53, 109, 112, 74, 115, 103, /* 648 */ 53, 82, 112, 51, 111, 74, 51, 56, 98, 68, 86, 69, 110, 55, /* 649 */ 68, 55, 88, 116, 82, 101, 78, 78, 83, 78, 101, 113, 77, /* 650 */ 111, 121, 112, 120, 105, 69, 114, 43, 113, 55, 110, 119, /* 651 */ 73, 68, 65, 81, 65, 66 }; /* 652 */ } /* 653 */ /* 654 */ private byte[] getPlusPublicKey() { /* 655 */ return new byte[] { 77, 73, 71, 102, 77, 65, 48, 71, 67, 83, 113, /* 656 */ 71, 83, 73, 98, 51, 68, 81, 69, 66, 65, 81, 85, 65, 65, 52, /* 657 */ 71, 78, 65, 68, 67, 66, 105, 81, 75, 66, 103, 81, 67, 104, /* 658 */ 105, 71, 48, 119, 72, 104, 43, 115, 68, 57, 49, 52, 54, 65, /* 659 */ 98, 76, 75, 75, 76, 73, 101, 48, 98, 83, 87, 110, 122, 71, /* 660 */ 65, 112, 106, 43, 120, 110, 101, 121, 69, 110, 65, 112, 57, /* 661 */ 111, 116, 118, 83, 52, 105, 101, 48, 78, 77, 75, 72, 122, /* 662 */ 101, 81, 89, 48, 118, 47, 107, 65, 89, 70, 51, 99, 102, 43, /* 663 */ 114, 68, 113, 73, 68, 90, 85, 71, 109, 49, 79, 115, 105, /* 664 */ 72, 75, 116, 57, 50, 112, 57, 72, 106, 119, 81, 48, 48, 89, /* 665 */ 120, 117, 116, 87, 78, 116, 109, 109, 55, 90, 73, 104, 69, /* 666 */ 57, 90, 89, 43, 116, 76, 100, 87, 78, 118, 116, 53, 107, /* 667 */ 55, 52, 82, 47, 48, 100, 51, 75, 81, 69, 90, 76, 68, 82, /* 668 */ 109, 80, 114, 98, 49, 109, 104, 116, 73, 65, 50, 89, 75, /* 669 */ 108, 82, 50, 77, 116, 109, 51, 43, 82, 113, 68, 101, 50, /* 670 */ 115, 90, 78, 109, 112, 71, 111, 102, 119, 73, 68, 65, 81, /* 671 */ 65, 66 }; /* 672 */ } /* 673 */ /* 674 */ private byte[] getVindyPublicKey() { /* 675 */ return new byte[] { 77, 73, 71, 102, 77, 65, 48, 71, 67, 83, 113, /* 676 */ 71, 83, 73, 98, 51, 68, 81, 69, 66, 65, 81, 85, 65, 65, 52, /* 677 */ 71, 78, 65, 68, 67, 66, 105, 81, 75, 66, 103, 81, 68, 98, /* 678 */ 73, 106, 85, 74, 67, 47, 121, 76, 77, 83, 106, 113, 74, 76, /* 679 */ 99, 48, 116, 81, 43, 98, 54, 97, 69, 97, 103, 66, 68, 70, /* 680 */ 47, 101, 105, 81, 100, 70, 51, 49, 103, 79, 103, 98, 52, /* 681 */ 113, 105, 54, 85, 54, 113, 56, 97, 81, 65, 43, 65, 85, 84, /* 682 */ 56, 67, 101, 87, 68, 102, 108, 83, 119, 100, 85, 53, 118, /* 683 */ 55, 86, 53, 86, 98, 111, 56, 86, 102, 47, 119, 75, 81, 75, /* 684 */ 119, 119, 113, 114, 48, 119, 98, 56, 66, 87, 85, 53, 51, /* 685 */ 85, 121, 120, 121, 65, 73, 115, 121, 68, 118, 77, 110, 77, /* 686 */ 114, 118, 51, 119, 85, 101, 48, 71, 98, 68, 102, 82, 76, /* 687 */ 53, 108, 105, 101, 101, 49, 98, 105, 75, 99, 75, 103, 100, /* 688 */ 104, 107, 73, 121, 53, 88, 89, 114, 109, 77, 86, 49, 74, /* 689 */ 48, 50, 74, 49, 79, 89, 98, 109, 115, 69, 110, 49, 107, 70, /* 690 */ 99, 122, 122, 116, 115, 47, 72, 79, 119, 73, 68, 65, 81, /* 691 */ 65, 66 }; /* 692 */ } /* 693 */ /* 694 */ private CipherParameters parsePublicKey(byte[] paramArrayOfByte) throws Exception /* 695 */ { /* 696 */ byte[] arrayOfByte = Base64.decode(paramArrayOfByte); /* 697 */ ASN1InputStream localASN1InputStream = new ASN1InputStream( /* 698 */ arrayOfByte); /* 699 */ ASN1Sequence localASN1Sequence = (ASN1Sequence)localASN1InputStream /* 700 */ .readObject(); /* 701 */ SubjectPublicKeyInfo localSubjectPublicKeyInfo = new SubjectPublicKeyInfo( /* 702 */ localASN1Sequence); /* 703 */ RSAPublicKey localRSAPublicKey = /* 704 */ RSAPublicKey.getInstance(localSubjectPublicKeyInfo.parsePublicKey()); /* 705 */ return new RSAKeyParameters(false, localRSAPublicKey.getModulus(), /* 706 */ localRSAPublicKey.getPublicExponent()); /* 707 */ } /* 708 */ /* 709 */ private void verifyVindy(IProgressMonitor paramIProgressMonitor) { /* 710 */ String str = checkValidVindy(paramIProgressMonitor); /* 711 */ if (str != null) /* 712 */ this.validity = LicenseVerifier.createValidity(0, str); /* 713 */ } /* 714 */ /* 715 */ private String checkValidVindy(IProgressMonitor paramIProgressMonitor) { /* 716 */ String str1 = /* 717 */ System.getProperty("org.xmind.product.distribution.id"); /* 718 */ if ((str1 == null) || ("".equals(str1)) || /* 719 */ (!str1.startsWith("vindy"))) /* 720 */ return null; /* 721 */ String str2 = /* 722 */ System.getProperty("org.xmind.product.distribution.vindy.org"); /* 723 */ if ((str2 == null) || ("".equals(str2))) /* 724 */ return null; /* 725 */ String str3 = /* 726 */ System.getProperty("org.xmind.product.distribution.vindy.time"); /* 727 */ if ((str3 == null) || ("".equals(str3))) /* 728 */ return null; /* 729 */ String str4 = /* 730 */ System.getProperty("org.xmind.product.distribution.vindy.name"); /* 731 */ if ((str4 == null) || ("".equals(str4))) /* 732 */ return null; /* 733 */ String str5 = str2 + str3; /* 734 */ IStatus localIStatus = this.validity; /* 735 */ verifySignature(str5, str4, "^xmap61\nbg4[d\t", /* 736 */ getVindyPublicKey(), 2, paramIProgressMonitor); /* 737 */ if (isValid()) /* 738 */ return str2; /* 739 */ this.validity = localIStatus; /* 740 */ return null; /* 741 */ } /* 742 */ /* 743 */ private void verifySubscription(IProgressMonitor paramIProgressMonitor) { /* 744 */ retrieveUID(paramIProgressMonitor); /* 745 */ if (paramIProgressMonitor.isCanceled()) /* 746 */ return; /* 747 */ if (hasUID()) /* 748 */ retrieveSubscription(paramIProgressMonitor); /* 749 */ } /* 750 */ /* 751 */ private void openInputDialog(final IProgressMonitor paramIProgressMonitor) /* 752 */ { /* 753 */ final Properties localProperties = new Properties(); /* 754 */ if (this.licenseEmail != null) /* 755 */ localProperties.setProperty("licenseEmail", this.licenseEmail); /* 756 */ if (this.licenseEmail != null) /* 757 */ localProperties.setProperty("licenseKey", this.licenseKey); /* 758 */ if (this.user != null) /* 759 */ localProperties.setProperty("user", this.user); /* 760 */ final Job local1 = new Job("Verify Pro License Key") /* 761 */ { /* 762 */ protected IStatus run(IProgressMonitor paramAnonymousIProgressMonitor) { /* 763 */ doVerifyLicenseKey(paramAnonymousIProgressMonitor); /* 764 */ return LicenseVerifier.VerificationJob.this.validity; /* 765 */ } /* 766 */ /* 767 */ private void doVerifyLicenseKey(IProgressMonitor paramAnonymousIProgressMonitor) /* 768 */ { /* 769 */ paramAnonymousIProgressMonitor.beginTask(null, 1); /* 770 */ if ((paramIProgressMonitor.isCanceled()) || /* 771 */ (paramAnonymousIProgressMonitor.isCanceled())) /* 772 */ return; /* 773 */ LicenseVerifier.VerificationJob.this /* 774 */ .loadInfoFromInput(localProperties); /* 775 */ if ((paramIProgressMonitor.isCanceled()) || /* 776 */ (paramAnonymousIProgressMonitor.isCanceled())) /* 777 */ return; /* 778 */ if (LicenseVerifier.VerificationJob.this.hasLicenseKey()) /* 779 */ { /* 780 */ if (LicenseVerifier.VerificationJob.this /* 781 */ .hasLicenseEmail()) /* 782 */ LicenseVerifier.VerificationJob.this /* 783 */ .verifyProLicenseKey(paramAnonymousIProgressMonitor); /* 784 */ } /* 785 */ if ((!paramIProgressMonitor.isCanceled()) && ( /* 786 */ paramAnonymousIProgressMonitor.isCanceled())); /* 787 */ } /* 788 */ }; /* 789 */ local1.setSystem(true); /* 790 */ final Job local2 = new Job("Verify Plus License Key") /* 791 */ { /* 792 */ protected IStatus run(IProgressMonitor paramAnonymousIProgressMonitor) { /* 793 */ doVerifyLicenseKey(paramAnonymousIProgressMonitor); /* 794 */ return LicenseVerifier.VerificationJob.this.validity; /* 795 */ } /* 796 */ /* 797 */ private void doVerifyLicenseKey(IProgressMonitor paramAnonymousIProgressMonitor) /* 798 */ { /* 799 */ paramAnonymousIProgressMonitor.beginTask(null, 1); /* 800 */ if ((paramIProgressMonitor.isCanceled()) || /* 801 */ (paramAnonymousIProgressMonitor.isCanceled())) /* 802 */ return; /* 803 */ LicenseVerifier.VerificationJob.this /* 804 */ .loadInfoFromInput(localProperties); /* 805 */ if ((paramIProgressMonitor.isCanceled()) || /* 806 */ (paramAnonymousIProgressMonitor.isCanceled())) /* 807 */ return; /* 808 */ if (LicenseVerifier.VerificationJob.this.hasLicenseKey()) /* 809 */ { /* 810 */ if (LicenseVerifier.VerificationJob.this /* 811 */ .hasLicenseEmail()) /* 812 */ LicenseVerifier.VerificationJob.this /* 813 */ .verifyPlusLicenseKey(paramAnonymousIProgressMonitor); /* 814 */ } /* 815 */ if ((!paramIProgressMonitor.isCanceled()) && ( /* 816 */ paramAnonymousIProgressMonitor.isCanceled())); /* 817 */ } /* 818 */ }; /* 819 */ local2.setSystem(true); /* 820 */ final Job local3 = new Job("Verify License Key") /* 821 */ { /* 822 */ protected IStatus run(IProgressMonitor paramAnonymousIProgressMonitor) { /* 823 */ doVerifySubscription(paramAnonymousIProgressMonitor); /* 824 */ return LicenseVerifier.VerificationJob.this.validity; /* 825 */ } /* 826 */ /* 827 */ private void doVerifySubscription(IProgressMonitor paramAnonymousIProgressMonitor) /* 828 */ { /* 829 */ paramAnonymousIProgressMonitor.beginTask(null, 1); /* 830 */ if ((paramIProgressMonitor.isCanceled()) || /* 831 */ (paramAnonymousIProgressMonitor.isCanceled())) /* 832 */ return; /* 833 */ LicenseVerifier.VerificationJob.this /* 834 */ .loadInfoFromInput(localProperties); /* 835 */ if ((paramIProgressMonitor.isCanceled()) || /* 836 */ (paramAnonymousIProgressMonitor.isCanceled())) /* 837 */ return; /* 838 */ if (LicenseVerifier.VerificationJob.this.hasUser()) /* 839 */ { /* 840 */ if (LicenseVerifier.VerificationJob.this /* 841 */ .hasAuthToken()) /* 842 */ LicenseVerifier.VerificationJob.this /* 843 */ .verifySubscription(paramAnonymousIProgressMonitor); /* 844 */ } /* 845 */ if ((!paramIProgressMonitor.isCanceled()) && ( /* 846 */ paramAnonymousIProgressMonitor.isCanceled())); /* 847 */ } /* 848 */ /* 849 */ protected void canceling() { /* 850 */ LicenseVerifier.VerificationJob.this.retrieveUIDRequest /* 851 */ .abort(); /* 852 */ LicenseVerifier.VerificationJob.this.retrieveSubscriptionRequest /* 853 */ .abort(); /* 854 */ super.canceling(); /* 855 */ } /* 856 */ }; /* 857 */ local3.setSystem(true); /* 858 */ final IWorkbench localIWorkbench = PlatformUI.getWorkbench(); /* 859 */ Display localDisplay = localIWorkbench.getDisplay(); /* 860 */ if ((localDisplay == null) || (localDisplay.isDisposed())) /* 861 */ return; /* 862 */ if (paramIProgressMonitor.isCanceled()) /* 863 */ return; /* 864 */ localDisplay.syncExec(new Runnable() { /* 865 */ public void run() { /* 866 */ IWorkbenchWindow localIWorkbenchWindow = localIWorkbench /* 867 */ .getActiveWorkbenchWindow(); /* 868 */ Shell localShell = localIWorkbenchWindow == null ? null : /* 869 */ localIWorkbenchWindow.getShell(); /* 870 */ if ((localShell != null) && (localShell.isDisposed())) /* 871 */ localShell = null; /* 872 */ LicenseVerifier.VerificationJob.this.inputDialog = new ActivateProDialog( /* 873 */ localShell, /* 874 */ LicenseVerifier.VerificationJob.joinStr(LicenseVerifier.VerificationJob.this.actionNames), /* 875 */ LicenseVerifier.VerificationJob.this.requiredStatus, /* 876 */ LicenseVerifier.VerificationJob.this.validity /* 877 */ .getCode(), /* 878 */ localProperties, /* 879 */ (LicenseVerifier.VerificationJob.this.style & 0x4) != 0, /* 880 */ (LicenseVerifier.VerificationJob.this.style & 0x8) != 0, /* 881 */ local1, local2, local3); /* 882 */ int i = LicenseVerifier.VerificationJob.this.inputDialog /* 883 */ .open(); /* 884 */ if (i == 1) { /* 885 */ local1.cancel(); /* 886 */ local2.cancel(); /* 887 */ local3.cancel(); /* 888 */ LicenseVerifier.VerificationJob.this.cancel(); /* 889 */ paramIProgressMonitor.setCanceled(true); /* 890 */ } /* 891 */ } /* 892 */ }); /* 893 */ if ((LicenseVerifier.hasValidity(this.validity, 1)) && (hasUser()) && /* 894 */ (hasAuthToken())) { /* 895 */ long l = System.currentTimeMillis() + 604800L; /* 896 */ InternalXMindNet.getInstance().getAccount() /* 897 */ .signedIn(this.user, this.authToken, l, true); /* 898 */ } /* 899 */ } /* 900 */ /* 901 */ private static String joinStr(Collection paramCollection) { /* 902 */ StringBuffer localStringBuffer = new StringBuffer( /* 903 */ paramCollection.size() * 10); /* 904 */ Iterator localIterator = paramCollection.iterator(); /* 905 */ while (localIterator.hasNext()) { /* 906 */ String str = (String)localIterator.next(); /* 907 */ if (localStringBuffer.length() > 0) /* 908 */ localStringBuffer.append(", "); /* 909 */ localStringBuffer.append(str); /* 910 */ } /* 911 */ return localStringBuffer.toString(); /* 912 */ } /* 913 */ /* 914 */ private void loadInfoFromInput(Properties paramProperties) { /* 915 */ this.licenseEmail = paramProperties.getProperty("licenseEmail"); /* 916 */ this.licenseKey = paramProperties.getProperty("licenseKey"); /* 917 */ this.user = paramProperties.getProperty("user"); /* 918 */ this.authToken = paramProperties.getProperty("token"); /* 919 */ } /* 920 */ /* 921 */ private void retrieveSubscription(IProgressMonitor paramIProgressMonitor) { /* 922 */ this.retrieveSubscriptionRequest /* 923 */ .uri("/_res/verify/%s", new Object[] { this.user }) /* 924 */ .addHeader("UID", this.uid).get(); /* 925 */ if ((paramIProgressMonitor.isCanceled()) || /* 926 */ (this.retrieveSubscriptionRequest.isAborted())) /* 927 */ return; /* 928 */ int i = this.retrieveSubscriptionRequest.getCode(); /* 929 */ IDataStore localIDataStore = this.retrieveSubscriptionRequest /* 930 */ .getData(); /* 931 */ if ((i == 200) && (localIDataStore != null)) { /* 932 */ this.expiration = LicenseVerifier.extractExpiration( /* 933 */ localIDataStore, this.uid); /* 934 */ if (this.expiration == null) /* 935 */ this.validity = LicenseVerifier.createValidity(4096); /* 936 */ else /* 937 */ this.validity = LicenseVerifier.createValidity( /* 938 */ LicenseVerifier.parseExpiration(this.expiration, /* 939 */ this.uid), this.user); /* 940 */ } else if (this.retrieveUIDRequest.getException() != null) { /* 941 */ this.validity = LicenseVerifier.createValidity(1073741824, /* 942 */ this.retrieveUIDRequest.getException()); /* 943 */ } else if ((i >= 500) || (i < 400)) { /* 944 */ this.validity = LicenseVerifier.createValidity(1073741824); /* 945 */ } /* 946 */ } /* 947 */ /* 948 */ private void retrieveUID(IProgressMonitor paramIProgressMonitor) { /* 949 */ this.retrieveUIDRequest /* 950 */ .uri("/_res/uid/%s", new Object[] { this.user }) /* 951 */ .setAuthToken(this.authToken).get(); /* 952 */ if ((paramIProgressMonitor.isCanceled()) || /* 953 */ (this.retrieveUIDRequest.isAborted())) /* 954 */ return; /* 955 */ int i = this.retrieveUIDRequest.getCode(); /* 956 */ IDataStore localIDataStore = this.retrieveUIDRequest.getData(); /* 957 */ if ((i == 200) && (localIDataStore != null)) /* 958 */ this.uid = localIDataStore.getString("uid"); /* 959 */ else if (this.retrieveUIDRequest.getException() != null) /* 960 */ this.validity = LicenseVerifier.createValidity(1073741824, /* 961 */ this.retrieveUIDRequest.getException()); /* 962 */ else if ((i >= 500) || (i < 400)) /* 963 */ this.validity = LicenseVerifier.createValidity(1073741824); /* 964 */ } /* 965 */ /* 966 */ private boolean hasLicenseKey() { /* 967 */ return (this.licenseKey != null) && (!"".equals(this.licenseKey)); /* 968 */ } /* 969 */ /* 970 */ private boolean hasLicenseEmail() /* 971 */ { /* 972 */ return (this.licenseEmail != null) && /* 973 */ (!"".equals(this.licenseEmail)); /* 974 */ } /* 975 */ /* 976 */ private boolean hasUser() { /* 977 */ return (this.user != null) && (!"".equals(this.user)); /* 978 */ } /* 979 */ /* 980 */ private boolean hasAuthToken() { /* 981 */ return (this.authToken != null) && (!"".equals(this.authToken)); /* 982 */ } /* 983 */ /* 984 */ private boolean hasUID() { /* 985 */ return (this.uid != null) && (!"".equals(this.uid)); /* 986 */ } /* 987 */ /* 988 */ private boolean hasExpiration() { /* 989 */ return (this.expiration != null) && (!"".equals(this.expiration)); /* 990 */ } /* 991 */ /* 992 */ protected void canceling() { /* 993 */ this.retrieveUIDRequest.abort(); /* 994 */ this.retrieveSubscriptionRequest.abort(); /* 995 */ final ActivateProDialog localActivateProDialog = this.inputDialog; /* 996 */ if (localActivateProDialog != null) { /* 997 */ IWorkbench localIWorkbench = PlatformUI.getWorkbench(); /* 998 */ if (localIWorkbench != null) { /* 999 */ final Display localDisplay = localIWorkbench.getDisplay(); /* 1000 */ if ((localDisplay != null) && (!localDisplay.isDisposed())) /* 1001 */ localDisplay.asyncExec(new Runnable() { /* 1002 */ public void run() { /* 1003 */ if (localDisplay.isDisposed()) /* 1004 */ return; /* 1005 */ localActivateProDialog.close(); /* 1006 */ } /* 1007 */ }); /* 1008 */ } /* 1009 */ } /* 1010 */ super.canceling(); /* 1011 */ } /* 1012 */ } /* 1013 */ }


6. Create build environment for ant with build.xml (build.xml should be created in ~/xmind.verify/ folder) as below
~/xmind.verify/build.xml    Select all
<?xml version="1.0" encoding="UTF-8"?> <project basedir="." default="jar"> <!--ant build file to recompile jar--> <property environment="env"/> <property name="project.base.dir" value="."/> <property name="xmind.class.path" value="/Applications/XMind.app/Contents/Resources/plugins"/> <property name="name" value="net.xmind.verify_3.3.0.201208102038"/> <property name="javafilename" value="LicenseVerifier"/> <property name="app.dir" value="/Applications/XMind.app/Contents/Resources/plugins" /> <property name="src" value="${project.base.dir}/src"/> <property name="test" value="${project.base.dir}/test"/> <property name="reference" value="${project.base.dir}/lib"/> <property name="build" value="${project.base.dir}/build"/> <property name="classes" value="${build}/classes"/> <property name="lib" value="${build}/lib"/> <path id="reference.class.path"> <pathelement path="${java.class.path}" /> <fileset dir="${reference}"> <include name="*.jar" /> </fileset> <fileset dir="${xmind.class.path}" includes="*.jar"/> </path> <target name="init"> <mkdir dir="${build}"/> <mkdir dir="${classes}"/> <mkdir dir="${lib}"/> </target> <target depends="init" name="pre.compile.test"> </target> <target depends="pre.compile.test" name="compile.src"> <javac debug="on" memoryMaximumSize="256m" memoryInitialSize="256m" fork="true" includeantruntime="false" destdir="${classes}" srcdir="${src}"> <classpath refid="reference.class.path" /> <compilerarg value="-Xlint:unchecked"/> </javac> </target> <target depends="compile.src" name="compile.test"> <javac debug="on" memoryMaximumSize="256m" memoryInitialSize="256m" fork="true" includeantruntime="false" destdir="${classes}"> <src path="${test}"/> <classpath refid="reference.class.path" /> <compilerarg value="-Xlint:unchecked"/> </javac> </target> <target depends="compile.src" name="jar"> <echo>=== BUILDING ${name}.jar ===</echo> <jar destfile="${lib}/${name}.jar"> <zipfileset src="${reference}/${name}.jar" excludes="**/${javafilename}*.class"/> <fileset dir="${classes}" excludes="**/Test.class"/> </jar> </target> <!-- INSTALL --> <target name="install" depends="jar"> <echo>=== INSTALLING ${name}.jar ===</echo> <copy file="${lib}/${name}.jar" tofile="${app.dir}/${name}.jar" overwrite="true" /> </target> <target name="clean"> <delete dir="${build}"/> </target> </project>


7. ant clean & build
cd ~/xmind.verify
ant clean jar



8. Update jar file and install to App folder
cd ~/xmind.verify/
ant install


P.S. this is how to add line numbers to the source code and then convert the angle brackets for this blog.
awk '{printf("/* %3d */ %s\n", NR,$0)}' filename | sed 's/</\&lt;/g;s/>/\&gt;/g' > filenamenumbered.txt