diff options
author | Ade Lee <alee@redhat.com> | 2013-05-14 15:57:52 -0400 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2013-07-22 11:03:02 -0400 |
commit | 9eb2c354b9e3a1d93f89ea951bb713cc684646ed (patch) | |
tree | 82587ac4e9982a63daf85d759a8f8eb11baae80b /base/common/src/com/netscape/certsrv/profile | |
parent | dbf97dfa2f163094b5ce0af299ec4bd902ed3488 (diff) | |
download | pki-9eb2c354b9e3a1d93f89ea951bb713cc684646ed.tar.gz pki-9eb2c354b9e3a1d93f89ea951bb713cc684646ed.tar.xz pki-9eb2c354b9e3a1d93f89ea951bb713cc684646ed.zip |
Add interfaces for managing profiles
This adds the initial framework for viewing and managing profiles.
Also adds CLI code for viewing/adding/deleting and editing profiles.
Diffstat (limited to 'base/common/src/com/netscape/certsrv/profile')
11 files changed, 587 insertions, 109 deletions
diff --git a/base/common/src/com/netscape/certsrv/profile/IPolicyDefault.java b/base/common/src/com/netscape/certsrv/profile/IPolicyDefault.java index e18534d66..2c1d6250e 100644 --- a/base/common/src/com/netscape/certsrv/profile/IPolicyDefault.java +++ b/base/common/src/com/netscape/certsrv/profile/IPolicyDefault.java @@ -133,4 +133,5 @@ public interface IPolicyDefault extends IConfigTemplate { */ public String getValue(String name, Locale locale, IRequest request) throws EPropertyException; + } diff --git a/base/common/src/com/netscape/certsrv/profile/IProfile.java b/base/common/src/com/netscape/certsrv/profile/IProfile.java index 9125b2f69..1a2b7aa68 100644 --- a/base/common/src/com/netscape/certsrv/profile/IProfile.java +++ b/base/common/src/com/netscape/certsrv/profile/IProfile.java @@ -120,6 +120,8 @@ public interface IProfile { */ public void setAuthenticatorId(String id); + public void setAuthzAcl(String id); + /** * Retrieves the associated authenticator instance. * @@ -266,6 +268,12 @@ public interface IProfile { public void deleteProfileInput(String inputId) throws EProfileException; /** + * Delete all profile inputs + * @throws EProfileException + */ + public void deleteAllProfileInputs() throws EProfileException; + + /** * Deletes output policy by id. * * @param outputId id of the output policy @@ -274,6 +282,12 @@ public interface IProfile { public void deleteProfileOutput(String outputId) throws EProfileException; /** + * Delete all profile inputs + * @exception EProfileException + */ + public void deleteAllProfileOutputs() throws EProfileException; + + /** * Creates a input policy. * * @param id input policy id @@ -309,6 +323,12 @@ public interface IProfile { throws EProfileException; /** + * Delete all profile policies + * @exception EProfileException + */ + public void deleteAllProfilePolicies() throws EProfileException; + + /** * Retrieves a policy. * * @param setId set id @@ -405,4 +425,8 @@ public interface IProfile { */ public void submit(IAuthToken token, IRequest request) throws EDeferException, EProfileException; + + public void setRenewal(boolean renewal); + + public void setXMLOutput(boolean xmlOutput); } diff --git a/base/common/src/com/netscape/certsrv/profile/PolicyConstraint.java b/base/common/src/com/netscape/certsrv/profile/PolicyConstraint.java index 8b43661a2..a0f4e9def 100644 --- a/base/common/src/com/netscape/certsrv/profile/PolicyConstraint.java +++ b/base/common/src/com/netscape/certsrv/profile/PolicyConstraint.java @@ -35,6 +35,9 @@ public class PolicyConstraint { @XmlElement(name="description") private String text; + @XmlElement + private String classId; + @XmlElement(name = "constraint") private List<PolicyConstraintValue> constraints = new ArrayList<PolicyConstraintValue>(); @@ -62,6 +65,14 @@ public class PolicyConstraint { this.text = text; } + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + public List<PolicyConstraintValue> getConstraints() { return constraints; } diff --git a/base/common/src/com/netscape/certsrv/profile/PolicyConstraintValue.java b/base/common/src/com/netscape/certsrv/profile/PolicyConstraintValue.java index 5241ad832..a16b4c59d 100644 --- a/base/common/src/com/netscape/certsrv/profile/PolicyConstraintValue.java +++ b/base/common/src/com/netscape/certsrv/profile/PolicyConstraintValue.java @@ -34,13 +34,17 @@ public class PolicyConstraintValue { @XmlElement private Descriptor descriptor; + @XmlElement + private String value; + public PolicyConstraintValue() { // required for jax-b } - public PolicyConstraintValue(String name, Descriptor descriptor) { + public PolicyConstraintValue(String name, Descriptor descriptor, String value) { this.name = name; this.descriptor = descriptor; + this.value = value; } public String getName() { @@ -58,4 +62,12 @@ public class PolicyConstraintValue { public void setDescriptor(Descriptor descriptor) { this.descriptor = descriptor; } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } } diff --git a/base/common/src/com/netscape/certsrv/profile/PolicyDefault.java b/base/common/src/com/netscape/certsrv/profile/PolicyDefault.java index 2b95cf5f0..f92242cc1 100644 --- a/base/common/src/com/netscape/certsrv/profile/PolicyDefault.java +++ b/base/common/src/com/netscape/certsrv/profile/PolicyDefault.java @@ -32,12 +32,18 @@ public class PolicyDefault { @XmlAttribute(name="id") private String name; + @XmlAttribute + private String classId; + @XmlElement(name="description") private String text; @XmlElement(name="policyAttribute") private List<ProfileAttribute> attributes = new ArrayList<ProfileAttribute>(); + @XmlElement(name = "params") + private List<ProfileParameter> params = new ArrayList<ProfileParameter>(); + public PolicyDefault() { // required for jaxb } @@ -62,6 +68,14 @@ public class PolicyDefault { this.text = text; } + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + public List<ProfileAttribute> getAttributes() { return attributes; } @@ -70,4 +84,12 @@ public class PolicyDefault { this.attributes = attributes; } + public List<ProfileParameter> getParams() { + return params; + } + + public void setParams(List<ProfileParameter> params) { + this.params = params; + } + } diff --git a/base/common/src/com/netscape/certsrv/profile/ProfileClient.java b/base/common/src/com/netscape/certsrv/profile/ProfileClient.java new file mode 100644 index 000000000..12b54cc60 --- /dev/null +++ b/base/common/src/com/netscape/certsrv/profile/ProfileClient.java @@ -0,0 +1,73 @@ +//--- BEGIN COPYRIGHT BLOCK --- +//This program is free software; you can redistribute it and/or modify +//it under the terms of the GNU General Public License as published by +//the Free Software Foundation; version 2 of the License. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU General Public License for more details. +// +//You should have received a copy of the GNU General Public License along +//with this program; if not, write to the Free Software Foundation, Inc., +//51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +//(C) 2012 Red Hat, Inc. +//All rights reserved. +//--- END COPYRIGHT BLOCK --- +package com.netscape.certsrv.profile; + +import java.net.URISyntaxException; + +import com.netscape.certsrv.client.ClientConfig; +import com.netscape.certsrv.client.PKIClient; + +/** + * @author Ade Lee + */ +public class ProfileClient { + public PKIClient client; + public ProfileResource profileClient; + + public ProfileClient(ClientConfig config) throws URISyntaxException { + this(new PKIClient(config)); + } + + public ProfileClient(PKIClient client) throws URISyntaxException { + this.client = client; + init(); + } + + public void init() throws URISyntaxException { + profileClient = client.createProxy(ProfileResource.class); + } + + public ProfileData retrieveProfile(String id) { + return profileClient.retrieveProfile(id); + } + + public ProfileDataInfos listProfiles() { + return profileClient.listProfiles(); + } + + public void enableProfile(String id) { + profileClient.modifyProfileState(id, "enable"); + } + + public void disableProfile(String id) { + profileClient.modifyProfileState(id, "disable"); + } + + public void createProfile(ProfileData data){ + profileClient.createProfile(data); + } + + public void modifyProfile(ProfileData data){ + profileClient.modifyProfile(data.getId(), data); + } + + public void deleteProfile(String id) { + profileClient.deleteProfile(id); + } + +} diff --git a/base/common/src/com/netscape/certsrv/profile/ProfileData.java b/base/common/src/com/netscape/certsrv/profile/ProfileData.java index 465981add..b1eca7887 100644 --- a/base/common/src/com/netscape/certsrv/profile/ProfileData.java +++ b/base/common/src/com/netscape/certsrv/profile/ProfileData.java @@ -22,13 +22,17 @@ package com.netscape.certsrv.profile; import java.util.ArrayList; -import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; +import java.util.Vector; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** * @author jmagne @@ -43,22 +47,79 @@ public class ProfileData { protected String id; @XmlElement + protected String classId; + + @XmlElement protected String name; @XmlElement protected String description; @XmlElement - protected boolean isEnabled; + protected boolean enabled; @XmlElement - protected boolean isVisible; + protected boolean visible; @XmlElement protected String enabledBy; - @XmlElement(name = "Input") - protected List<ProfileInput> inputs = new ArrayList<ProfileInput>(); + @XmlElement + protected String authenticatorId; + + @XmlElement + protected String authzAcl; + + @XmlElement + protected boolean renewal; + + @XmlElement + protected boolean xmlOutput; + + @XmlElement(name = "Inputs") + @XmlJavaTypeAdapter(InputAdapter.class) + protected Map<String, ProfileInput> inputs = new LinkedHashMap<String, ProfileInput>(); + + @XmlElement(name = "Outputs") + @XmlJavaTypeAdapter(OutputAdapter.class) + protected Map<String, ProfileOutput> outputs = new LinkedHashMap<String, ProfileOutput>(); + + @XmlElement(name = "PolicySets") + @XmlJavaTypeAdapter(PolicySetAdapter.class) + protected Map<String, List<ProfilePolicy>> policySets = new LinkedHashMap<String, List<ProfilePolicy>>(); + + + public String getAuthenticatorId() { + return authenticatorId; + } + + public void setAuthenticatorId(String authenticatorId) { + this.authenticatorId = authenticatorId; + } + + public String getAuthzAcl() { + return authzAcl; + } + + public void setAuthzAcl(String authzAcl) { + this.authzAcl = authzAcl; + } + + public boolean isRenewal() { + return renewal; + } + + public void setRenewal(boolean renewal) { + this.renewal = renewal; + } + + public boolean isXMLOutput() { + return xmlOutput; + } + + public void setXMLOutput(boolean isXMLOutput) { + this.xmlOutput = isXMLOutput; + } public void setName(String name) { this.name = name; @@ -76,20 +137,20 @@ public class ProfileData { return description; } - public void setIsEnabled(boolean isEnabled) { - this.isEnabled = isEnabled; + public void setEnabled(boolean enabled) { + this.enabled = enabled; } - public boolean getIsEnabled() { - return isEnabled; + public boolean isEnabled() { + return enabled; } - public void setIsVisible(boolean isVisible) { - this.isVisible = isVisible; + public void setVisible(boolean visible) { + this.visible = visible; } - public boolean getIsVisible() { - return isVisible; + public boolean isVisible() { + return visible; } public void setEnabledBy(String enabledBy) { @@ -108,40 +169,188 @@ public class ProfileData { return id; } - public ProfileInput addProfileInput(String name) { + public String getClassId() { + return classId; + } - ProfileInput oldInput = getProfileInput(name); + public void setClassId(String classId) { + this.classId = classId; + } - if (oldInput != null) - return oldInput; + public void addProfileInput(String id, ProfileInput input) { + inputs.put(id, input); + } - ProfileInput newInput = new ProfileInput(); - newInput.setInputId(name); + public ProfileInput getProfileInput(String id) { + return inputs.get(id); + } - inputs.add(newInput); + public Map<String, ProfileInput> getInputs() { + return inputs; + } - return newInput; + public void setInputs(Map<String, ProfileInput> inputs) { + this.inputs = inputs; } - public ProfileInput getProfileInput(String name) { + public Map<String, ProfileOutput> getOutputs() { + return outputs; + } - ProfileInput input = null; + public void setOutputs(Map<String, ProfileOutput> outputs) { + this.outputs = outputs; + } - Iterator<ProfileInput> it = inputs.iterator(); + public Map<String, List<ProfilePolicy>> getPolicySets() { + return policySets; + } - ProfileInput curInput = null; - while (it.hasNext()) { - curInput = it.next(); + public void setPolicySets(Map<String, List<ProfilePolicy>> policySets) { + this.policySets = policySets; + } + + public void addProfilePolicySet(String id, Vector<ProfilePolicy> policySet) { + this.policySets.put(id, policySet); + } + + public void addProfileOutput(String id, ProfileOutput output) { + outputs.put(id, output); + } - if (curInput != null && curInput.getInputId().equals(name)) - break; + public ProfileOutput getProfileOutput(String id) { + return outputs.get(id); + } + + public static class InputAdapter extends XmlAdapter<InputList, Map<String, ProfileInput>> { + + public InputList marshal(Map<String,ProfileInput> map) { + InputList list = new InputList(); + for (Map.Entry<String, ProfileInput> entry : map.entrySet()) { + Input input = new Input(); + input.name = entry.getKey(); + input.value = entry.getValue(); + list.inputs.add(input); + } + return list; } - return input; + public Map<String, ProfileInput> unmarshal(InputList list) { + Map<String, ProfileInput> map = new LinkedHashMap<String, ProfileInput>(); + for (Input input : list.inputs) { + map.put(input.name, input.value); + } + return map; + } } - public List<ProfileInput> getProfileInputsList() { - return inputs; + public static class InputList { + @XmlElement(name="input") + public List<Input> inputs = new ArrayList<Input>(); + } + + public static class Input { + + @XmlElement(name="id") + public String name; + + @XmlElement + public ProfileInput value; + } + + public static class OutputAdapter extends XmlAdapter<OutputList, Map<String, ProfileOutput>> { + + public OutputList marshal(Map<String,ProfileOutput> map) { + OutputList list = new OutputList(); + for (Map.Entry<String, ProfileOutput> entry : map.entrySet()) { + Output output = new Output(); + output.name = entry.getKey(); + output.value = entry.getValue(); + list.outputs.add(output); + } + return list; + } + + public Map<String, ProfileOutput> unmarshal(OutputList list) { + Map<String, ProfileOutput> map = new LinkedHashMap<String, ProfileOutput>(); + for (Output output : list.outputs) { + map.put(output.name, output.value); + } + return map; + } + } + + public static class OutputList { + @XmlElement(name="output") + public List<Output> outputs = new ArrayList<Output>(); + } + + public static class Output { + + @XmlElement(name="id") + public String name; + + @XmlElement + public ProfileOutput value; + } + + public static class PolicySetAdapter extends XmlAdapter<PolicySetList, Map<String, Vector<ProfilePolicy>>> { + + public PolicySetList marshal(Map<String,Vector<ProfilePolicy>> map) { + PolicySetList list = new PolicySetList(); + for (Map.Entry<String, Vector<ProfilePolicy>> entry : map.entrySet()) { + PolicySet pset = new PolicySet(); + pset.name = entry.getKey(); + pset.value = entry.getValue(); + list.psets.add(pset); + } + return list; + } + + public Map<String, Vector<ProfilePolicy>> unmarshal(PolicySetList list) { + Map<String, Vector<ProfilePolicy>> map = new LinkedHashMap<String, Vector<ProfilePolicy>>(); + for (PolicySet pset : list.psets) { + map.put(pset.name, pset.value); + } + return map; + } + } + + public static class PolicySetList { + @XmlElement(name="PolicySet") + public List<PolicySet> psets = new ArrayList<PolicySet>(); + } + + public static class PolicySet { + + @XmlElement(name="id") + public String name; + + @XmlElement + public Vector<ProfilePolicy> value; + } + + public static void main(String args[]) throws Exception { + Map<String, ProfileInput> inputs = new LinkedHashMap<String, ProfileInput>(); + //ProfileInput input = new ProfileInput(); + //input.setClassId(classId); + //input.setInputId(inputId); + //input.setName(name); + //input.setText(text); + + + ProfileData data = new ProfileData(); + data.setClassId("com.netscape.cms.profile.common.CAEnrollProfile"); + data.setDescription("This certificate profile is for enrolling user certificates."); + data.setEnabled(true); + data.setEnabledBy("admin"); + data.setId("caUserCertEnrollImpl"); + data.setInputs(inputs); + data.setName("Manual User Dual-Use Certificate Enrollment"); + //data.setOutputs(outputs); + //data.setPolicySets(policySets); + data.setRenewal(false); + data.setVisible(true); + data.setXMLOutput(false); } }
\ No newline at end of file diff --git a/base/common/src/com/netscape/certsrv/profile/ProfileInput.java b/base/common/src/com/netscape/certsrv/profile/ProfileInput.java index 64d2aafdb..3a3aefe4c 100644 --- a/base/common/src/com/netscape/certsrv/profile/ProfileInput.java +++ b/base/common/src/com/netscape/certsrv/profile/ProfileInput.java @@ -18,77 +18,104 @@ package com.netscape.certsrv.profile; import java.util.ArrayList; -import java.util.LinkedHashMap; +import java.util.Enumeration; import java.util.List; -import java.util.Map; +import java.util.Locale; -import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlValue; -import javax.xml.bind.annotation.adapters.XmlAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.netscape.certsrv.property.Descriptor; public class ProfileInput { + private String classId; + private String name; + private String text; + private List<ProfileAttribute> attrs = new ArrayList<ProfileAttribute>(); + private List<ProfileAttribute> configAttrs = new ArrayList<ProfileAttribute>(); + public ProfileInput() { // required for jaxb } + public ProfileInput(IProfileInput input, String classId, Locale locale) { + this.name = input.getName(locale); + this.classId = classId; + Enumeration<String> names = input.getValueNames(); + while (names.hasMoreElements()) { + String name = names.nextElement(); + addAttribute(new ProfileAttribute(name, null, + (Descriptor) input.getValueDescriptor(locale, name))); + } + } + @XmlElement - public String getInputId() { - return inputId; + public String getClassId() { + return classId; } - private String inputId; + @XmlElement + public String getName() { + return name; + } - @XmlJavaTypeAdapter(InputAttrsAdapter.class) - public Map<String, String> InputAttrs = new LinkedHashMap<String, String>(); + @XmlElement + public String getText() { + return text; + } - public void setInputAttr(String name, String value) { - InputAttrs.put(name, value); + public void setClassId(String classId) { + this.classId = classId; } - public void setInputId(String inputId) { - this.inputId = inputId; + public void setName(String name) { + this.name = name; } - public static class InputAttrsAdapter extends XmlAdapter<InputAttrList, Map<String, String>> { + public void setText(String text) { + this.text = text; + } - public InputAttrList marshal(Map<String, String> map) { - InputAttrList list = new InputAttrList(); - 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; - } + @XmlElement(name = "attribute") + public List<ProfileAttribute> getAttrs() { + return attrs; + } - public Map<String, String> unmarshal(InputAttrList list) { - Map<String, String> map = new LinkedHashMap<String, String>(); - for (Attribute attribute : list.attributes) { - map.put(attribute.name, attribute.value); - } - return map; - } + public void setAttrs(List<ProfileAttribute> attrs) { + this.attrs = attrs; + } + + public void addAttribute(ProfileAttribute attr) { + attrs.add(attr); } - public static class InputAttrList { - @XmlElement(name = "InputAttr") - public List<Attribute> attributes = new ArrayList<Attribute>(); + public void removeAttribute(ProfileAttribute attr) { + attrs.remove(attr); } - public static class Attribute { + public void clearAttributes() { + attrs.clear(); + } - @XmlAttribute - public String name; + @XmlElement(name = "config_attribute") + public List<ProfileAttribute> getConfigAttrs() { + return configAttrs; + } - @XmlValue - public String value; + public void setConfigAttrs(List<ProfileAttribute> configAttrs) { + this.configAttrs = configAttrs; } - public Map<String, String> getAttributes() { - return InputAttrs; + public void addConfigAttribute(ProfileAttribute configAttr) { + attrs.add(configAttr); } + + public void removeConfigAttribute(ProfileAttribute configAttr) { + attrs.remove(configAttr); + } + + public void clearConfigAttributes() { + configAttrs.clear(); + } + } diff --git a/base/common/src/com/netscape/certsrv/profile/ProfileOutput.java b/base/common/src/com/netscape/certsrv/profile/ProfileOutput.java index 2e25f619d..492fdb46a 100644 --- a/base/common/src/com/netscape/certsrv/profile/ProfileOutput.java +++ b/base/common/src/com/netscape/certsrv/profile/ProfileOutput.java @@ -18,39 +18,55 @@ package com.netscape.certsrv.profile; import java.util.ArrayList; +import java.util.Enumeration; import java.util.List; +import java.util.Locale; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import com.netscape.certsrv.property.Descriptor; + @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class ProfileOutput { - public ProfileOutput() { - // required for jaxb - } + @XmlElement + private String name; @XmlElement - private String outputId; + private String text; + + @XmlElement + private String classId; @XmlElement(name = "attributes") private List<ProfileAttribute> attrs = new ArrayList<ProfileAttribute>(); - @XmlElement - private String name; - @XmlElement - private String text; + public ProfileOutput() { + // required for jaxb + } - public String getOutputId() { - return outputId; + public ProfileOutput(IProfileOutput output, String classId, Locale locale) { + this.name = output.getName(locale); + this.classId = classId; + Enumeration<String> names = output.getValueNames(); + while (names.hasMoreElements()) { + String name = names.nextElement(); + addAttribute(new ProfileAttribute(name, null, + (Descriptor) output.getValueDescriptor(locale, name))); + } } - public void setOutputId(String OutputId) { - this.outputId = OutputId; + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; } public List<ProfileAttribute> getAttrs() { @@ -81,4 +97,12 @@ public class ProfileOutput { attrs.add(attr); } + public void removeAttribute(ProfileAttribute attr) { + attrs.remove(attr); + } + + public void clearAttributes() { + attrs.clear(); + } + } diff --git a/base/common/src/com/netscape/certsrv/profile/ProfileParameter.java b/base/common/src/com/netscape/certsrv/profile/ProfileParameter.java new file mode 100644 index 000000000..af7fa26f7 --- /dev/null +++ b/base/common/src/com/netscape/certsrv/profile/ProfileParameter.java @@ -0,0 +1,66 @@ +//--- BEGIN COPYRIGHT BLOCK --- +//This program is free software; you can redistribute it and/or modify +//it under the terms of the GNU General Public License as published by +//the Free Software Foundation; version 2 of the License. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU General Public License for more details. +// +//You should have received a copy of the GNU General Public License along +//with this program; if not, write to the Free Software Foundation, Inc., +//51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +//(C) 2012 Red Hat, Inc. +//All rights reserved. +//--- END COPYRIGHT BLOCK --- +package com.netscape.certsrv.profile; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +public class ProfileParameter { + + @XmlAttribute + private String name; + + @XmlElement + private String value; + + public ProfileParameter() { + // required for jax-b + } + + public ProfileParameter(String name, String value) { + this.name = name; + this.value = value; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Override + public String toString() { + return "ProfileParameter [name=" + name + ", value=" + value + "]"; + } + +}
\ No newline at end of file diff --git a/base/common/src/com/netscape/certsrv/profile/ProfileResource.java b/base/common/src/com/netscape/certsrv/profile/ProfileResource.java index 572e6eb88..317215afb 100644 --- a/base/common/src/com/netscape/certsrv/profile/ProfileResource.java +++ b/base/common/src/com/netscape/certsrv/profile/ProfileResource.java @@ -1,46 +1,55 @@ package com.netscape.certsrv.profile; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import com.netscape.certsrv.authentication.AuthMethodMapping; - -@Path("agent/profiles") -@AuthMethodMapping("agent") +@Path("") public interface ProfileResource { @GET - @Path("{id}") + @Path("profiles") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public ProfileData retrieveProfile(@PathParam("id") String id); + public ProfileDataInfos listProfiles(); @GET + @Path("profiles/{id}") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public ProfileDataInfos listProfiles(); - - /** - * Used to retrieve a key - * - * @param data - * @return - */ + public ProfileData retrieveProfile(@PathParam("id") String id); - /* @POST - @Path("retrieve") + @Path("admin/profiles") + @AuthMethodMapping("admin") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public ProfileData retrieveProfile(ProfileRetrievalRequestData request); + public void createProfile(ProfileData data); - // retrieval - used to test integration with a browser @POST - @Path("retrieve") + @Path("agent/profiles/{id}") + @AuthMethodMapping("agent") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - @Consumes({ MediaType.APPLICATION_FORM_URLENCODED }) - public ProfileData retrievProfile(MultivaluedMap<String, String> form); - */ + public void modifyProfileState(@PathParam("id") String id, @QueryParam("action") String action); + + @PUT + @Path("admin/profiles/{id}") + @AuthMethodMapping("admin") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public void modifyProfile(@PathParam("id") String id, ProfileData data); + + @DELETE + @Path("admin/profiles/{id}") + @AuthMethodMapping("admin") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public void deleteProfile(@PathParam("id") String id); + }
\ No newline at end of file |