diff options
author | Ade Lee <alee@redhat.com> | 2015-10-01 12:12:38 -0400 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2015-10-02 13:12:24 -0400 |
commit | a401b768197cbecf14d4e9fb268b51056dfa2510 (patch) | |
tree | 40cd0d6d09a65156cf0a0de780a585dfd287318b /base/common | |
parent | e9784003ebcfb310ff59a455e9af94d62f9502b4 (diff) | |
download | pki-a401b768197cbecf14d4e9fb268b51056dfa2510.tar.gz pki-a401b768197cbecf14d4e9fb268b51056dfa2510.tar.xz pki-a401b768197cbecf14d4e9fb268b51056dfa2510.zip |
Added Java client and CLI support for Feature resource.
Diffstat (limited to 'base/common')
3 files changed, 58 insertions, 5 deletions
diff --git a/base/common/src/com/netscape/certsrv/ca/CAClient.java b/base/common/src/com/netscape/certsrv/ca/CAClient.java index 1fbd2a0b2..bb131ecb1 100644 --- a/base/common/src/com/netscape/certsrv/ca/CAClient.java +++ b/base/common/src/com/netscape/certsrv/ca/CAClient.java @@ -19,14 +19,15 @@ package com.netscape.certsrv.ca; import java.net.URISyntaxException; +import com.netscape.certsrv.authority.AuthorityClient; import com.netscape.certsrv.cert.CertClient; import com.netscape.certsrv.client.PKIClient; import com.netscape.certsrv.client.SubsystemClient; import com.netscape.certsrv.group.GroupClient; import com.netscape.certsrv.profile.ProfileClient; import com.netscape.certsrv.selftests.SelfTestClient; +import com.netscape.certsrv.system.FeatureClient; import com.netscape.certsrv.user.UserClient; -import com.netscape.certsrv.authority.AuthorityClient; public class CAClient extends SubsystemClient { @@ -38,6 +39,7 @@ public class CAClient extends SubsystemClient { public void init() throws URISyntaxException { addClient(new AuthorityClient(client, name)); addClient(new CertClient(client, name)); + addClient(new FeatureClient(client, name)); addClient(new GroupClient(client, name)); addClient(new ProfileClient(client, name)); addClient(new SelfTestClient(client, name)); diff --git a/base/common/src/com/netscape/certsrv/system/Feature.java b/base/common/src/com/netscape/certsrv/system/Feature.java index 59b88d2f6..c995a2e6d 100644 --- a/base/common/src/com/netscape/certsrv/system/Feature.java +++ b/base/common/src/com/netscape/certsrv/system/Feature.java @@ -56,12 +56,12 @@ public class Feature { } @XmlAttribute(name="enabled") - public boolean getEnabled() { + public boolean isEnabled() { return enabled; } - public void setEnabled(String enabled) { - this.enabled = enabled.equalsIgnoreCase("true"); + public void setEnabled(boolean enabled) { + this.enabled = enabled; } @XmlAttribute(name="version") @@ -138,7 +138,7 @@ public class Feature { public static void main(String args[]) throws Exception { Feature before = new Feature(); before.setId("authority"); - before.setEnabled("true"); + before.setEnabled(true); before.setDescription("Subordinate CA Feature"); before.setVersion("1.0"); diff --git a/base/common/src/com/netscape/certsrv/system/FeatureClient.java b/base/common/src/com/netscape/certsrv/system/FeatureClient.java new file mode 100644 index 000000000..c5c9a1642 --- /dev/null +++ b/base/common/src/com/netscape/certsrv/system/FeatureClient.java @@ -0,0 +1,51 @@ +//--- 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) 2015 Red Hat, Inc. +//All rights reserved. +//--- END COPYRIGHT BLOCK --- +package com.netscape.certsrv.system; + +import java.net.URISyntaxException; +import java.util.List; + +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.Response; + +import com.netscape.certsrv.client.Client; +import com.netscape.certsrv.client.PKIClient; + +/** +* @author Ade Lee <alee@redhat.com> +*/ +public class FeatureClient extends Client { + + public FeatureResource featureClient; + + public FeatureClient(PKIClient client, String subsystem) throws URISyntaxException { + super(client, subsystem, "feature"); + featureClient = createProxy(FeatureResource.class); + } + + public List<Feature> listFeatures() { + Response response = featureClient.listFeatures(); + GenericType<List<Feature>> type = new GenericType<List<Feature>>() {}; + return client.getEntity(response, type); + } + + public Feature getFeature(String featureID) { + Response response = featureClient.getFeature(featureID); + return client.getEntity(response, Feature.class); + } +}
\ No newline at end of file |