summaryrefslogtreecommitdiffstats
path: root/base/java-tools/src/com/netscape/cmstools/authority/AuthorityCLI.java
blob: ac06ea24ce824ad1b4be29a4176658caa9302e89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.netscape.cmstools.authority;

import com.netscape.certsrv.authority.AuthorityClient;
import com.netscape.certsrv.authority.AuthorityData;
import com.netscape.cmstools.cli.CLI;
import com.netscape.cmstools.cli.MainCLI;

public class AuthorityCLI extends CLI {

    public AuthorityClient authorityClient;

    public AuthorityCLI(CLI parent) {
        super("authority", "CA management commands", parent);

        addModule(new AuthorityFindCLI(this));
        addModule(new AuthorityShowCLI(this));
        addModule(new AuthorityCreateCLI(this));
        addModule(new AuthorityDisableCLI(this));
        addModule(new AuthorityEnableCLI(this));
        addModule(new AuthorityRemoveCLI(this));
    }

    public String getFullName() {
        if (parent instanceof MainCLI) {
            // do not include MainCLI's name
            return name;
        } else {
            return parent.getFullName() + "-" + name;
        }
    }

    public void execute(String[] args) throws Exception {
        client = parent.getClient();
        authorityClient = new AuthorityClient(client, "ca");
        super.execute(args);
    }

    protected static void printAuthorityData(AuthorityData data) {
        Boolean isHostAuthority = data.getIsHostAuthority();
        if (isHostAuthority != null && isHostAuthority)
            System.out.println("  Host authority: true");
        System.out.println("  Authority DN:   " + data.getDN());
        System.out.println("  ID:             " + data.getID());
        String parentAID = data.getParentID();
        if (parentAID != null)
            System.out.println("  Parent ID:      " + data.getParentID());
        System.out.println("  Enabled:        " + data.getEnabled());
        System.out.println("  Ready to sign:  " + data.getReady());
        String desc = data.getDescription();
        if (desc != null)
            System.out.println("  Description:    " + desc);
    }

}