The top-level CLI commands have been modified to get the subsystem name from the parent subsystem CLI if available, otherwise they will use a hard-coded default value.
https://pagure.io/dogtagpki/issue/2626 Pushed to master under trivial rule. -- Endi S. Dewata
>From 1d3216aece7381cbac7b812dfbb969b466b31abe Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" <edew...@redhat.com> Date: Thu, 30 Mar 2017 22:31:30 +0200 Subject: [PATCH] Fixed default subsystems for top-level CLI commands. The top-level CLI commands have been modified to get the subsystem name from the parent subsystem CLI if available, otherwise they will use a hard-coded default value. https://pagure.io/dogtagpki/issue/2626 Change-Id: Ieef45abfdfb4a6fc63fd06a6ccda4e70366de4a0 --- base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java | 10 ++++++++-- base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java | 10 ++++++++-- base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java | 9 +++++++-- .../src/com/netscape/cmstools/system/SecurityDomainCLI.java | 10 ++++++++-- base/java-tools/src/com/netscape/cmstools/user/UserCLI.java | 10 ++++++++-- 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java b/base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java index 96870844002f23d61d567c2a5647030317ea9f47..af117a6206813fcff23c29bce2b0f219a57ad2a9 100644 --- a/base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java @@ -32,6 +32,7 @@ import com.netscape.certsrv.cert.CertReviewResponse; import com.netscape.certsrv.client.PKIClient; import com.netscape.cmstools.cli.CLI; import com.netscape.cmstools.cli.MainCLI; +import com.netscape.cmstools.cli.SubsystemCLI; /** * @author Endi S. Dewata @@ -81,8 +82,13 @@ public class CertCLI extends CLI { PKIClient client = getClient(); // determine the subsystem - String subsystem = client.getSubsystem(); - if (subsystem == null) subsystem = "ca"; + String subsystem; + if (parent instanceof SubsystemCLI) { + SubsystemCLI subsystemCLI = (SubsystemCLI)parent; + subsystem = subsystemCLI.getName(); + } else { + subsystem = "ca"; + } // create new cert client certClient = new CertClient(client, subsystem); diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java index bd4651d9ee8b46382831bb71ee44446c6b35d1cb..5ccf70df54fde2a59123f8147649957ec36af243 100644 --- a/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java @@ -26,6 +26,7 @@ import com.netscape.certsrv.group.GroupClient; import com.netscape.certsrv.group.GroupData; import com.netscape.cmstools.cli.CLI; import com.netscape.cmstools.cli.MainCLI; +import com.netscape.cmstools.cli.SubsystemCLI; /** * @author Endi S. Dewata @@ -67,8 +68,13 @@ public class GroupCLI extends CLI { PKIClient client = getClient(); // determine the subsystem - String subsystem = client.getSubsystem(); - if (subsystem == null) subsystem = "ca"; + String subsystem; + if (parent instanceof SubsystemCLI) { + SubsystemCLI subsystemCLI = (SubsystemCLI)parent; + subsystem = subsystemCLI.getName(); + } else { + subsystem = "ca"; + } // create new group client groupClient = new GroupClient(client, subsystem); diff --git a/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java b/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java index b9b27d1132fbff0ed50c22a147ee09513ab66db9..d7c087f650f1ad6ba659e9cd4017b6289a2bf5e5 100644 --- a/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java @@ -27,6 +27,7 @@ import com.netscape.certsrv.system.SystemCertClient; import com.netscape.certsrv.util.NSSCryptoProvider; import com.netscape.cmstools.cli.CLI; import com.netscape.cmstools.cli.MainCLI; +import com.netscape.cmstools.cli.SubsystemCLI; import com.netscape.cmsutil.util.Utils; /** @@ -78,9 +79,13 @@ public class KeyCLI extends CLI { PKIClient client = getClient(); // determine the subsystem - String subsystem = client.getSubsystem(); - if (subsystem == null) + String subsystem; + if (parent instanceof SubsystemCLI) { + SubsystemCLI subsystemCLI = (SubsystemCLI)parent; + subsystem = subsystemCLI.getName(); + } else { subsystem = "kra"; + } // create new key client keyClient = new KeyClient(client, subsystem); diff --git a/base/java-tools/src/com/netscape/cmstools/system/SecurityDomainCLI.java b/base/java-tools/src/com/netscape/cmstools/system/SecurityDomainCLI.java index d9db91eb9295185188663fbb1dc235d00ab0cb89..ea6cd2944b3848f3c54eb951eeb3927a98bc96c8 100644 --- a/base/java-tools/src/com/netscape/cmstools/system/SecurityDomainCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/system/SecurityDomainCLI.java @@ -25,6 +25,7 @@ import com.netscape.certsrv.system.SecurityDomainHost; import com.netscape.certsrv.system.SecurityDomainSubsystem; import com.netscape.cmstools.cli.CLI; import com.netscape.cmstools.cli.MainCLI; +import com.netscape.cmstools.cli.SubsystemCLI; /** * @author Endi S. Dewata @@ -60,8 +61,13 @@ public class SecurityDomainCLI extends CLI { PKIClient client = getClient(); // determine the subsystem - String subsystem = client.getSubsystem(); - if (subsystem == null) subsystem = "ca"; + String subsystem; + if (parent instanceof SubsystemCLI) { + SubsystemCLI subsystemCLI = (SubsystemCLI)parent; + subsystem = subsystemCLI.getName(); + } else { + subsystem = "ca"; + } // create new security domain client securityDomainClient = new SecurityDomainClient(client, subsystem); diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java index 57a132c4670c27cda877ca2ed90d6037b3b1a3b5..1acbf0b726ac64147daa955b62a542818e180593 100644 --- a/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java @@ -27,6 +27,7 @@ import com.netscape.certsrv.user.UserData; import com.netscape.certsrv.user.UserResource; import com.netscape.cmstools.cli.CLI; import com.netscape.cmstools.cli.MainCLI; +import com.netscape.cmstools.cli.SubsystemCLI; /** * @author Endi S. Dewata @@ -70,8 +71,13 @@ public class UserCLI extends CLI { PKIClient client = getClient(); // determine the subsystem - String subsystem = client.getSubsystem(); - if (subsystem == null) subsystem = "ca"; + String subsystem; + if (parent instanceof SubsystemCLI) { + SubsystemCLI subsystemCLI = (SubsystemCLI)parent; + subsystem = subsystemCLI.getName(); + } else { + subsystem = "ca"; + } // create new user client userClient = new UserClient(client, subsystem); -- 2.9.3
_______________________________________________ Pki-devel mailing list Pki-devel@redhat.com https://www.redhat.com/mailman/listinfo/pki-devel