Search in sources :

Example 6 with TrustBundle

use of org.nhind.config.TrustBundle in project nhin-d by DirectProject.

the class TrustBundleCommands method listDomainBundles.

@Command(name = "ListDomainBundles", usage = LIST_DOMAIN_BUNDLES_USAGE)
public void listDomainBundles(String[] args) {
    final long domainId = Long.parseLong(StringArrayUtil.getRequiredValue(args, 0));
    try {
        final Domain domain = proxy.getDomain(domainId);
        if (domain == null) {
            System.out.println("Domain with id " + domainId + " does not exist.");
            return;
        }
        // make sure there isn't already an association
        final TrustBundleDomainReltn[] reltns = proxy.getTrustBundlesByDomain(domainId, false);
        if (reltns == null || reltns.length == 0) {
            System.out.println("No bundles associated with domain " + domain.getDomainName());
            return;
        }
        List<TrustBundle> bundles = new ArrayList<TrustBundle>();
        for (TrustBundleDomainReltn reltn : reltns) bundles.add(reltn.getTrustBundle());
        System.out.println("Bundles associated with domain " + domain.getDomainName());
        bundlePrinter.printRecords(bundles);
    } catch (Exception e) {
        System.out.println("Error getting domain bundles : " + e.getMessage());
    }
}
Also used : ArrayList(java.util.ArrayList) TrustBundle(org.nhind.config.TrustBundle) Domain(org.nhind.config.Domain) TrustBundleDomainReltn(org.nhind.config.TrustBundleDomainReltn) Command(org.nhindirect.dns.tools.utils.Command)

Example 7 with TrustBundle

use of org.nhind.config.TrustBundle in project nhin-d by DirectProject.

the class TrustBundleCommands method deleteTrustBundleFromDomain.

@Command(name = "DeleteTrustBundleFromDomain", usage = REMOVE_BUNDLE_FROM_DOMAIN)
public void deleteTrustBundleFromDomain(String[] args) {
    final long bundleId = Long.parseLong(StringArrayUtil.getRequiredValue(args, 0));
    final long domainId = Long.parseLong(StringArrayUtil.getRequiredValue(args, 1));
    try {
        final TrustBundle bundle = proxy.getTrustBundleById(bundleId);
        if (bundle == null) {
            System.out.println("Bundle with id " + bundleId + " does not exist.");
            return;
        }
        final Domain domain = proxy.getDomain(domainId);
        if (domain == null) {
            System.out.println("Domain with id " + domainId + " does not exist.");
            return;
        }
        // make sure there is already an association
        boolean associationExists = false;
        final TrustBundleDomainReltn[] reltns = proxy.getTrustBundlesByDomain(domainId, false);
        if (reltns != null && reltns.length > 0) {
            for (TrustBundleDomainReltn reltn : reltns) {
                if (reltn.getTrustBundle().getId() == bundleId) {
                    associationExists = true;
                    break;
                }
            }
        }
        if (!associationExists) {
            System.out.println("Bundle " + bundle.getBundleName() + " is not associated with domain " + domain.getDomainName());
            return;
        }
        proxy.disassociateTrustBundleFromDomain(domainId, bundleId);
        System.out.println("Trust bundle " + bundle.getBundleName() + " removed from domain " + domain.getDomainName());
    } catch (Exception e) {
        System.out.println("Error removing bundle from domain : " + e.getMessage());
    }
}
Also used : TrustBundle(org.nhind.config.TrustBundle) Domain(org.nhind.config.Domain) TrustBundleDomainReltn(org.nhind.config.TrustBundleDomainReltn) Command(org.nhindirect.dns.tools.utils.Command)

Aggregations

TrustBundle (org.nhind.config.TrustBundle)7 Command (org.nhindirect.dns.tools.utils.Command)6 Domain (org.nhind.config.Domain)4 TrustBundleDomainReltn (org.nhind.config.TrustBundleDomainReltn)4 ArrayList (java.util.ArrayList)2 TrustBundleAnchor (org.nhind.config.TrustBundleAnchor)2 File (java.io.File)1 IOException (java.io.IOException)1 CertificateException (java.security.cert.CertificateException)1 X509Certificate (java.security.cert.X509Certificate)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 AddressException (javax.mail.internet.AddressException)1 Anchor (org.nhind.config.Anchor)1 Setting (org.nhind.config.Setting)1 SmtpAgentException (org.nhindirect.gateway.smtp.SmtpAgentException)1 PolicyParseException (org.nhindirect.policy.PolicyParseException)1 TrustAnchorResolver (org.nhindirect.stagent.trust.TrustAnchorResolver)1 MultiDomainTrustAnchorResolverProvider (org.nhindirect.stagent.trust.provider.MultiDomainTrustAnchorResolverProvider)1 UniformTrustAnchorResolverProvider (org.nhindirect.stagent.trust.provider.UniformTrustAnchorResolverProvider)1