Coding the Challenge-Response Mechanism While Requesting a License

NOTE   A license containing secrets (character set: A-Z, a-z, and 0-9) must be loaded on the License Manager.

Declare Variables/Constants

String FEATURE_NAME = "Feature1";
String CONTACT_SERVER = "localhost";
String SECRET_KEY_INDEX = "1";
String CHALLENGE_DATA = "12xd78jh";

 
Attribute attrAppContext = null;
Attribute attrLogin = null ;
ApplicationContext appContext = null;
LoginSession session = null;

API Calls

To use the challenge-response mechanism while requesting 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);

>attrLogin = new Attribute();

>attrLogin.set(LicensingConstants. SNTL_ATTR_LOGIN_CHALLENGE_SECRET, SECRET_KEY_INDEX);

>attrLogin.set(LicensingConstants.SNTL_ATTR_LOGIN_CHALLENGE_DATA, CHALLENGE_DATA);

>session = new LoginSession();

>session.login(appContext, FEATURE_NAME, attrLogin);

>String sessioninfo = session.getSessionInfo(LicensingConstants.SNTL_SESSIONINFO);

If the session.getSessionInfo call is successful, the sessioninfo string contains an XML output having the detailed information.

NOTE   The SNTL_SESSIONINFO constant is defined in the LicensingConstants.java file.