Search in sources :

Example 1 with SearchDomainForm

use of org.nhindirect.config.ui.form.SearchDomainForm in project nhin-d by DirectProject.

the class BundlesController method addBundle.

/*********************************
     *
     * Add Bundle Method
     *
     *********************************/
@PreAuthorize("hasRole('ROLE_ADMIN')")
@RequestMapping(value = "/addbundle", method = RequestMethod.POST)
public ModelAndView addBundle(@RequestHeader(value = "X-Requested-With", required = false) String requestedWith, HttpSession session, @ModelAttribute BundleForm bundleForm, Model model, @RequestParam(value = "submitType") String actionPath) {
    final ModelAndView mav = new ModelAndView();
    // Debug Statement
    if (log.isDebugEnabled())
        log.debug("Enter Add Trust Bundle");
    if (actionPath.equalsIgnoreCase("cancel")) {
        if (log.isDebugEnabled()) {
            log.debug("trying to cancel from saveupdate");
        }
        // If cancel then clear form	
        final SearchDomainForm form2 = (SearchDomainForm) session.getAttribute("searchDomainForm");
        model.addAttribute(form2 != null ? form2 : new SearchDomainForm());
        model.addAttribute("ajaxRequest", AjaxUtils.isAjaxRequest(requestedWith));
        mav.setViewName("main");
        mav.addObject("privKeyTypeList", PrivateKeyType.getPrivKeyTypeList());
        mav.addObject("statusList", EntityStatus.getEntityStatusList());
        return mav;
    }
    if (actionPath.equalsIgnoreCase("newbundle") || actionPath.equalsIgnoreCase("add bundle")) {
        Boolean formValidated = true;
        if (log.isDebugEnabled()) {
            log.debug("Beginning to process signing certificate file");
        }
        model.addAttribute("signingCertError", false);
        model.addAttribute("URLError", false);
        final TrustBundle trustBundle = new TrustBundle();
        String bundleName = bundleForm.getBundleName();
        trustBundle.setBundleName(bundleName);
        // Convert Hours to Seconds for backend
        trustBundle.setRefreshInterval(bundleForm.getRefreshInterval() * 3600);
        // Check if signing certificate is uploaded
        if (!bundleForm.getFileData().isEmpty()) {
            byte[] bytes = bundleForm.getFileData().getBytes();
            final String fileType = bundleForm.getFileData().getContentType();
            if (!fileType.matches("application/x-x509-ca-cert") && !fileType.matches("application/x-x509-user-cert") && !fileType.matches("application/pkix-cert")) {
                model.addAttribute("signingCertError", true);
                formValidated = false;
            } else {
                try {
                    trustBundle.setSigningCertificateData(bytes);
                } catch (Exception ce) {
                }
            }
        } else {
            if (log.isDebugEnabled())
                log.debug("DO NOT store the bundle into database BECAUSE THERE IS NO FILE");
        }
        // Check for empty bundle name
        if (bundleName.isEmpty()) {
            model.addAttribute("EmptyBundleError", true);
            formValidated = false;
        } else {
            // Check if trust bundle name is already used
            TrustBundle dupeBundle = null;
            try {
                dupeBundle = bundleService.getTrustBundle(bundleName);
            } catch (ServiceException cse) {
                log.error("Could not get bundle information from config service");
            }
            if (dupeBundle != null) {
                model.addAttribute("DupeBundleError", true);
                formValidated = false;
            }
        }
        // Check for valid URL
        final String trustURL = bundleForm.getTrustURL();
        try {
            new URL(trustURL);
        } catch (MalformedURLException mu) {
            model.addAttribute("URLError", true);
            formValidated = false;
        }
        if (formValidated) {
            trustBundle.setBundleURL(trustURL);
            try {
                trustBundle.setCheckSum("");
                bundleService.addTrustBundle(trustBundle);
                if (log.isDebugEnabled()) {
                    log.debug("Add Trust Bundle to Database");
                }
            } catch (Exception e) {
                if (log.isDebugEnabled())
                    log.error(e);
                e.printStackTrace();
            }
            final BundleForm bform = new BundleForm();
            model.addAttribute("bundleForm", bform);
        }
        // Process data for Trust Bundle View
        try {
            // Get Trust Bundles
            final Collection<TrustBundle> trustBundles = bundleService.getTrustBundles(false);
            if (trustBundles != null) {
                model.addAttribute("trustBundles", trustBundles);
            }
        } catch (ServiceException e1) {
        }
        model.addAttribute("bundlesSelected");
        model.addAttribute("ajaxRequest", AjaxUtils.isAjaxRequest(requestedWith));
        mav.setViewName("bundles");
    }
    return mav;
}
Also used : SearchDomainForm(org.nhindirect.config.ui.form.SearchDomainForm) MalformedURLException(java.net.MalformedURLException) ServiceException(org.nhindirect.common.rest.exceptions.ServiceException) BundleForm(org.nhindirect.config.ui.form.BundleForm) ModelAndView(org.springframework.web.servlet.ModelAndView) TrustBundle(org.nhindirect.config.model.TrustBundle) MalformedURLException(java.net.MalformedURLException) ServiceException(org.nhindirect.common.rest.exceptions.ServiceException) IOException(java.io.IOException) URL(java.net.URL) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with SearchDomainForm

