This article is showing how to set up a text file to be used as a Credential Store for discovery using JDK, which provides more details for product documentation below:
The article is based on working on the MID server host, where the JDK is installed.
Download the Java Development Kit
Download and install the JDK from Oracle website:
Install it in a folder of your choice.
Set Windows environment variable to the JAVA bin
We need to modify the "Path" Environment Variable , to point to the JAVA bin folder. In the 'Control Panel/System/Advanced system settings/Advanced/Environment Variable', open ''PATH", then append Value "C:\Program Files\Java\jdk1.8.0_161\bin" (or your path to the java bin folder) at the end.
We also need to set the path to our property file in an environmental variable on the MID server.
This is referred in the java file discussed below. If this is not set, the default path: DEFAULT_PROP_FILE_PATH is used.
Create the System Variable CREDENTIAL_RESOLVER_FILE with the value C:/Mid server/Credentials/dummycredentials.properties
Create the properties file for username/password storage
We are going to store the user credentials in a properties file. Open Notepad and create the property file (make sure Windows is not adding .txt at the end) in a folder of your choice.
In the samples we use
Add the content from this page (the part of the property file):
In the property file, add the account that you want to use for discovery.
Here we are adding a Windows user:
Add the user to the credential table in the instance (first part of the property entry is the credentials id):
Create the JAR file
We need to create the JAR file as mentioned in the product doc.
To do this we need to save the code from the doc in a .java file, compile it to a class file, then convert it to JAR file.
Doing this using Eclipse is easier. However when using JDK, we need to follow below steps carefully
Open Notepad, copy the content from this page (the part of the java file), paste in Notepad, and save the file as CredentialResolver.java
On the top of your java file, change the line with the path to your property file:
DEFAULT_PROP_FILE_PATH = "C:/Mid server/Credentials/dummycredentials.properties"
Now we need to compile the java to the class. Open the cmd prompt, change folder to c:\Mid server\Credentials and run the following command:
This will create a CredentialResolver.class in the same folder.
We need to put this class in com.snc.discovery, (as showing in the java file: package com.snc.discovery).
so now you need to create the following folder structure:
Copy the "CredentialResolver.class "into the "C:\Mid server\Credentials\com\snc\discovery"-folder.
Now we are going to create the JAR file named CredRes.jar (or the name of your choice).
Open the cmd prompt and change folder to c:\Mid server\Credentials and run the following command:
jar cvf CredRes.jar ".\com\snc\discovery\CredentialResolver.class"
You can check the content of your JAR-file by running the command:
Jar tf .\CredRes.jar
Confirm the path for the class file is: com/snc/discovery/CredentialResolver.class
Your folders should now look like this:
Upload the Jar file
Then we need to upload the Jar file to the ServiceNow instance. MID Server/JAR files and add a new entry and attach the CredRes.jar-file. Don't forget to restart the MID server after you upload a jar file!
You can verify that the CredRes.jar file ended up correctly in the extlib folder on the MID-server.
Test the credential
Go to the credential in the instance that you created earlier and run a 'Test Credential' against an IP where the user has permission.
Verify you get 'Credential Validated'.
Check MID Server agent log and wrapper log for debug information.