summaryrefslogtreecommitdiffstats
path: root/base/common/src/com/netscape/cms/servlet/profile/model
diff options
context:
space:
mode:
Diffstat (limited to 'base/common/src/com/netscape/cms/servlet/profile/model')
-rw-r--r--base/common/src/com/netscape/cms/servlet/profile/model/PolicyConstraint.java73
-rw-r--r--base/common/src/com/netscape/cms/servlet/profile/model/PolicyConstraintFactory.java42
-rw-r--r--base/common/src/com/netscape/cms/servlet/profile/model/PolicyConstraintValue.java61
-rw-r--r--base/common/src/com/netscape/cms/servlet/profile/model/PolicyDefault.java73
-rw-r--r--base/common/src/com/netscape/cms/servlet/profile/model/PolicyDefaultFactory.java65
-rw-r--r--base/common/src/com/netscape/cms/servlet/profile/model/ProfileAttribute.java80
-rw-r--r--base/common/src/com/netscape/cms/servlet/profile/model/ProfileData.java1
-rw-r--r--base/common/src/com/netscape/cms/servlet/profile/model/ProfileDataInfo.java10
-rw-r--r--base/common/src/com/netscape/cms/servlet/profile/model/ProfileInput.java5
-rw-r--r--base/common/src/com/netscape/cms/servlet/profile/model/ProfileInputFactory.java40
-rw-r--r--base/common/src/com/netscape/cms/servlet/profile/model/ProfileOutput.java84
-rw-r--r--base/common/src/com/netscape/cms/servlet/profile/model/ProfileOutputFactory.java47
-rw-r--r--base/common/src/com/netscape/cms/servlet/profile/model/ProfilePolicy.java82
-rw-r--r--base/common/src/com/netscape/cms/servlet/profile/model/ProfilePolicySet.java50
14 files changed, 706 insertions, 7 deletions
diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/PolicyConstraint.java b/base/common/src/com/netscape/cms/servlet/profile/model/PolicyConstraint.java
new file mode 100644
index 000000000..588431a83
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/profile/model/PolicyConstraint.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.cms.servlet.profile.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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 PolicyConstraint {
+ @XmlAttribute(name="id")
+ private String name;
+
+ @XmlElement(name="description")
+ private String text;
+
+ @XmlElement(name = "constraint")
+ private List<PolicyConstraintValue> constraints = new ArrayList<PolicyConstraintValue>();
+
+ public PolicyConstraint() {
+ // required for jaxb
+ }
+
+ public void addConstraint(PolicyConstraintValue constraint) {
+ constraints.add(constraint);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public List<PolicyConstraintValue> getConstraints() {
+ return constraints;
+ }
+
+ public void setConstraints(List<PolicyConstraintValue> constraints) {
+ this.constraints = constraints;
+ }
+
+}
diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/PolicyConstraintFactory.java b/base/common/src/com/netscape/cms/servlet/profile/model/PolicyConstraintFactory.java
new file mode 100644
index 000000000..bd361a752
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/profile/model/PolicyConstraintFactory.java
@@ -0,0 +1,42 @@
+// --- 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.cms.servlet.profile.model;
+
+import java.util.Enumeration;
+import java.util.Locale;
+
+import com.netscape.certsrv.profile.IPolicyConstraint;
+import com.netscape.certsrv.property.Descriptor;
+
+public class PolicyConstraintFactory {
+
+ public static PolicyConstraint create(Locale locale, IPolicyConstraint cons) {
+ PolicyConstraint ret = new PolicyConstraint();
+ ret.setName(cons.getName(locale));
+ ret.setText(cons.getText(locale));
+
+ Enumeration<String> conNames = cons.getConfigNames();
+ while (conNames.hasMoreElements()) {
+ String conName = conNames.nextElement();
+ PolicyConstraintValue dataVal =
+ new PolicyConstraintValue(conName, (Descriptor) cons.getConfigDescriptor(locale, conName));
+ ret.addConstraint(dataVal);
+ }
+ return ret;
+ }
+}
diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/PolicyConstraintValue.java b/base/common/src/com/netscape/cms/servlet/profile/model/PolicyConstraintValue.java
new file mode 100644
index 000000000..7b60e7ea6
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/profile/model/PolicyConstraintValue.java
@@ -0,0 +1,61 @@
+// --- 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.cms.servlet.profile.model;
+
+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;
+
+import com.netscape.certsrv.property.Descriptor;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+public class PolicyConstraintValue {
+ @XmlAttribute(name="id")
+ private String name;
+
+ @XmlElement
+ private Descriptor descriptor;
+
+ public PolicyConstraintValue() {
+ // required for jax-b
+ }
+
+ public PolicyConstraintValue(String name, Descriptor descriptor) {
+ this.name = name;
+ this.descriptor = descriptor;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Descriptor getDescriptor() {
+ return descriptor;
+ }
+
+ public void setDescriptor(Descriptor descriptor) {
+ this.descriptor = descriptor;
+ }
+}
diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/PolicyDefault.java b/base/common/src/com/netscape/cms/servlet/profile/model/PolicyDefault.java
new file mode 100644
index 000000000..2c66fc9dc
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/profile/model/PolicyDefault.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.cms.servlet.profile.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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 PolicyDefault {
+ @XmlAttribute(name="id")
+ private String name;
+
+ @XmlElement(name="description")
+ private String text;
+
+ @XmlElement(name="policyAttribute")
+ private List<ProfileAttribute> attributes = new ArrayList<ProfileAttribute>();
+
+ public PolicyDefault() {
+ // required for jaxb
+ }
+
+ public void addAttribute(ProfileAttribute attr) {
+ attributes.add(attr);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public List<ProfileAttribute> getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(List<ProfileAttribute> attributes) {
+ this.attributes = attributes;
+ }
+
+}
diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/PolicyDefaultFactory.java b/base/common/src/com/netscape/cms/servlet/profile/model/PolicyDefaultFactory.java
new file mode 100644
index 000000000..6b9379f0b
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/profile/model/PolicyDefaultFactory.java
@@ -0,0 +1,65 @@
+// --- 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.cms.servlet.profile.model;
+
+import java.util.Enumeration;
+import java.util.Locale;
+
+import com.netscape.certsrv.base.IArgBlock;
+import com.netscape.certsrv.profile.IPolicyDefault;
+import com.netscape.certsrv.property.Descriptor;
+import com.netscape.certsrv.property.EPropertyException;
+import com.netscape.certsrv.request.IRequest;
+
+public class PolicyDefaultFactory {
+
+ public static PolicyDefault create(IRequest request, Locale locale, IPolicyDefault def) throws EPropertyException {
+ PolicyDefault ret = new PolicyDefault();
+ ret.setName(def.getName(locale));
+ ret.setText(def.getText(locale));
+
+ Enumeration<String> defNames = def.getValueNames();
+ while (defNames.hasMoreElements()) {
+ String defName = defNames.nextElement();
+ ProfileAttribute attr = new ProfileAttribute(
+ defName,
+ def.getValue(defName, locale, request),
+ (Descriptor) def.getValueDescriptor(locale, defName));
+ ret.addAttribute(attr);
+ }
+ return ret;
+ }
+
+ public static PolicyDefault create(IArgBlock params, Locale locale, IPolicyDefault def) throws EPropertyException {
+ PolicyDefault ret = new PolicyDefault();
+ ret.setName(def.getName(locale));
+ ret.setText(def.getText(locale));
+
+ Enumeration<String> defNames = def.getValueNames();
+ while (defNames.hasMoreElements()) {
+ String defName = defNames.nextElement();
+ ProfileAttribute attr = new ProfileAttribute(
+ defName,
+ params.getValueAsString(defName, ""),
+ (Descriptor) def.getValueDescriptor(locale, defName));
+ ret.addAttribute(attr);
+ }
+ return ret;
+ }
+
+}
diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/ProfileAttribute.java b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileAttribute.java
new file mode 100644
index 000000000..616c0695d
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileAttribute.java
@@ -0,0 +1,80 @@
+// --- 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.cms.servlet.profile.model;
+
+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;
+
+import com.netscape.certsrv.property.Descriptor;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ProfileAttribute {
+
+ @XmlAttribute
+ private String name;
+
+ @XmlElement
+ private String value;
+
+ @XmlElement
+ private Descriptor descriptor;
+
+ public ProfileAttribute() {
+ // required for jax-b
+ }
+
+ public ProfileAttribute(String name, String value, Descriptor descriptor) {
+ this.name = name;
+ this.value = value;
+ this.descriptor = descriptor;
+ }
+
+ 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;
+ }
+
+ public Descriptor getDescriptor() {
+ return descriptor;
+ }
+
+ public void setDescriptor(Descriptor descriptor) {
+ this.descriptor = descriptor;
+ }
+
+ @Override
+ public String toString() {
+ return "PolicyAttribute [name=" + name + ", value=" + value + ", descriptor=" + descriptor + "]";
+ }
+
+}
diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/ProfileData.java b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileData.java
index 22a59c470..7f7f26b29 100644
--- a/base/common/src/com/netscape/cms/servlet/profile/model/ProfileData.java
+++ b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileData.java
@@ -41,6 +41,7 @@ public class ProfileData {
@XmlElement
protected String id;
+
@XmlElement
protected String name;
diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/ProfileDataInfo.java b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileDataInfo.java
index 63f005b54..d5083c7a4 100644
--- a/base/common/src/com/netscape/cms/servlet/profile/model/ProfileDataInfo.java
+++ b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileDataInfo.java
@@ -1,5 +1,3 @@
-package com.netscape.cms.servlet.profile.model;
-
//--- 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
@@ -17,18 +15,16 @@ package com.netscape.cms.servlet.profile.model;
//(C) 2011 Red Hat, Inc.
//All rights reserved.
//--- END COPYRIGHT BLOCK ---
-/**
- *
- */
+package com.netscape.cms.servlet.profile.model;
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.XmlAccessorType;
/**
* @author alee
- *
+ *
*/
@XmlRootElement(name = "ProfileDataInfo")
@XmlAccessorType(XmlAccessType.FIELD)
diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/ProfileInput.java b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileInput.java
index a0aea9fd4..631a013cc 100644
--- a/base/common/src/com/netscape/cms/servlet/profile/model/ProfileInput.java
+++ b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileInput.java
@@ -30,12 +30,17 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
public class ProfileInput {
+ public ProfileInput() {
+ // required for jaxb
+ }
+
@XmlElement
public String getInputId() {
return inputId;
}
private String inputId;
+
@XmlJavaTypeAdapter(InputAttrsAdapter.class)
public Map<String, String> InputAttrs = new LinkedHashMap<String, String>();
diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/ProfileInputFactory.java b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileInputFactory.java
new file mode 100644
index 000000000..67d3e9a2c
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileInputFactory.java
@@ -0,0 +1,40 @@
+package com.netscape.cms.servlet.profile.model;
+
+import java.util.Enumeration;
+import java.util.Locale;
+
+import com.netscape.certsrv.base.IArgBlock;
+import com.netscape.certsrv.profile.EProfileException;
+import com.netscape.certsrv.profile.IProfileInput;
+import com.netscape.certsrv.request.IRequest;
+
+public class ProfileInputFactory {
+
+ public static ProfileInput create(IProfileInput input, IRequest request, Locale locale) throws EProfileException {
+ ProfileInput ret = new ProfileInput();
+ ret.setInputId(input.getName(locale));
+ Enumeration<String> names = input.getValueNames();
+ while (names.hasMoreElements()) {
+ String name = names.nextElement();
+ String value = input.getValue(name, locale, request);
+ if (value != null) {
+ ret.setInputAttr(name, value);
+ }
+ }
+ return ret;
+ }
+
+ public static ProfileInput create(IProfileInput input, IArgBlock params, Locale locale) throws EProfileException {
+ ProfileInput ret = new ProfileInput();
+ ret.setInputId(input.getName(locale));
+ Enumeration<String> names = input.getValueNames();
+ while (names.hasMoreElements()) {
+ String name = names.nextElement();
+ String value = params.getValueAsString(name, null);
+ if (value != null) {
+ ret.setInputAttr(name, value);
+ }
+ }
+ return ret;
+ }
+}
diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/ProfileOutput.java b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileOutput.java
new file mode 100644
index 000000000..f27db4101
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileOutput.java
@@ -0,0 +1,84 @@
+// --- 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) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.cms.servlet.profile.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ProfileOutput {
+
+ public ProfileOutput() {
+ // required for jaxb
+ }
+
+ @XmlElement
+ private String outputId;
+
+ @XmlElement(name = "attributes")
+ private List<ProfileAttribute> attrs = new ArrayList<ProfileAttribute>();
+
+ @XmlElement
+ private String name;
+
+ @XmlElement
+ private String text;
+
+ public String getOutputId() {
+ return outputId;
+ }
+
+ public void setOutputId(String OutputId) {
+ this.outputId = OutputId;
+ }
+
+ public List<ProfileAttribute> getAttrs() {
+ return attrs;
+ }
+
+ public void setAttrs(List<ProfileAttribute> attrs) {
+ this.attrs = attrs;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public void addAttribute(ProfileAttribute attr) {
+ attrs.add(attr);
+ }
+
+}
diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/ProfileOutputFactory.java b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileOutputFactory.java
new file mode 100644
index 000000000..93bbaa2c5
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileOutputFactory.java
@@ -0,0 +1,47 @@
+//--- 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.cms.servlet.profile.model;
+
+import java.util.Enumeration;
+import java.util.Locale;
+
+import com.netscape.certsrv.profile.EProfileException;
+import com.netscape.certsrv.profile.IProfileOutput;
+import com.netscape.certsrv.property.Descriptor;
+import com.netscape.certsrv.request.IRequest;
+
+public class ProfileOutputFactory {
+
+ public static ProfileOutput create(IProfileOutput output, IRequest request, Locale locale) throws EProfileException {
+ ProfileOutput ret = new ProfileOutput();
+ ret.setName(output.getName(locale));
+ ret.setText(output.getText(locale));
+
+ Enumeration<String> attrNames = output.getValueNames();
+ while (attrNames.hasMoreElements()) {
+ String attrName = attrNames.nextElement();
+ ProfileAttribute attr = new ProfileAttribute(
+ attrName,
+ output.getValue(attrName, locale, request),
+ (Descriptor) output.getValueDescriptor(locale, attrName));
+ ret.addAttribute(attr);
+ }
+ return ret;
+ }
+
+}
diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/ProfilePolicy.java b/base/common/src/com/netscape/cms/servlet/profile/model/ProfilePolicy.java
new file mode 100644
index 000000000..a24f93619
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/profile/model/ProfilePolicy.java
@@ -0,0 +1,82 @@
+//--- 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.cms.servlet.profile.model;
+
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+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 ProfilePolicy {
+ @XmlAttribute
+ private String id = null;
+
+ @XmlElement
+ private PolicyDefault def = null;
+
+ @XmlElement
+ private PolicyConstraint constraint = null;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public PolicyDefault getDef() {
+ return def;
+ }
+
+ public void setDef(PolicyDefault def) {
+ this.def = def;
+ }
+
+ public PolicyConstraint getConstraint() {
+ return constraint;
+ }
+
+ public void setConstraint(PolicyConstraint constraint) {
+ this.constraint = constraint;
+ }
+
+ public String toString() {
+ try {
+ JAXBContext context = JAXBContext.newInstance(ProfilePolicy.class);
+ Marshaller marshaller = context.createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+
+ marshaller.marshal(this, stream);
+ return stream.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+}
diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/ProfilePolicySet.java b/base/common/src/com/netscape/cms/servlet/profile/model/ProfilePolicySet.java
new file mode 100644
index 000000000..784f5670d
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/profile/model/ProfilePolicySet.java
@@ -0,0 +1,50 @@
+//--- 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.cms.servlet.profile.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ProfilePolicySet {
+ @XmlElement
+ protected List<ProfilePolicy> policies = new ArrayList<ProfilePolicy>();
+
+ public List<ProfilePolicy> getPolicies() {
+ return policies;
+ }
+
+ public void setPolicies(List<ProfilePolicy> policies) {
+ this.policies = policies;
+ }
+
+ public void addPolicy(ProfilePolicy policy) {
+ policies.add(policy);
+ }
+
+ public void removePolicy(ProfilePolicy policy) {
+ policies.remove(policy);
+ }
+
+}