use of org.nhindirect.config.ui.form.SearchDomainForm in project nhin-d by DirectProject.

the class SettingsController method addSetting.

@PreAuthorize("hasRole('ROLE_ADMIN')")
@RequestMapping(value = "/addsetting", method = RequestMethod.POST)
public ModelAndView addSetting(@RequestHeader(value = "X-Requested-With", required = false) String requestedWith, HttpSession session, @ModelAttribute SettingsForm settingsForm, Model model, @RequestParam(value = "submitType") String actionPath) {
    final ModelAndView mav = new ModelAndView();
    String strid = "";
    String key = "";
    String value = "";
    if (log.isDebugEnabled())
        log.debug("Enter domain/addsetting");
    if (actionPath.equalsIgnoreCase("cancel")) {
        if (log.isDebugEnabled())
            log.debug("trying to cancel from saveupdate");
        SearchDomainForm form2 = (SearchDomainForm) session.getAttribute("searchDomainForm");
        model.addAttribute(form2 != null ? form2 : new SearchDomainForm());
        model.addAttribute("ajaxRequest", AjaxUtils.isAjaxRequest(requestedWith));
        mav.setViewName("main");
        mav.addObject("privKeyTypeList", PrivateKeyType.getPrivKeyTypeList());
        mav.addObject("statusList", EntityStatus.getEntityStatusList());
        return mav;
    }
    if (actionPath.equalsIgnoreCase("newsetting") || actionPath.equalsIgnoreCase("add setting")) {
        if (log.isDebugEnabled())
            log.debug("trying to get/set settings");
        strid = "" + settingsForm.getId();
        key = "" + settingsForm.getKey();
        value = "" + settingsForm.getValue();
        try {
            if (log.isDebugEnabled())
                log.debug("trying set settings services");
            settingsService.addSetting(key, value);
            if (log.isDebugEnabled())
                log.debug("PAST trying set settings services");
        } catch (ServiceException e) {
            e.printStackTrace();
        }
        model.addAttribute("ajaxRequest", AjaxUtils.isAjaxRequest(requestedWith));
        SimpleForm simple = new SimpleForm();
        simple.setId(Long.parseLong(strid));
        model.addAttribute("simpleForm", simple);
        try {
            model.addAttribute("settingsResults", settingsService.getSettings());
        } catch (ServiceException e) {
            e.printStackTrace();
        }
        mav.setViewName("settings");
        // the Form's default button action
        String action = "Update";
        model.addAttribute("settingsForm", settingsForm);
        model.addAttribute("action", action);
        model.addAttribute("ajaxRequest", AjaxUtils.isAjaxRequest(requestedWith));
    }
    return mav;
}
Also used : SearchDomainForm(org.nhindirect.config.ui.form.SearchDomainForm) SimpleForm(org.nhindirect.config.ui.form.SimpleForm) ServiceException(org.nhindirect.common.rest.exceptions.ServiceException) ModelAndView(org.springframework.web.servlet.ModelAndView) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with SearchDomainForm

