The Remote PUMA SPI REST Service is implemented as a servlet that runs as a separate enterprise application on the WebSphere Portal Express server.
Operation | Description | Parameter(Method Name) |
/um/attributes/users | list of references to the attribute definitions that are available for users | expandRefs(GET) |
/um/attributes/users/attribute name | representation of the attribute definition | |
/um/attributes/groups | the list of references to the attribute definitions that are available for groups | expandRefs(GET) |
/um/attributes/groups/attribute name | a representation of the attribute definition | |
/um/currentuser/profile | profile of the current user. If this operation is performed without authentication, the profile of the anonymous user is returned. | Update(PUT OR POST) |
/um/users/profiles | the list of references to all user that correspond to the search criteria and other parameters. If there are no limiting parameters, all available users are returned. The list that is returned is access control filtered for the current user. | expandRefs(GET) includeAttributes(GET) memberOf(GET) showNested(GET) searchAttributes(GET) identifier(GET) resultsPerPage(GET) sortByAttributes(GET) descending(GET) |
/um/groups/profiles | the list of references to all groups that correspond to the search criteria and other parameters. If there are no limiting parameters, all available groups are returned. The list that is returned is access control filtered for the current user. | expandRefs(GET) includeAttributes(GET) memberOf(GET) showNested(GET) searchAttributes(GET) identifier(GET) resultsPerPage(GET) sortByAttributes(GET) descending(GET) |
/um/users/profiles/unique id of user | Returns a representation of a user profile. | update(PUT OR POST) |
/um/groups/profiles/unique id of group | Returns a representation of a group profile. | update(PUT OR POST) |
/um/groupmembership/unique id of user | Returns the list of references to all group profiles of the groups of which the user is a member. | expandRefs(GET) includeAttributes(GET) showNested(GET) update(PUT OR POST) |
/um/groupmembership/unique id of group | Returns the list of references to all group profiles of the groups of which the group is a member. | expandRefs(GET) includeAttributes(GET) showNested(GET) update(PUT OR POST) |
The portal Remote PUMA SPI REST Service allows requests to the following operations only for authenticated users by using the /um/secure path element:
- /um/attributes/users
- /um/attributes/users/attribute name
- /um/attributes/groups
- /um/attributes/groups/attribute name
Sample Code:
public class SampleTest {
public static void main(String[] args) {
try {
/**
/um/secure/users/profiles
/um/secure/attributes/groups
/um/secure/attributes/users/
**/
final String userName = "wasadmin";
final String password = "wasadmin";
HttpClient client = new HttpClient();
GetMethod get = new GetMethod ("http://localhost:10039/wps/mycontenthandler/!ut/p/um/secure/currentuser/profile");
Credentials defaultcreds = new UsernamePasswordCredentials(userName,password);
client.getState().setCredentials(null,null,defaultcreds);
get.setDoAuthentication(true);
// Open the URL: throws exception if not found
client.executeMethod(get);
InputStream inputStream = get.getResponseBodyAsStream();
System.out.println(convertStreamToString(inputStream));
} catch (MalformedURLException e) {
e.printStackTrace(System.out);
} catch (IOException e) {
e.printStackTrace(System.out);
}
}
public static String convertStreamToString(InputStream inputStream) throws IOException {
if (inputStream != null) {
StringBuilder sb = new StringBuilder();
String line;
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
while ((line = reader.readLine()) != null) {
sb.append(line).append("\n");
}
} finally {
inputStream.close();
}
return sb.toString();
} else {
return "";
}
}
}
public static void main(String[] args) {
try {
/**
/um/secure/users/profiles
/um/secure/attributes/groups
/um/secure/attributes/users/
**/
final String userName = "wasadmin";
final String password = "wasadmin";
HttpClient client = new HttpClient();
GetMethod get = new GetMethod ("http://localhost:10039/wps/mycontenthandler/!ut/p/um/secure/currentuser/profile");
Credentials defaultcreds = new UsernamePasswordCredentials(userName,password);
client.getState().setCredentials(null,null,defaultcreds);
get.setDoAuthentication(true);
// Open the URL: throws exception if not found
client.executeMethod(get);
InputStream inputStream = get.getResponseBodyAsStream();
System.out.println(convertStreamToString(inputStream));
} catch (MalformedURLException e) {
e.printStackTrace(System.out);
} catch (IOException e) {
e.printStackTrace(System.out);
}
}
public static String convertStreamToString(InputStream inputStream) throws IOException {
if (inputStream != null) {
StringBuilder sb = new StringBuilder();
String line;
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
while ((line = reader.readLine()) != null) {
sb.append(line).append("\n");
}
} finally {
inputStream.close();
}
return sb.toString();
} else {
return "";
}
}
}
In this example,i am able to get profile of "wasadmin".
Result XML
Click here to download the files