Search in sources :

Example 6 with CertPolicy

use of org.nhindirect.config.model.CertPolicy in project nhin-d by DirectProject.

the class PoliciesController method addPolicy.

/*********************************
     *
     * Add Policy Method
     *
     *********************************/
@PreAuthorize("hasRole('ROLE_ADMIN')")
@RequestMapping(value = "/addPolicy", method = RequestMethod.POST)
@ResponseBody
public String addPolicy(@RequestParam("id") String id, @RequestParam("policyName") String policyName, @RequestParam("policyContent") String policyContent, @RequestParam("policyLexicon") String policyLexicon) {
    // Debug Statement
    if (log.isDebugEnabled()) {
        log.debug("Adding New Policy");
    }
    if (log.isDebugEnabled()) {
        log.debug("Beginning to add new policy");
    }
    try {
        URL configURL = new URL("http://localhost:8081/config-service/ConfigurationService");
    } catch (MalformedURLException ue) {
    }
    final CertPolicy newPolicy = new CertPolicy();
    newPolicy.setPolicyName(policyName);
    // Set policy lexicon type           
    final String lexiconName = policyLexicon;
    if (lexiconName.equalsIgnoreCase("XML")) {
        newPolicy.setLexicon(PolicyLexicon.XML);
    } else if (lexiconName.equalsIgnoreCase("JAVA_SER")) {
        newPolicy.setLexicon(PolicyLexicon.JAVA_SER);
    } else if (lexiconName.equalsIgnoreCase("SIMPLE_TEXT_V1")) {
        newPolicy.setLexicon(PolicyLexicon.SIMPLE_TEXT_V1);
    }
    // Get lexicon file from form
    //CommonsMultipartFile lexiconFile = policyForm.getFileData();            
    newPolicy.setPolicyData(policyContent.getBytes());
    // Debug
    log.error(newPolicy);
    try {
        policyService.addPolicy(newPolicy);
    } catch (ServiceException cse) {
        cse.printStackTrace();
    }
    return "test";
}
Also used : MalformedURLException(java.net.MalformedURLException) ServiceException(org.nhindirect.common.rest.exceptions.ServiceException) CertPolicy(org.nhindirect.config.model.CertPolicy) URL(java.net.URL) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

CertPolicy (org.nhindirect.config.model.CertPolicy)6 ServiceException (org.nhindirect.common.rest.exceptions.ServiceException)3 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 PolicyForm (org.nhindirect.config.ui.form.PolicyForm)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 KeyStore (java.security.KeyStore)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 PrivateKey (java.security.PrivateKey)1 X509Certificate (java.security.cert.X509Certificate)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1