use of org.nhindirect.config.ui.form.SearchDomainForm in project nhin-d by DirectProject.

the class CertificatesController method addCertificate.

@PreAuthorize("hasRole('ROLE_ADMIN')")
@RequestMapping(value = "/addcertificate", method = RequestMethod.POST)
public ModelAndView addCertificate(@RequestHeader(value = "X-Requested-With", required = false) String requestedWith, HttpSession session, @ModelAttribute CertificateForm certificateForm, Model model, @RequestParam(value = "submitType") String actionPath) {
    final ModelAndView mav = new ModelAndView();
    String strid = "";
    //if (log.isDebugEnabled()) 
    log.error("Enter domain/addcertificate");
    if (actionPath.equalsIgnoreCase("cancel")) {
        if (log.isDebugEnabled())
            log.debug("trying to cancel from saveupdate");
        final SearchDomainForm form2 = (SearchDomainForm) session.getAttribute("searchDomainForm");
        model.addAttribute(form2 != null ? form2 : new SearchDomainForm());
        model.addAttribute("ajaxRequest", AjaxUtils.isAjaxRequest(requestedWith));
        mav.setViewName("main");
        mav.addObject("privKeyTypeList", PrivateKeyType.getPrivKeyTypeList());
        mav.addObject("statusList", EntityStatus.getEntityStatusList());
        return mav;
    }
    if (actionPath.equalsIgnoreCase("newcertificate") || actionPath.equalsIgnoreCase("add certificate")) {
        log.debug("Attempting to add certificate");
        if (this.keyManager == null)
            log.debug("Key manager is null");
        else
            log.debug("Key manager is non-null");
        strid = "" + certificateForm.getId();
        // insert the new address into the Domain list of Addresses
        final EntityStatus estatus = certificateForm.getStatus();
        if (log.isDebugEnabled())
            log.debug("beginning to evaluate filedata");
        try {
            model.addAttribute("certerror", false);
            model.addAttribute("passphraseError", false);
            if (!certificateForm.getFileData().isEmpty()) {
                final String passphrase = (certificateForm.getKeyPassphrase() == null) ? "" : certificateForm.getKeyPassphrase();
                PrivateKeyType privKeyType = PrivateKeyType.fromString(certificateForm.getPrivKeyType());
                if ((privKeyType == PrivateKeyType.PKCS8_PASSPHRASE || privKeyType == PrivateKeyType.PKCS_12_PASSPHRASE) && StringUtils.isEmpty(passphrase)) {
                    // can't move on if a passphrase is required and one is not supplied
                    model.addAttribute("passphraseError", true);
                } else {
                    byte[] certOrP12Bytes = certificateForm.getFileData().getBytes();
                    byte[] privateKeyBytes = null;
                    if (privKeyType == PrivateKeyType.PKCS_12_PASSPHRASE || privKeyType == PrivateKeyType.PKCS_12_UNPROTECTED) {
                        log.debug("Converting byte stream to cert container");
                        // there is a private key present.. normalized it to an unproted format
                        //if (cont.getKey() != null)
                        //{
                        log.debug("Private key exists; normalizing to non-protected p12 format.");
                        certOrP12Bytes = CertUtils.changePkcs12Protection(certOrP12Bytes, passphrase.toCharArray(), passphrase.toCharArray(), "".toCharArray(), "".toCharArray());
                    //}
                    } else if (privKeyType != PrivateKeyType.NONE) {
                        // there is a private key file associated with this request
                        privateKeyBytes = certificateForm.getPrivKeyData().getBytes();
                        // get the private key... it may be different formats, so be on the watch
                        if (privKeyType == PrivateKeyType.PKCS8_PASSPHRASE) {
                            // key
                            try {
                                final EncryptedPrivateKeyInfo encryptPKInfo = new EncryptedPrivateKeyInfo(privateKeyBytes);
                                final Cipher cipher = Cipher.getInstance(encryptPKInfo.getAlgName());
                                final PBEKeySpec pbeKeySpec = new PBEKeySpec(passphrase.toCharArray());
                                final SecretKeyFactory secFac = SecretKeyFactory.getInstance(encryptPKInfo.getAlgName());
                                final Key pbeKey = secFac.generateSecret(pbeKeySpec);
                                final AlgorithmParameters algParams = encryptPKInfo.getAlgParameters();
                                cipher.init(Cipher.DECRYPT_MODE, pbeKey, algParams);
                                final KeySpec pkcs8KeySpec = encryptPKInfo.getKeySpec(cipher);
                                final KeyFactory kf = KeyFactory.getInstance("RSA");
                                privateKeyBytes = kf.generatePrivate(pkcs8KeySpec).getEncoded();
                            } catch (Exception e) {
                                return mav;
                            }
                        }
                    }
                    String owner = "";
                    final String fileType = certificateForm.getFileData().getContentType();
                    if (!fileType.matches("application/x-x509-ca-cert") && !fileType.matches("application/octet-stream") && !fileType.matches("application/x-pkcs12")) {
                        model.addAttribute("certerror", true);
                    } else {
                        final Certificate cert = new Certificate();
                        // convert the cert and key to the proper storage format
                        cert.setData(toCertDataFormat(certOrP12Bytes, privateKeyBytes, privKeyType));
                        cert.setOwner(owner);
                        cert.setStatus(org.nhindirect.config.model.EntityStatus.valueOf(estatus.toString()));
                        final ArrayList<Certificate> certlist = new ArrayList<Certificate>();
                        certlist.add(cert);
                        log.debug("Adding certificate to config store.");
                        certService.addCertificate(cert);
                        log.debug("Certificate add SUCCESSFUL");
                    }
                }
            } else {
                if (log.isDebugEnabled())
                    log.debug("DO NOT store the certificate into database BECAUSE THERE IS NO FILE");
            }
        } catch (ServiceException ed) {
            log.error(ed);
        } catch (Exception e) {
            log.error(e);
            e.printStackTrace();
        }
        // certificate form and result
        try {
            final Collection<Certificate> certs = certService.getAllCertificates();
            if (this.keyManager != null && this.keyManager instanceof MutableKeyStoreProtectionManager) {
                final KeyStore keyStore = ((MutableKeyStoreProtectionManager) keyManager).getKS();
                // the key store manager to see if they have private keys
                for (Certificate cert : certs) {
                    if (!cert.isPrivateKey()) {
                        try {
                            final X509Certificate checkCert = CertUtils.toX509Certificate(cert.getData());
                            final String alias = keyStore.getCertificateAlias(checkCert);
                            if (!StringUtils.isEmpty(alias)) {
                                // check if this entry has a private key associated with
                                // it
                                final PrivateKey privKey = (PrivateKey) keyStore.getKey(alias, "".toCharArray());
                                if (privKey != null)
                                    cert.setPrivateKey(true);
                            }
                        } catch (Exception e) {
                        }
                    }
                }
            }
            model.addAttribute("certificatesResults", certs);
            final CertificateForm cform = new CertificateForm();
            cform.setId(0);
            model.addAttribute("certificateForm", cform);
        } catch (ServiceException e1) {
            e1.printStackTrace();
        }
        model.addAttribute("ajaxRequest", AjaxUtils.isAjaxRequest(requestedWith));
        final SimpleForm simple = new SimpleForm();
        simple.setId(Long.parseLong(strid));
        model.addAttribute("simpleForm", simple);
        mav.setViewName("certificates");
        // the Form's default button action
        final String action = "Update";
        model.addAttribute("action", action);
        model.addAttribute("ajaxRequest", AjaxUtils.isAjaxRequest(requestedWith));
        mav.addObject("privKeyTypeList", PrivateKeyType.getPrivKeyTypeList());
        mav.addObject("statusList", EntityStatus.getEntityStatusList());
    }
    return mav;
}
Also used : PBEKeySpec(javax.crypto.spec.PBEKeySpec) CertificateForm(org.nhindirect.config.ui.form.CertificateForm) SimpleForm(org.nhindirect.config.ui.form.SimpleForm) PrivateKey(java.security.PrivateKey) KeySpec(java.security.spec.KeySpec) PBEKeySpec(javax.crypto.spec.PBEKeySpec) PKCS8EncodedKeySpec(java.security.spec.PKCS8EncodedKeySpec) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) SearchDomainForm(org.nhindirect.config.ui.form.SearchDomainForm) MutableKeyStoreProtectionManager(org.nhindirect.common.crypto.MutableKeyStoreProtectionManager) EntityStatus(org.nhindirect.config.model.EntityStatus) SecretKeyFactory(javax.crypto.SecretKeyFactory) KeyFactory(java.security.KeyFactory) SecretKeyFactory(javax.crypto.SecretKeyFactory) KeyStore(java.security.KeyStore) ServiceException(org.nhindirect.common.rest.exceptions.ServiceException) IOException(java.io.IOException) CryptoException(org.nhindirect.common.crypto.exceptions.CryptoException) X509Certificate(java.security.cert.X509Certificate) PrivateKeyType(org.nhindirect.config.ui.util.PrivateKeyType) ServiceException(org.nhindirect.common.rest.exceptions.ServiceException) EncryptedPrivateKeyInfo(javax.crypto.EncryptedPrivateKeyInfo) Cipher(javax.crypto.Cipher) Key(java.security.Key) PrivateKey(java.security.PrivateKey) SecretKey(javax.crypto.SecretKey) AlgorithmParameters(java.security.AlgorithmParameters) X509Certificate(java.security.cert.X509Certificate) Certificate(org.nhindirect.config.model.Certificate) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with SearchDomainForm

