summaryrefslogtreecommitdiffstats
path: root/base/common/src/com/netscape/certsrv/user
diff options
context:
space:
mode:
authorAde Lee <alee@redhat.com>2013-08-21 11:39:03 -0400
committerAde Lee <alee@redhat.com>2013-08-21 15:39:46 -0400
commit7f829d6ea87537a689edd0546eae25f4e13f558c (patch)
tree2ab11d8460800aca67aeef5e77a8ef0c85447c1e /base/common/src/com/netscape/certsrv/user
parent6d99354ce9e2f1250538eb31a8b7e2e788518892 (diff)
downloadpki-7f829d6ea87537a689edd0546eae25f4e13f558c.tar.gz
pki-7f829d6ea87537a689edd0546eae25f4e13f558c.tar.xz
pki-7f829d6ea87537a689edd0546eae25f4e13f558c.zip
Add TPS profile ID auxilliary object to tps users
Diffstat (limited to 'base/common/src/com/netscape/certsrv/user')
-rw-r--r--base/common/src/com/netscape/certsrv/user/UserData.java62
-rw-r--r--base/common/src/com/netscape/certsrv/user/UserResource.java3
2 files changed, 65 insertions, 0 deletions
diff --git a/base/common/src/com/netscape/certsrv/user/UserData.java b/base/common/src/com/netscape/certsrv/user/UserData.java
index b62d02231..da771f2e7 100644
--- a/base/common/src/com/netscape/certsrv/user/UserData.java
+++ b/base/common/src/com/netscape/certsrv/user/UserData.java
@@ -20,6 +20,10 @@ package com.netscape.certsrv.user;
import java.io.StringReader;
import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import javax.ws.rs.FormParam;
import javax.xml.bind.JAXBContext;
@@ -28,6 +32,9 @@ import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlValue;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.jboss.resteasy.plugins.providers.atom.Link;
@@ -62,6 +69,18 @@ public class UserData {
Link link;
+ @XmlElement(name="Attributes")
+ @XmlJavaTypeAdapter(MapAdapter.class)
+ Map<String, String> attributes = new LinkedHashMap<String, String>();
+
+ public String getAttribute(String name) {
+ return attributes.get(name);
+ }
+
+ public void setAttribute(String name, String value) {
+ attributes.put(name, value);
+ }
+
@XmlAttribute(name="id")
public String getID() {
return id;
@@ -144,6 +163,7 @@ public class UserData {
public int hashCode() {
final int prime = 31;
int result = 1;
+ result = prime * result + ((attributes == null) ? 0 : attributes.hashCode());
result = prime * result + ((email == null) ? 0 : email.hashCode());
result = prime * result + ((fullName == null) ? 0 : fullName.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
@@ -163,6 +183,11 @@ public class UserData {
if (getClass() != obj.getClass())
return false;
UserData other = (UserData) obj;
+ if (attributes == null) {
+ if (other.attributes != null)
+ return false;
+ } else if (!attributes.equals(other.attributes))
+ return false;
if (email == null) {
if (other.email != null)
return false;
@@ -220,6 +245,43 @@ public class UserData {
}
}
+ public static class MapAdapter extends XmlAdapter<AttributeList, Map<String, String>> {
+
+ public AttributeList marshal(Map<String, String> map) {
+ AttributeList list = new AttributeList();
+ for (Map.Entry<String, String> entry : map.entrySet()) {
+ Attribute attribute = new Attribute();
+ attribute.name = entry.getKey();
+ attribute.value = entry.getValue();
+ list.attributes.add(attribute);
+ }
+ return list;
+ }
+
+ public Map<String, String> unmarshal(AttributeList list) {
+ Map<String, String> map = new LinkedHashMap<String, String>();
+ for (Attribute attribute : list.attributes) {
+ map.put(attribute.name, attribute.value);
+ }
+ return map;
+ }
+ }
+
+ public static class AttributeList {
+ @XmlElement(name="Attribute")
+ public List<Attribute> attributes = new ArrayList<Attribute>();
+ }
+
+ public static class Attribute {
+
+ @XmlAttribute
+ public String name;
+
+ @XmlValue
+ public String value;
+ }
+
+
public static void main(String args[]) throws Exception {
UserData before = new UserData();
diff --git a/base/common/src/com/netscape/certsrv/user/UserResource.java b/base/common/src/com/netscape/certsrv/user/UserResource.java
index 078992897..a0f5f1db5 100644
--- a/base/common/src/com/netscape/certsrv/user/UserResource.java
+++ b/base/common/src/com/netscape/certsrv/user/UserResource.java
@@ -42,6 +42,9 @@ import com.netscape.certsrv.authentication.AuthMethodMapping;
@AuthMethodMapping("admin")
public interface UserResource {
+ public static final String ATTR_TPS_PROFILES = "tpsProfiles";
+ public static final String ALL_PROFILES = "All Profiles";
+
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public UserCollection findUsers(