http://www.confluence.cn/pages/viewpage.action?pageId=6979701
http://www.oschina.net/p/java+decompiler
1.解压gliffy-confluence-plugin-5.1.jar到目录下gliffy-confluence-plugin-5.1\META-INF\lib查找gliffy-license-1.1.3.jar;
2.用decompiler反编译gliffy-license-1.1.3.jar;代码(代码编译依赖confluence的jar包和插件的jar包都添到classpath即可)修改后打成.zip包,再修改扩展名为.jar即可
3.找到类com.gliffy.core.license.PluginLicenseManager,把验证相关的全部返回true,或者去掉;
下面的代码安装通过【Powered by Atlassian Confluence 4.3.1】;没去细究具体走哪个
/* 1: */ package com.gliffy.core.license; /* 2: */ /* 3: */ import com.atlassian.extras.api.Contact; /* 4: */ import com.atlassian.extras.api.LicenseType; /* 5: */ import com.atlassian.extras.api.Organisation; /* 6: */ import com.atlassian.extras.api.ProductLicense; /* 7: */ import com.atlassian.sal.api.ApplicationProperties; /* 8: */ import com.atlassian.sal.api.net.Request; /* 9: */ import com.atlassian.sal.api.net.Request.MethodType; /* 10: */ import com.atlassian.sal.api.net.RequestFactory; /* 11: */ import com.atlassian.sal.api.net.Response; /* 12: */ import com.atlassian.sal.api.net.ResponseException; /* 13: */ import com.atlassian.sal.api.net.ResponseHandler; /* 14: */ import com.atlassian.sal.api.pluginsettings.PluginSettings; /* 15: */ import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; /* 16: */ import java.text.DateFormat; /* 17: */ import java.text.SimpleDateFormat; /* 18: */ import java.util.ArrayList; /* 19: */ import java.util.Calendar; /* 20: */ import java.util.Collection; /* 21: */ import java.util.Date; /* 22: */ import java.util.GregorianCalendar; /* 23: */ import java.util.List; /* 24: */ import java.util.Locale; /* 25: */ import java.util.Map; /* 26: */ import java.util.Map.Entry; /* 27: */ import org.slf4j.Logger; /* 28: */ import org.slf4j.LoggerFactory; /* 29: */ /* 30: */ public final class PluginLicenseManager /* 31: */ implements LicenseManager /* 32: */ { /* 33: 24 */ private static final Logger logger = LoggerFactory.getLogger(PluginLicenseManager.class); /* 34: 26 */ private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); /* 35: */ private static final String POSTBACK_ENDPOINT = "https://www.gliffy.com/_postback/"; /* 36: */ static final String GLIFFY_LICENSE_KEY = "com.gliffy.license.key"; /* 37: */ private License license; /* 38: */ private Product product; /* 39: */ private ProductLicense atlassianProductLicense; /* 40: */ private PluginSettingsFactory pluginSettingsFactory; /* 41: */ private ApplicationProperties applicationProperties; /* 42: */ private RequestFactory<?> requestFactory; /* 43: */ /* 44: */ public static enum LicenseEvent /* 45: */ { /* 46: 33 */ GENERATE_TRIAL_LICENSE, GENERATE_FREE_LICENSE, INSTALL_LICENSE; /* 47: */ /* 48: */ private LicenseEvent() {} /* 49: */ } /* 50: */ /* 51: 47 */ private List<LicenseGenerator> licenseGenerators = new ArrayList(); /* 52: 48 */ private List<LicenseError> licenseErrors = new ArrayList(); /* 53: */ /* 54: */ public PluginLicenseManager(PluginSettingsFactory pluginSettingsFactory, ApplicationProperties applicationProperties, RequestFactory<?> requestFactory, Product product, LicenseGenerator legacyLicenseReader) /* 55: */ { /* 56: 55 */ this.pluginSettingsFactory = pluginSettingsFactory; /* 57: 56 */ this.applicationProperties = applicationProperties; /* 58: 57 */ this.requestFactory = requestFactory; /* 59: 58 */ this.product = product; /* 60: */ ///* 61: 60 */ this.licenseGenerators.add(new HostedLicenseGenerator()); ///* 62: 61 */ this.licenseGenerators.add(new FreeLicenseGenerator()); ///* 63: 62 */ this.licenseGenerators.add(new EncodedLicenseReader()); ///* 64: 63 */ this.licenseGenerators.add(legacyLicenseReader); /* 65: 64 */ this.licenseGenerators.add(new TrialLicenseGenerator()); /* 66: */ } /* 67: */ /* 68: */ public synchronized License getLicense() /* 69: */ { /* 70: 68 */ logger.debug("Getting license"); /* 71: 69 */ if (this.license == null) /* 72: */ { /* 73: 70 */ logger.debug("No license found"); /* 74: 71 */ reloadLicense(); /* 75: */ } /* 76: 73 */ return this.license; /* 77: */ } /* 78: */ /* 79: */ public void reloadLicense() /* 80: */ { /* 81: 79 */ this.atlassianProductLicense = this.product.getProductLicense(); /* 82: 82 */ for (LicenseGenerator licenseGenerator : this.licenseGenerators) /* 83: */ { /* 84: 83 */ logger.debug("Attempting to generate license from={}", licenseGenerator.getClass().getSimpleName()); /* 85: 84 */ License license = licenseGenerator.getLicense(); /* 86: 85 */ if (license != null) /* 87: */ { /* 88: 86 */ logger.debug("License returned"); /* 89: */ try /* 90: */ { /* 91: 88 */ install(license); /* 92: */ } /* 93: */ catch (LicenseException e) /* 94: */ { /* 95: 92 */ logger.error("{}", e.getMessage()); /* 96: */ } /* 97: */ } /* 98: */ } /* 99: */ } /* 100: */ /* 101: */ public void install(License license) /* 102: */ throws LicenseException /* 103: */ { /* 104:100 */ logger.debug("Installing license"); ///* 105:101 */ if ((license.getLicenseKey() == null) || (license.getLicensedTo() == null) || (license.getLicenseType() == null)) { ///* 106:104 */ throw new LicenseException("gliffy.license.error.fieldsNotSet"); ///* 107: */ } /* 108:107 */ logger.debug("Checking license hash"); /* 109: */ /* 110:109 */ String expectedLicenseKey = hashIt(license); ///* 111:110 */ if (!license.getLicenseKey().equals(expectedLicenseKey)) ///* 112: */ { ///* 113:111 */ logger.debug("License key mismatch"); ///* 114:112 */ throw new LicenseException("gliffy.license.error.licenseKeyInvalid"); ///* 115: */ } /* 116:115 */ logger.debug("Checking product name"); ///* 117:117 */ if (!this.product.getProductName().equals(license.getLicensedSystem())) ///* 118: */ { ///* 119:118 */ logger.debug("Licensed system mismatch"); ///* 120:119 */ throw new LicenseException("gliffy.license.error.licenseKeyInvalid"); ///* 121: */ } /* 122:122 */ logger.debug("Getting global settings"); /* 123:123 */ PluginSettings pluginSettings = this.pluginSettingsFactory.createGlobalSettings(); /* 124: */ /* 125:125 */ logger.debug("Adding license key"); /* 126:126 */ pluginSettings.put("com.gliffy.license.key", license.toEncodedLicense()); /* 127: */ /* 128:128 */ this.license = license; /* 129:129 */ logger.debug("Installed new license"); /* 130: */ /* 131:131 */ validate(); /* 132: */ } /* 133: */ /* 134: */ public boolean isValidLicense() /* 135: */ { ///* 136:135 */ if (this.licenseErrors.isEmpty()) { ///* 137:136 */ checkFreeTrial(); ///* 138: */ } ///* 139:138 */ logger.debug("isValidLicense={}", Boolean.valueOf(this.licenseErrors.isEmpty())); ///* 140:139 */ return this.licenseErrors.isEmpty(); return true; /* 141: */ } /* 142: */ /* 143: */ public List<LicenseError> getLicenseErrors() /* 144: */ { /* 145:143 */ return this.licenseErrors; /* 146: */ } /* 147: */ /* 148: */ private void validate() /* 149: */ { ///* 150:148 */ logger.debug("Clearing license errors"); ///* 151: */ ///* 152: */ ///* 153:151 */ this.licenseErrors.clear(); ///* 154: */ ///* 155:153 */ logger.debug("Checking Atlassian license"); ///* 156:155 */ if ((this.license == null) || (this.atlassianProductLicense == null)) ///* 157: */ { ///* 158:156 */ Object[] licenses = { this.license, this.atlassianProductLicense }; ///* 159:157 */ logger.error("No licenses set gliffy={} atlassianProduct={}", licenses); ///* 160:158 */ this.licenseErrors.add(new LicenseError("gliffy.license.error.noInstalledLicense")); ///* 161:159 */ return; ///* 162: */ } ///* 163:162 */ logger.debug("Checking OnDemand"); ///* 164:163 */ if (this.license.isHosted()) ///* 165: */ { ///* 166:164 */ logger.debug("Running in OnDemand"); ///* 167:165 */ if (this.license.getExpirationDateObject() != null) ///* 168: */ { ///* 169:166 */ logger.debug("Gliffy inactive"); ///* 170:167 */ this.licenseErrors.add(new LicenseError("gliffy.license.error.unlicensed")); ///* 171: */ } ///* 172:169 */ return; ///* 173: */ } ///* 174:172 */ logger.debug("Checking free trial"); ///* 175: */ ///* 176:174 */ checkFreeTrial(); ///* 177:177 */ if (this.license.isRevoked()) ///* 178: */ { ///* 179:178 */ logger.error("Using a revoked license"); ///* 180:179 */ this.licenseErrors.add(new LicenseError("gliffy.license.error.revokedLicense")); ///* 181: */ } ///* 182:183 */ if ((this.license.getQuantityUsers() > 0) && (this.license.getQuantityUsers() < this.atlassianProductLicense.getMaximumNumberOfUsers())) ///* 183: */ { ///* 184:185 */ logger.error("Exceeded allowed users"); ///* 185:186 */ this.licenseErrors.add(new LicenseError("gliffy.license.error.maxUsersExceeded")); ///* 186: */ } ///* 187:190 */ if ((this.license.isPaid()) && (this.license.getExpirationDateObject().before(this.product.getBuildDate()))) ///* 188: */ { ///* 189:192 */ logger.error("Unlicensed upgrade"); ///* 190:193 */ this.licenseErrors.add(new LicenseError("gliffy.license.error.unlicensedUpgrade")); ///* 191: */ } ///* 192:197 */ if ((this.license.isFree()) && (!isAtlassianFree())) ///* 193: */ { ///* 194:198 */ logger.error("License mismatch"); ///* 195:199 */ this.licenseErrors.add(new LicenseError("gliffy.license.error.licenseMismatch")); ///* 196: */ } ///* 197:203 */ this.licenseErrors.addAll(this.product.validateLicense(this.license)); /* 198: */ } /* 199: */ /* 200: */ private void checkFreeTrial() /* 201: */ { /* 202:208 */ if ((this.license.isTrial()) && (this.license.isExpired())) /* 203: */ { /* 204:209 */ logger.warn("Free Trial has expired"); /* 205:210 */ this.licenseErrors.add(new LicenseError("gliffy.license.error.freeTrialExpired")); /* 206: */ } /* 207: */ } /* 208: */ /* 209: */ private boolean isAtlassianFree() /* 210: */ { ///* 211:215 */ switch (2.$SwitchMap$com$atlassian$extras$api$LicenseType[this.atlassianProductLicense.getLicenseType().ordinal()]) ///* 212: */ { ///* 213: */ case 1: ///* 214: */ case 2: ///* 215: */ case 3: ///* 216: */ case 4: ///* 217: */ case 5: ///* 218: */ case 6: ///* 219:222 */ return true; ///* 220: */ } /* 221:224 */ return false; /* 222: */ } /* 223: */ /* 224: */ private String hashIt(License license) /* 225: */ { /* 226:230 */ String trial = license.getLicenseType().toString(); /* 227:231 */ logger.debug("licenseType={}", trial); /* 228: */ /* 229: */ /* 230:234 */ return hashIt(license.getLicensedSystem(), license.getLicensedTo(), license.getExpirationDate(), license.getQuantityUsers(), license.getQuantityNodes(), trial); /* 231: */ } /* 232: */ /* 233: */ private String hashIt(String licType, String licTo, String expireDate, int qtyUsers, int qtyNodes, String trial) /* 234: */ { /* 235:244 */ String nodePart = ""; /* 236:248 */ if (qtyNodes > 1) { /* 237:249 */ nodePart = String.valueOf(qtyNodes); /* 238: */ } /* 239:252 */ return hashString(new StringBuilder().append("").append(qtyUsers).append(trial).append(licType).append(licTo).append(expireDate).append(nodePart).toString()) + "-" + hashString(new StringBuilder().append(licTo).append(qtyUsers).append(nodePart).append(trial).append(expireDate).append(licType).toString()) + "-" + hashString(new StringBuilder().append(nodePart).append(licTo).append(licType).append(qtyUsers).append(trial).append(expireDate).toString()) + "-" + hashString(new StringBuilder().append(licType).append(expireDate).append(nodePart).append(licTo).append(trial).append(qtyUsers).toString()); /* 240: */ } /* 241: */ /* 242: */ private String hashString(String toHash) /* 243: */ { /* 244:262 */ int b = 378551; /* 245:263 */ int a = 63689; /* 246:264 */ long hash = 0L; /* 247:266 */ for (int i = 0; i < toHash.length(); i++) /* 248: */ { /* 249:267 */ hash = hash * a + toHash.charAt(i); /* 250:268 */ a *= b; /* 251: */ } /* 252:271 */ long result = hash & 0x7FFFFFFF; /* 253: */ /* 254:273 */ return result + ""; /* 255: */ } /* 256: */ /* 257: */ public void sendLicenseEvent(LicenseEvent licenseEvent) /* 258: */ { /* 259:282 */ String productVersion = this.product.getVersion(); /* 260:283 */ if (productVersion.contains("-")) /* 261: */ { /* 262:284 */ logger.debug("No build id or build id contains sub-version qualifier"); /* 263:285 */ return; /* 264: */ } /* 265:288 */ List<String> data = new ArrayList(); /* 266: */ /* 267:290 */ data.add("product"); /* 268:291 */ data.add(this.atlassianProductLicense.getProduct().getName()); /* 269: */ /* 270:293 */ data.add("productVersion"); /* 271:294 */ data.add(this.applicationProperties.getBuildNumber()); /* 272: */ /* 273:296 */ data.add("gliffyVersion"); /* 274:297 */ data.add(this.product.getVersion()); /* 275: */ /* 276:299 */ data.add("serverId"); /* 277:300 */ data.add(this.atlassianProductLicense.getServerId()); /* 278: */ /* 279:302 */ data.add("licenseType"); /* 280:303 */ data.add(this.atlassianProductLicense.getLicenseType().name()); /* 281: */ /* 282:305 */ data.add("licenseSize"); /* 283:306 */ data.add(String.valueOf(this.atlassianProductLicense.getMaximumNumberOfUsers())); /* 284: */ /* 285:308 */ data.add("isEvaluation"); /* 286:309 */ data.add(Boolean.toString(this.atlassianProductLicense.isEvaluation())); /* 287: */ /* 288:311 */ data.add("licenseEvent"); /* 289:312 */ data.add(licenseEvent.toString()); /* 290: */ /* 291:314 */ data.add("instanceServerId"); /* 292:315 */ data.add(this.product.getServerId()); /* 293:317 */ if (this.license != null) /* 294: */ { /* 295:318 */ data.add("customerId"); /* 296:319 */ data.add(this.license.getCustomerId()); /* 297: */ } /* 298:322 */ data.add("organization"); /* 299:323 */ data.add(this.atlassianProductLicense.getOrganisation().getName()); /* 300: */ /* 301:325 */ data.add("creationDate"); /* 302:326 */ data.add(DATE_FORMAT.format(this.atlassianProductLicense.getCreationDate())); /* 303: */ /* 304:328 */ Locale locale = Locale.getDefault(); /* 305:329 */ data.add("locale"); /* 306:330 */ data.add(locale.toString()); /* 307: */ /* 308:332 */ Collection<Contact> contacts = this.atlassianProductLicense.getContacts(); /* 309:333 */ for (Contact contact : contacts) /* 310: */ { /* 311:334 */ data.add("customerName[]"); /* 312:335 */ data.add(contact.getName()); /* 313:336 */ data.add("customerEmail[]"); /* 314:337 */ data.add(contact.getEmail()); /* 315: */ } /* 316:340 */ Map<String, String> productCallbackValues = this.product.getCallbackValues(); /* 317:341 */ for (Map.Entry<String, String> productCallbackEntry : productCallbackValues.entrySet()) /* 318: */ { /* 319:342 */ data.add(productCallbackEntry.getKey()); /* 320:343 */ data.add(productCallbackEntry.getValue()); /* 321: */ } /* 322:346 */ sendRequest(data); /* 323: */ } /* 324: */ /* 325: */ private void sendRequest(List<String> data) /* 326: */ { ///* 327: */ try ///* 328: */ { /* 329:351 */ logger.debug("Trial license ping - START"); ///* 330: */ ///* 331:353 */ Request<?> request = this.requestFactory.createRequest(Request.MethodType.POST, "https://www.gliffy.com/_postback/"); ///* 332:354 */ request.addRequestParameters((String[])data.toArray(new String[data.size()])); ///* 333: */ ///* 334:356 */ request.execute(new ResponseHandler() ///* 335: */ { ///* 336: */ public void handle(Response response) ///* 337: */ throws ResponseException ///* 338: */ { /* 339:359 */ PluginLicenseManager.logger.debug("Trial license ping - RESPONSE={}",200); ///* 340: */ } ///* 341: */ }); ///* 342: */ } ///* 343: */ catch (Exception e) ///* 344: */ { ///* 345:364 */ logger.debug("Trial license ping - ERROR", e); ///* 346: */ } /* 347: */ } /* 348: */ /* 349: */ private class EncodedLicenseReader /* 350: */ implements LicenseGenerator /* 351: */ { /* 352: */ private EncodedLicenseReader() {} /* 353: */ /* 354: */ public License getLicense() /* 355: */ { /* 356:372 */ PluginSettings pluginSettings = PluginLicenseManager.this.pluginSettingsFactory.createGlobalSettings(); /* 357:373 */ String licenseString = (String)pluginSettings.get("com.gliffy.license.key"); /* 358:374 */ return License.parse(licenseString); /* 359: */ } /* 360: */ } /* 361: */ /* 362: */ private class FreeLicenseGenerator /* 363: */ implements LicenseGenerator /* 364: */ { /* 365: */ private FreeLicenseGenerator() {} /* 366: */ /* 367: */ public License getLicense() /* 368: */ { ///* 369:384 */ PluginLicenseManager.logger.debug("Atlassian Product licenseType={}", PluginLicenseManager.this.atlassianProductLicense.getLicenseType()); ///* 370:386 */ switch (PluginLicenseManager.2.$SwitchMap$com$atlassian$extras$api$LicenseType[PluginLicenseManager.this.atlassianProductLicense.getLicenseType().ordinal()]) ///* 371: */ { ///* 372: */ case 1: ///* 373: */ case 4: ///* 374: */ case 5: ///* 375:390 */ PluginLicenseManager.logger.debug("Creating free license"); ///* 376:391 */ License license = new License(); ///* 377:392 */ license.setLicensedSystem(PluginLicenseManager.this.product.getProductName()); ///* 378:393 */ license.setLicenseType(map(PluginLicenseManager.this.atlassianProductLicense.getLicenseType())); ///* 379:394 */ license.setLicensedTo("Free License"); ///* 380:395 */ license.setLicenseKey(PluginLicenseManager.this.hashIt(license)); ///* 381: */ ///* 382:397 */ PluginLicenseManager.this.sendLicenseEvent(PluginLicenseManager.LicenseEvent.GENERATE_FREE_LICENSE); ///* 383: */ ///* 384:399 */ return license; ///* 385: */ } /* 386:401 */ return null; /* 387: */ } /* 388: */ /* 389: */ private License.Type map(LicenseType licenseType) /* 390: */ { /* 391:410 */ switch (licenseType.ordinal()) { /* 393: */ case 7: /* 394:411 */ return License.Type.ACADEMIC; /* 395: */ case 8: /* 396:412 */ return License.Type.COMMERCIAL; /* 397: */ case 1: /* 398:413 */ return License.Type.COMMUNITY; /* 399: */ case 2: /* 400:414 */ return License.Type.DEMONSTRATION; /* 401: */ case 3: /* 402:415 */ return License.Type.DEVELOPER; /* 403: */ case 4: /* 404:416 */ return License.Type.NON_PROFIT; /* 405: */ case 5: /* 406:417 */ return License.Type.OPEN_SOURCE; /* 407: */ case 6: /* 408:418 */ return License.Type.PERSONAL; /* 409: */ case 9: /* 410:419 */ return License.Type.STARTER; /* 411: */ case 10: /* 412:420 */ return License.Type.HOSTED; /* 413: */ case 11: /* 414:421 */ return License.Type.TESTING; /* 415: */ } /* 416:422 */ return null; /* 417: */ } /* 418: */ } /* 419: */ /* 420: */ private class HostedLicenseGenerator /* 421: */ implements LicenseGenerator /* 422: */ { /* 423: */ private HostedLicenseGenerator() {} /* 424: */ /* 425: */ public License getLicense() /* 426: */ { /* 427:434 */ String onDemandProperty = PluginLicenseManager.this.atlassianProductLicense.getProperty("ondemand"); /* 428:435 */ PluginLicenseManager.logger.debug("isHosted={}", onDemandProperty); /* 429: */ /* 430:437 */ boolean isHosted = Boolean.parseBoolean(onDemandProperty); /* 431:438 */ if (!isHosted) { /* 432:439 */ return null; /* 433: */ } /* 434:442 */ String gliffyProperty = PluginLicenseManager.this.atlassianProductLicense.getProperty(PluginLicenseManager.this.product.getHostedKey()); /* 435:443 */ boolean isActive = Boolean.parseBoolean(gliffyProperty); /* 436:444 */ PluginLicenseManager.logger.debug("key={} isActive={}", PluginLicenseManager.this.product.getHostedKey(), gliffyProperty); /* 437: */ /* 438:446 */ License license = new License(); /* 439:447 */ license.setLicensedSystem(PluginLicenseManager.this.product.getProductName()); /* 440:448 */ license.setLicenseType(License.Type.HOSTED); /* 441:449 */ license.setLicensedTo("Atlassian OnDemand"); /* 442:450 */ license.setExpirationDateObject(isActive ? null : new Date()); /* 443:451 */ license.setLicenseKey(PluginLicenseManager.this.hashIt(license)); /* 444: */ /* 445:453 */ return license; /* 446: */ } /* 447: */ } /* 448: */ /* 449: */ private class TrialLicenseGenerator /* 450: */ implements LicenseGenerator /* 451: */ { /* 452: */ private TrialLicenseGenerator() {} /* 453: */ /* 454: */ public License getLicense() /* 455: */ { /* 456:460 */ PluginLicenseManager.logger.debug("Generating Trial License"); /* 457: */ /* 458: */ /* 459:463 */ Calendar expirationDate = GregorianCalendar.getInstance(); /* 460:464 */ expirationDate.add(6, 100045); /* 461: */ /* 462:466 */ License license = new License(); /* 463:467 */ license.setLicensedSystem(PluginLicenseManager.this.product.getProductName()); /* 464:468 */ license.setLicenseType(License.Type.COMMERCIAL_ENTERPRISE); /* 465:469 */ license.setLicensedTo("guahao"); /* 466:470 */ license.setExpirationDateObject(expirationDate.getTime()); /* 467:471 */ license.setLicenseKey(PluginLicenseManager.this.hashIt(license)); /* 468: */ /* 469:473 */ PluginLicenseManager.this.sendLicenseEvent(PluginLicenseManager.LicenseEvent.INSTALL_LICENSE); /* 470: */ /* 471:475 */ return license; /* 472: */ } /* 473: */ } /* 474: */ } /* Location: E:\workspace_indigo\gliffy-confluence-plugin-5.1\META-INF\lib\gliffy-license-1.1.3.jar * Qualified Name: com.gliffy.core.license.PluginLicenseManager * JD-Core Version: 0.7.0.1 */