use of org.nhindirect.config.ui.form.SearchDomainForm in project nhin-d by DirectProject.

the class MainController method search.

/**
	 * Execute the search and return the results
	 */
@PreAuthorize("hasRole('ROLE_ADMIN')")
@RequestMapping(value = "/search", method = RequestMethod.GET)
public ModelAndView search(@RequestHeader(value = "X-Requested-With", required = false) String requestedWith, HttpSession session, @ModelAttribute SimpleForm simpleForm, Model model, @RequestParam(value = "submitType") String actionPath) {
    if (log.isDebugEnabled())
        log.debug("Enter search");
    String message = "Search complete";
    ModelAndView mav = new ModelAndView();
    // check to see if new domain requested
    if (actionPath.equalsIgnoreCase("gotosettings")) {
        if (log.isDebugEnabled())
            log.debug("trying to go to the settings page");
        String action = "add";
        model.addAttribute("action", action);
        mav.setViewName("settings");
        mav.addObject("actionPath", actionPath);
        SettingsForm form = (SettingsForm) session.getAttribute("settingsForm");
        if (form == null) {
            form = new SettingsForm();
        }
        model.addAttribute("settingsForm", form);
        // retrieve list of settings for settingsResults
        List<Setting> results = null;
        if (configSvc != null) {
            try {
                Collection<Setting> settings = configSvc.getAllSettings();
                if (settings != null)
                    results = new ArrayList<Setting>(settings);
                else
                    results = new ArrayList<Setting>();
            } catch (ConfigurationServiceException e) {
                e.printStackTrace();
            }
        }
        model.addAttribute("simpleForm", new SimpleForm());
        model.addAttribute("settingsResults", results);
    } else if (actionPath.equalsIgnoreCase("gotocertificates")) {
        if (log.isDebugEnabled())
            log.debug("trying to go to the certificates page");
        String action = "Update";
        model.addAttribute("action", action);
        mav.setViewName("certificates");
        mav.addObject("actionPath", actionPath);
        CertificateForm form = (CertificateForm) session.getAttribute("certificateForm");
        if (form == null) {
            form = new CertificateForm();
        }
        model.addAttribute("certificateForm", form);
        // retrieve list of settings for settingsResults
        List<Certificate> results = null;
        if (configSvc != null) {
            try {
                Collection<Certificate> certs = configSvc.listCertificates(1, 10000, CertificateGetOptions.DEFAULT);
                if (certs != null)
                    results = new ArrayList<Certificate>(certs);
                else
                    results = new ArrayList<Certificate>();
            } catch (ConfigurationServiceException e) {
                e.printStackTrace();
            }
        }
        model.addAttribute("simpleForm", new SimpleForm());
        model.addAttribute("certificatesResults", results);
    } else if (actionPath.equalsIgnoreCase("newdomain")) {
        if (log.isDebugEnabled())
            log.debug("trying to go to the new domain page");
        HashMap<String, String> msgs = new HashMap<String, String>();
        mav.addObject("msgs", msgs);
        model.addAttribute("simpleForm", new SimpleForm());
        AddressForm addrform = new AddressForm();
        addrform.setId(0L);
        model.addAttribute("addressForm", addrform);
        // TODO: once certificates and anchors are available change code accordingly
        CertificateForm cform = new CertificateForm();
        cform.setId(0L);
        AnchorForm aform = new AnchorForm();
        aform.setId(0L);
        model.addAttribute("certificateForm", cform);
        model.addAttribute("anchorForm", aform);
        String action = "Add";
        DomainForm form = (DomainForm) session.getAttribute("domainForm");
        if (form == null) {
            form = new DomainForm();
        }
        model.addAttribute("domainForm", form);
        model.addAttribute("action", action);
        mav.setViewName("domain");
        mav.addObject("actionPath", actionPath);
        mav.addObject("statusList", EntityStatus.getEntityStatusList());
    } else if (actionPath.equalsIgnoreCase("gotodns")) {
        if (log.isDebugEnabled())
            log.debug("trying to go to the DNS page");
        HashMap<String, String> msgs = new HashMap<String, String>();
        mav.addObject("msgs", msgs);
        String action = "Update";
        model.addAttribute("action", action);
        // get all DNSType.A.getValue() records
        // GET A RECORDS
        Collection<DNSRecord> arecords = null;
        arecords = getDnsRecords(DNSType.A.getValue());
        model.addAttribute("dnsARecordResults", arecords);
        // GET A4 RECORDS
        Collection<DNSRecord> a4records = null;
        a4records = getDnsRecords(DNSType.AAAA.getValue());
        model.addAttribute("dnsA4RecordResults", a4records);
        // GET C RECORDS
        Collection<DNSRecord> crecords = null;
        crecords = getDnsRecords(DNSType.CNAME.getValue());
        model.addAttribute("dnsCnameRecordResults", crecords);
        // GET Cert RECORDS
        Collection<DNSRecord> certrecords = null;
        certrecords = getDnsRecords(DNSType.CERT.getValue());
        model.addAttribute("dnsCertRecordResults", certrecords);
        // GET MX RECORDS
        Collection<DNSRecord> mxrecords = null;
        mxrecords = getDnsRecords(DNSType.MX.getValue());
        model.addAttribute("dnsMxRecordResults", mxrecords);
        // GET SRV RECORDS
        Collection<DNSRecord> srvrecords = null;
        srvrecords = getDnsRecords(DNSType.SRV.getValue());
        model.addAttribute("dnsSrvRecordResults", srvrecords);
        mav.setViewName("dns");
        mav.addObject("actionPath", actionPath);
        model.addAttribute("AdnsForm", new DNSEntryForm());
        model.addAttribute("AAdnsForm", new DNSEntryForm());
        model.addAttribute("CdnsForm", new DNSEntryForm());
        model.addAttribute("CertdnsForm", new DNSEntryForm());
        model.addAttribute("MXdnsForm", new DNSEntryForm());
        model.addAttribute("SrvdnsForm", new DNSEntryForm());
        refreshModelFromService(model);
        model.addAttribute("simpleForm", new SimpleForm());
    } else {
        SearchDomainForm form = (SearchDomainForm) session.getAttribute("searchDomainForm");
        if (form == null) {
            form = new SearchDomainForm();
        }
        model.addAttribute(form);
        model.addAttribute("ajaxRequest", AjaxUtils.isAjaxRequest(requestedWith));
        String domain = form.getDomainName();
        EntityStatus status = form.getStatus();
        List<Domain> results = null;
        if (configSvc != null) {
            Collection<Domain> domains = configSvc.searchDomain(domain, status);
            if (domains != null) {
                results = new ArrayList<Domain>(domains);
            } else {
                results = new ArrayList<Domain>();
            }
        }
        if (AjaxUtils.isAjaxRequest(requestedWith)) {
            // prepare model for rendering success message in this request
            model.addAttribute("message", new Message(MessageType.success, message));
            model.addAttribute("ajaxRequest", true);
            model.addAttribute("searchResults", results);
            return null;
        }
        mav.setViewName("main");
        mav.addObject("statusList", EntityStatus.getEntityStatusList());
        mav.addObject("searchResults", results);
    }
    if (log.isDebugEnabled())
        log.debug("Exit");
    return mav;
}
Also used : SimpleForm(org.nhindirect.config.ui.form.SimpleForm) CertificateForm(org.nhindirect.config.ui.form.CertificateForm) AnchorForm(org.nhindirect.config.ui.form.AnchorForm) Message(org.nhindirect.config.ui.flash.FlashMap.Message) HashMap(java.util.HashMap) Setting(org.nhindirect.config.store.Setting) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) ConfigurationServiceException(org.nhindirect.config.service.ConfigurationServiceException) DNSEntryForm(org.nhindirect.config.ui.form.DNSEntryForm) DomainForm(org.nhindirect.config.ui.form.DomainForm) SearchDomainForm(org.nhindirect.config.ui.form.SearchDomainForm) SearchDomainForm(org.nhindirect.config.ui.form.SearchDomainForm) AddressForm(org.nhindirect.config.ui.form.AddressForm) SettingsForm(org.nhindirect.config.ui.form.SettingsForm) Collection(java.util.Collection) EntityStatus(org.nhindirect.config.store.EntityStatus) List(java.util.List) ArrayList(java.util.ArrayList) X509Certificate(java.security.cert.X509Certificate) Certificate(org.nhindirect.config.store.Certificate) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with SearchDomainForm

