All requests to the Prime Infrastructure API require user authentication. If no authentication details are provided in the request, the request is re-directed to the login page. Authentication details may be passed through the HTTP header of the request. Note that all access to the API are enforced over https and that users must be part of the admin group to access the Prime Infrastructure API.
The API uses basic authentication. The user name is appended with a colon and concatenated with the password and encoded with the Base64 algorithm.
For example, given the user name 'Aladdin' and password 'open sesame', the string 'Aladdin:open sesame' is Base64 encoded, resulting in 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='.
The Authorization HTTP header is use to pass the value:
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
... // encode user name and password String authHeader = org.apache.commons.codec.binary.Base64.encodeBase64String( (username + ":" + password).getBytes() ); // pass encoded user name and password as header URL url = new URL (urlString); URLConnection conn = url.openConnection(); conn.setRequestProperty ("Authorization", "Basic " + authHeader); ...