How to extract license information from an arbitrary archive


This can be achieved either through the Archive Search in the UI or through the Archive Entry Search REST call.

If you would like to retrieve the license information itself, you can create a script that will parse the returned result/s of the ‘Archive Entry Search’ REST call and use it in the Archive Entry Download REST call.

So, for example, let’s say you have an archive, ‘commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar’ in the ‘libs-release-local’ repository, which contains a ‘LICENSE’ file, you can run this query:

curl -u{user:password} “http://localhost:8081/artifactory/api/search/archive?name=LICENSE&repos=libs-rlease-local

The returned result will look something like this:

{

“results” : [ {

“entry” : “META-INF/LICENSE”,

“archiveUris” : [ “http://localhost:8081/artifactory/api/storage/libs-release-local/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar” ]

} ]

}

Now, after parsing this result, your next query should look like this:

curl -u{user}:{password} “http://localhost:8081/artifactory/libs-release-local/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar%21/META-INF/LICENSE”

This query will return the archived ‘LICENSE’ file.

Please note the ‘%21’ which is a URL encoding of ‘!’.

In addition to the above, please take a look at the attached images (1_searchLicense.png, 2_addLicense.png ,3_licenseProperties.png). These images show how to search for a license through the UI, add it as a property, and how this property looks like for the purpose of Property Search.

That being said, you may take a look at this wiki page for more information on License Control with Artifactory.