贴出qc9.0的注册码的判断的那个方法 大家写注册机吧
上一篇 / 下一篇 2007-08-19 20:23:12 / 个人分类:测试
查看( 2598 ) /
评论( 12 )
相关阅读:
- 2007年软件培训市场热点浅析 (isabelbi, 2007-8-07)
- 上传一个小测试程序 (higkoo, 2007-8-09)
- 测试 & 测试leader/测试经理的职责 (qicyt1812, 2007-8-14)
- 加油◎◎在测试的道路上奋勇前进!!! (swanlin128, 2007-8-14)
- 测试 & 测试设计者/测试者的职责 (qicyt1812, 2007-8-15)
- 详细分析—软件测试的14种类型 (hjjlearning, 2007-8-16)
- 有意思的测试! (lygkfj, 2007-8-17)
- 电子商务测试之重点:业务知识(转) (swanlin128, 2007-8-17)
TAG: 测试
- amirfly 发布于2007-08-18 15:10:48
-
package com.mercury.td.saserver.tools.license;
import com.mercury.optane.EnLicenseStatus;
import com.mercury.optane.EnLicenseType;
import com.mercury.optane.core.CTdException;
import com.mercury.optane.core.CTdGeneralFunctions;
import com.mercury.optane.core.crypto.license.CLicenseSigner;
import com.mercury.optane.core.frec.CFileRec;
import com.mercury.optane.core.frec.IFileRec;
import java.io.ByteArrayInputStream;
import java.util.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
public class CLicenseEngine
{
static interface ILicenseConsts
{
public static final String UNLIMITED = "unlimited";
public static final String TERMS = "terms";
public static final String ISSUED_TO = "issued_to";
public static final String LICENSE_IDENTIFIER = "license_identifier";
public static final String EVALUATION = "evaluation";
public static final String EXPIRATION = "expiration";
public static final String START_DATE = "start_date";
public static final String FULL_TEST_DIRECTOR = "full_test_director";
public static final String ADDITIONAL_DEFECTS = "additional_defects";
public static final String TOLERANCE = "tolerance";
public static final String REQUIREMENTS = "requirements";
public static final String ADVANCED_REPORTS = "advanced_reports";
public static final String VERSION_C;
public static final String BUSINESS_PROCESS_TESTING = "business_process_testing";
public static final String DASHBOARD = "dashboard";
}
private String m_license;
private boolean m_LicenseIsValid;
private String m_expiration;
private String m_edition;
private int m_date;
private int m_month;
private int m_year;
private GregorianCalendar m_expirationTime;
private float m_tolerance;
private int m_defects;
private int m_reqs;
private int m_tests;
private int m_components;
private boolean m_dashboard;
private boolean m_advanced_reports;
private boolean m_version_control;
private String m_startdate;
private GregorianCalendar m_startTime;
public CLicenseEngine()
{
m_license = null;
m_LicenseIsValid = false;
m_expiration = "01/01/1970";
m_date = 1;
m_month = 1;
m_year = 1970;
m_expirationTime = null;
m_tolerance = 0.0F;
m_defects = 1;
m_reqs = 1;
m_tests = 1;
m_components = 1;
m_dashboard = false;
m_advanced_reports = false;
m_version_control = false;
m_startdate = null;
m_startTime = null;
}
public void init(String license)
{
m_license = license;
m_LicenseIsValid = CLicenseSigner.checkLicense(license);
if(!m_LicenseIsValid)
{
throw new CTdException("Invalid license key");
} else
{
decrypt();
return;
}
}
private void decrypt()
{
Document doc = null;
try
{
SAXBuilder builder = new SAXBuilder();
doc = builder.build(new ByteArrayInputStream(m_license.getBytes()));
Element termsEl = doc.getRootElement().getChild("terms");
String vc = termsEl.getChildText("version_control");
m_version_control = CTdGeneralFunctions.strToBoolean(vc);
String reports = termsEl.getChildText("advanced_reports");
m_advanced_reports = CTdGeneralFunctions.strToBoolean(reports);
String defects = termsEl.getChildText("full_test_director");
if(defects.equalsIgnoreCase("unlimited"))
{
m_defects = EnLicenseStatus.UNLIMITED.asInt();
m_reqs = EnLicenseStatus.UNLIMITED.asInt();
m_tests = EnLicenseStatus.UNLIMITED.asInt();
} else
{
m_defects = Integer.parseInt(defects);
m_reqs = m_defects;
m_tests = m_defects;
defects = termsEl.getChildText("additional_defects");
if(defects.equalsIgnoreCase("unlimited"))
{
m_defects = EnLicenseStatus.UNLIMITED.asInt();
} else
{
m_defects += Integer.parseInt(defects);
}
}
String tolerance = termsEl.getChildText("tolerance");
tolerance = tolerance.substring(0, tolerance.indexOf("%"));
m_tolerance = 1.0F + Float.parseFloat(tolerance) / 100F;
m_expiration = termsEl.getChildText("expiration");
m_edition = termsEl.getChildText("edition");
if(m_edition == null)
{
m_edition = "enterprise";
}
Element startEl = termsEl.getChild("start_date");
if(startEl != null)
{
m_startdate = startEl.getText();
}
String sDashboard = termsEl.getChildText("dashboard");
if(sDashboard == null || sDashboard.length() == 0)
{
m_dashboard = false;
} else
{
m_dashboard = CTdGeneralFunctions.strToBoolean(sDashboard);
}
String sComponents = termsEl.getChildText("business_process_testing");
if(sComponents == null || sComponents.length() == 0)
{
m_components = 0;
} else
if(sComponents.equalsIgnoreCase("unlimited"))
{
m_components = EnLicenseStatus.UNLIMITED.asInt();
} else
{
m_components = Integer.parseInt(sComponents);
}
}
catch(Exception e)
{
throw new CTdException("Unable to load data from license data", e);
}
buildExpiration();
}
- amirfly 发布于2007-08-18 15:12:05
-
private void buildExpiration()
{
if(m_expiration.equalsIgnoreCase("unlimited"))
{
return;
}
StringTokenizer st = new StringTokenizer(m_expiration, "/");
m_month = Integer.parseInt(st.nextToken());
m_date = Integer.parseInt(st.nextToken());
m_year = Integer.parseInt(st.nextToken());
m_expirationTime = new GregorianCalendar(m_year, m_month - 1, m_date, 23, 59, 59);
if(m_startdate != null)
{
st = new StringTokenizer(m_startdate, "/");
int month = Integer.parseInt(st.nextToken());
int date = Integer.parseInt(st.nextToken());
int year = Integer.parseInt(st.nextToken());
m_startTime = new GregorianCalendar(year, month - 1, date, 0, 0, 1);
}
}
public boolean isExpired()
{
if(m_expiration.equalsIgnoreCase("unlimited"))
{
return false;
}
GregorianCalendar now = new GregorianCalendar();
if(now.after(m_expirationTime))
{
return true;
}
if(m_startTime != null)
{
return m_startTime.after(now);
} else
{
return false;
}
}
public String getEdition()
{
return m_edition;
}
private int getMaxAllocations(EnLicenseType licType)
{
int licTypeValue = licType.asInt();
switch(licTypeValue)
{
case 1: // '\001'
return m_defects;
case 2: // '\002'
return m_tests;
case 3: // '\003'
return m_reqs;
case 13: // '\r'
return m_components;
}
throw new CTdException("Max allocation for license type '" + licType.getName() + "' could not be retieved");
}
public boolean isLicenseTypeEnabled(EnLicenseType licType)
{
if(isExpired())
{
return false;
}
switch(licType.asInt())
{
case 1: // '\001'
case 2: // '\002'
case 3: // '\003'
case 13: // '\r'
int maxLicenseAllocations = 0;
try
{
maxLicenseAllocations = getMaxAllocations(licType);
}
catch(CTdException e)
{
return false;
}
if(maxLicenseAllocations == EnLicenseStatus.UNLIMITED.asInt())
{
return true;
}
return maxLicenseAllocations > 0;
case 12: // '\f'
return m_dashboard;
case 10: // '\n'
return m_advanced_reports;
case 9: // '\t'
return m_version_control;
case 4: // '\004'
case 5: // '\005'
case 6: // '\006'
case 7: // '\007'
case 8: // '\b'
case 11: // '\013'
default:
return false;
}
}
public EnLicenseStatus canAllocateLicense(EnLicenseType licType, int currentLicenseUsage)
{
if(isExpired())
{
return EnLicenseStatus.KEY_EXPIRED;
}
switch(licType.asInt())
{
case 1: // '\001'
case 2: // '\002'
case 3: // '\003'
case 13: // '\r'
int maxLicenseAllocations = 0;
try
{
maxLicenseAllocations = getMaxAllocations(licType);
}
catch(CTdException e)
{
return EnLicenseStatus.DENIED;
}
if(maxLicenseAllocations == EnLicenseStatus.UNLIMITED.asInt())
{
return EnLicenseStatus.APPROVED;
}
if(currentLicenseUsage >= (int)((float)maxLicenseAllocations * m_tolerance))
{
return EnLicenseStatus.DENIED;
}
if(currentLicenseUsage >= maxLicenseAllocations)
{
return EnLicenseStatus.OVERFLOW_ALERT;
} else
{
return EnLicenseStatus.APPROVED;
}
case 12: // '\f'
return m_dashboard ? EnLicenseStatus.APPROVED : EnLicenseStatus.DENIED;
case 4: // '\004'
case 5: // '\005'
case 6: // '\006'
case 7: // '\007'
case 8: // '\b'
case 9: // '\t'
case 10: // '\n'
case 11: // '\013'
default:
return EnLicenseStatus.DENIED;
}
}
public IFileRec getLicenseStatus(Map used)
{
StringBuffer expTime = null;
expTime = new StringBuffer();
IFileRec resultFrec = new CFileRec();
if(m_expiration.equalsIgnoreCase("Unlimited"))
{
expTime.append("Unlimited");
} else
{
expTime.append(m_month).append("/").append(m_date).append("/").append(m_year);
long daysToExpiration = (m_expirationTime.getTime().getTime() - System.currentTimeMillis()) / 0x5265c00L;
resultFrec.addItem("DaysToExpiration", daysToExpiration);
}
resultFrec.addItem("ExpirationDate", expTime.toString());
int usedLicenses = 0;
if(used.containsKey(EnLicenseType.BUG))
{
usedLicenses = ((Integer)used.get(EnLicenseType.BUG)).intValue();
} else
{
usedLicenses = 0;
}
saveLicStatus(EnLicenseType.BUG.getName(), EnLicenseType.BUG.getStatusCaption(), EnLicenseType.BUG, usedLicenses, resultFrec);
if(used.containsKey(EnLicenseType.LAB))
{
usedLicenses = ((Integer)used.get(EnLicenseType.LAB)).intValue();
} else
{
usedLicenses = 0;
}
saveLicStatus(EnLicenseType.LAB.getName(), EnLicenseType.LAB.getStatusCaption(), EnLicenseType.LAB, usedLicenses, resultFrec);
if(used.containsKey(EnLicenseType.REQUIREMENT))
{
usedLicenses = ((Integer)used.get(EnLicenseType.REQUIREMENT)).intValue();
} else
{
usedLicenses = 0;
}
saveLicStatus(EnLicenseType.REQUIREMENT.getName(), EnLicenseType.REQUIREMENT.getStatusCaption(), EnLicenseType.REQUIREMENT, usedLicenses, resultFrec);
if(used.containsKey(EnLicenseType.COMPONENTS))
{
usedLicenses = ((Integer)used.get(EnLicenseType.COMPONENTS)).intValue();
} else
{
usedLicenses = 0;
}
saveLicStatus(EnLicenseType.COMPONENTS.getName(), EnLicenseType.COMPONENTS.getStatusCaption(), EnLicenseType.COMPONENTS, usedLicenses, resultFrec);
resultFrec.addItem("Tolerance", Math.round((m_tolerance - 1.0F) * 100F));
resultFrec.addItem(EnLicenseType.VC.getStatusCaption(), CTdGeneralFunctions.booleanToStr(m_version_control));
resultFrec.addItem(EnLicenseType.ADVANCEDREPORTS.getStatusCaption(), CTdGeneralFunctions.booleanToStr(m_advanced_reports));
resultFrec.addItem(EnLicenseType.DASHBOARD.getStatusCaption(), CTdGeneralFunctions.booleanToStr(m_dashboard));
return resultFrec;
}
private void saveLicStatus(String name, String caption, EnLicenseType licType, int used, IFileRec outFrec)
{
IFileRec licStat = null;
licStat = new CFileRec();
licStat.addItem("inuse", used);
licStat.addItem("max", getMaxAllocations(licType));
licStat.addItem("name", caption);
outFrec.addItem(name, licStat.toString());
}
}
- 梦想流浪发布于2007-08-19 12:58:22
-
public void init(String license)
{
m_license = license;
m_LicenseIsValid = CLicenseSigner.checkLicense(license);
if(!m_LicenseIsValid)
{
throw new CTdException("Invalid license key");
} else
{
decrypt();
return;
}
}
- 梦想流浪发布于2007-08-19 12:59:17
-
public void init(String license)
{
m_license = license;
m_LicenseIsValid = CLicenseSigner.checkLicense(license);
if(!m_LicenseIsValid)
{
throw new CTdException("Invalid license key");
} else
{
decrypt();
return;
}
}
修改成
- 梦想流浪发布于2007-08-19 13:00:02
-
public void init(String license)
{
m_license = license;
m_LicenseIsValid = CLicenseSigner.checkLicense(license);
if(!m_LicenseIsValid)
{
throw new CTdException("Invalid license key");
} else
{
decrypt();
return;
}
}
修改成
public void init(String license)
{
m_license = license;
m_LicenseIsValid = CLicenseSigner.checkLicense(license);
if(!m_LicenseIsValid)
{
decrypt();
return; } else
{
decrypt();
return;
}
}
- amirfly 发布于2007-08-19 20:26:06
-
呵呵 下面还有校验的 不只是这一段 不知道大家看了没有
- cooltianhai 发布于2007-09-03 12:00:59
-
哇!
- juneyg 发布于2007-09-03 13:28:26
-
牛人啊
- 423799223发布于2007-09-03 14:24:10
-
确实较牛
会破解
唉
太强啦
- jxaa133720发布于2007-09-06 21:57:25
-
其实MERCURY的产品bug挺多的。。。
QC9.0的patch不是特别需要最好别打,打到patch16之后,bug修改历史记录居然没有了,什么玩意。。。
- bill_hen发布于2007-09-07 06:02:08
-
Decompile and post the result publicly is very likely illegal ..........
-----------------------------------
For bug tracking, use BUGZERO, fully supported.
http://www.websina.com/bugzero/
- RNB发布于2007-09-12 17:32:01
-
顶起,那些saproxy.jar等文件在停止QC服务时会被自动删除,启动后又会自动生成,不知道反编译修改后再编译的方法是否可行?