use of org.nhindirect.config.ui.form.SearchDomainForm in project nhin-d by DirectProject.

the class MainController method display.

/**
	 * Return the login page when requested
	 * @return
	 */
@PreAuthorize("hasRole('ROLE_ADMIN')")
@RequestMapping(method = RequestMethod.GET)
public ModelAndView display(@RequestHeader(value = "X-Requested-With", required = false) String requestedWith, HttpSession session, Model model) {
    if (log.isDebugEnabled())
        log.debug("Enter");
    ModelAndView mav = new ModelAndView();
    SearchDomainForm form = (SearchDomainForm) session.getAttribute("searchDomainForm");
    model.addAttribute(form != null ? form : new SearchDomainForm());
    model.addAttribute("ajaxRequest", AjaxUtils.isAjaxRequest(requestedWith));
    mav.setViewName("main");
    mav.addObject("statusList", EntityStatus.getEntityStatusList());
    if (log.isDebugEnabled())
        log.debug("Exit");
    return mav;
}
Also used : SearchDomainForm(org.nhindirect.config.ui.form.SearchDomainForm) ModelAndView(org.springframework.web.servlet.ModelAndView) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SearchDomainForm (org.nhindirect.config.ui.form.SearchDomainForm)9 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 ModelAndView (org.springframework.web.servlet.ModelAndView)9 ServiceException (org.nhindirect.common.rest.exceptions.ServiceException)7 ArrayList (java.util.ArrayList)6 SimpleForm (org.nhindirect.config.ui.form.SimpleForm)5 IOException (java.io.IOException)4 X509Certificate (java.security.cert.X509Certificate)4 CertificateForm (org.nhindirect.config.ui.form.CertificateForm)4 KeyStore (java.security.KeyStore)3 PrivateKey (java.security.PrivateKey)3 Collection (java.util.Collection)3 List (java.util.List)3 MutableKeyStoreProtectionManager (org.nhindirect.common.crypto.MutableKeyStoreProtectionManager)3 Certificate (org.nhindirect.config.model.Certificate)3 ConfigurationServiceException (org.nhindirect.config.service.ConfigurationServiceException)3 SettingsForm (org.nhindirect.config.ui.form.SettingsForm)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 HashMap (java.util.HashMap)2