Finding the Expiration Date of a License

Declare Variables/Constants

Attribute attrIdentity;
		Identity identity = null;
		String identityLogin = null;
		String customer = "NamedCustomer";
		String user = "user_1";
		String featureName = "f1";
		String featureVersion = "SampleFeatVer";

		Attribute attrGetinfo = null;
		
			attrGetinfo = new Attribute();
			lsapiInstance = new ApplicationContext(null);
		
		String getInfoResponse = null;

		
			// Set identity attributes
			attrIdentity = new Attribute();
			attrIdentity.set(LicensingConstants.SNTL_ATTR_IDENTITY_CUSTOMER_ID, customer);
			attrIdentity.set(LicensingConstants.SNTL_ATTR_IDENTITY_USERNAME, user);
			identity = new Identity(null, attrIdentity);
			identityLogin = identity.serialize();

		String QueryFeatureInfo = "<sentinelQuery query=\"entitlementInfo\"/>";
		String scopeFeatureInfo = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<sentinelScope>"
				+ "<identity>" + identityLogin + "</identity>" + "<feature index=\"0\">" + "<name>" + featureName
				+ "</name>" + "<version>" + featureVersion + "</version>" + "</feature>" + "</sentinelScope>")
						.toString();

		getInfoResponse = lsapiInstance.getInfo(attrGetinfo, scopeFeatureInfo, QueryFeatureInfo);
		System.out.println("\n\nXML returned by getInfo: :\n\n" + getInfoResponse);

API Calls

To know the expiration data of a license, execute the APIs in the specified sequential order only:

>attrAppContext = new Attribute();

>attrAppContext.set(LicensingConstants.SNTL_ATTR_APPCONTEXT_CONTACT_SERVER, CONTACT_SERVER);

NOTE   If, instead the LSFORCEHOST or LSHOST environment variables are set, then the above-mentioned steps are not required.

> appContext = new ApplicationContext(attrAppContext);

>String featureInfo = appContext.getInfo(ScopeFeatureInfo, LicensingConstants. SNTL_QUERY_FEATURE_INFO_VERSION("1.0"));

On success, featureInfo contains an XML output having the detailed information. Parse the XML, the “deathTime” tag in this XML contains the epoch timestamp for the license expiration.

NOTE   Refer to the sntl_demo.java sample of the Unified API (in the Sentinel RMS SDK installation) for a specific API function, its parameters, and usage.