>From 2d012328b0b4402d877202e5285249ee642ad548 Mon Sep 17 00:00:00 2001
From: Abhishek Koneru <akoneru@redhat.com>
Date: Wed, 16 Apr 2014 13:33:02 -0400
Subject: [PATCH] Addressed comments for patch 90. KeyCLIs

---
 base/common/CMakeLists.txt                         |  2 +-
 .../templates/archiveKey.xml}                      |  1 +
 .../templates/generateKey.xml}                     |  1 +
 .../templates/retrieveKey.xml}                     |  1 +
 .../com/netscape/certsrv/base/ResourceMessage.java | 20 +++++++
 .../src/com/netscape/certsrv/key/KeyClient.java    | 29 +++-------
 .../src/com/netscape/certsrv/key/KeyTemplate.java  |  9 ++-
 .../certsrv/key/SymKeyGenerationRequest.java       | 13 +++--
 .../com/netscape/cmstools/key/KeyGenerateCLI.java  | 15 +++--
 .../netscape/cmstools/key/KeyTemplateFindCLI.java  | 65 ++++++++++++++++++----
 .../netscape/cmstools/key/KeyTemplateShowCLI.java  | 63 +++++++++------------
 .../src/com/netscape/cms/servlet/test/DRMTest.java |  6 +-
 specs/pki-core.spec                                | 10 ++--
 13 files changed, 141 insertions(+), 94 deletions(-)
 rename base/common/{kra/templates/key-archive.xml => key/templates/archiveKey.xml} (90%)
 rename base/common/{kra/templates/key-generate.xml => key/templates/generateKey.xml} (80%)
 rename base/common/{kra/templates/key-retrieve.xml => key/templates/retrieveKey.xml} (88%)

diff --git a/base/common/CMakeLists.txt b/base/common/CMakeLists.txt
index f9b4e3c6bcd72f9f4ff11224d36aed591af7353a..f661890f2a4faf6c4c7f504670523582cdaabe6d 100644
--- a/base/common/CMakeLists.txt
+++ b/base/common/CMakeLists.txt
@@ -59,7 +59,7 @@ install(
 
 install(
     DIRECTORY
-        kra
+        key
     DESTINATION
         ${DATA_INSTALL_DIR}/
     FILE_PERMISSIONS
diff --git a/base/common/kra/templates/key-archive.xml b/base/common/key/templates/archiveKey.xml
similarity index 90%
rename from base/common/kra/templates/key-archive.xml
rename to base/common/key/templates/archiveKey.xml
index a698d59e122df5881cfb5590f721b4ba51da043f..6f8a01adda3341889a420ff7625116c10285d83f 100644
--- a/base/common/kra/templates/key-archive.xml
+++ b/base/common/key/templates/archiveKey.xml
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <KeyArchivalRequest>
     <Attributes>
+        <Attribute name="description">Template for submitting a key archival request</Attribute>
         <Attribute name="clientKeyID"></Attribute>
         <Attribute name="dataType">symmetricKey/passphrase/asymmetricKey</Attribute>
         <Attribute name="keyAlgorithm"></Attribute>
diff --git a/base/common/kra/templates/key-generate.xml b/base/common/key/templates/generateKey.xml
similarity index 80%
rename from base/common/kra/templates/key-generate.xml
rename to base/common/key/templates/generateKey.xml
index ef1df4113fda23a53812b3511947d6b95039e40d..25854e50324f4848af0180a0d9d102e70ae3e709 100644
--- a/base/common/kra/templates/key-generate.xml
+++ b/base/common/key/templates/generateKey.xml
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <SymKeyGenerationRequest>
     <Attributes>
+        <Attribute name="description">Template for submitting a request for generating a symmetric key.</Attribute>
         <Attribute name="clientKeyID"></Attribute>
         <Attribute name="keyAlgorithm">[AES/DES/DES3/DESede/RC2/RC4]</Attribute>
         <Attribute name="keySize">128</Attribute>
diff --git a/base/common/kra/templates/key-retrieve.xml b/base/common/key/templates/retrieveKey.xml
similarity index 88%
rename from base/common/kra/templates/key-retrieve.xml
rename to base/common/key/templates/retrieveKey.xml
index b3bb75b5810898738f06be8c3b00ecc05970dcef..4373e0390504e3476745eb1000230701dfe21363 100644
--- a/base/common/kra/templates/key-retrieve.xml
+++ b/base/common/key/templates/retrieveKey.xml
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <KeyRecoveryRequest>
     <Attributes>
+	<Attribute name="description">Template for submitting a key retrieval or key recovery request.</Attribute>
         <Attribute name="keyId">1</Attribute>
         <Attribute name="requestId">1</Attribute>
         <Attribute name="nonceData">Base64 encoded NonceData</Attribute>
diff --git a/base/common/src/com/netscape/certsrv/base/ResourceMessage.java b/base/common/src/com/netscape/certsrv/base/ResourceMessage.java
index 65f978ecc3ee3227c2dd671acd09decdbe3f2da4..34d7c2b11dc70efea03a96dac00bab02e48f580a 100644
--- a/base/common/src/com/netscape/certsrv/base/ResourceMessage.java
+++ b/base/common/src/com/netscape/certsrv/base/ResourceMessage.java
@@ -1,5 +1,8 @@
 package com.netscape.certsrv.base;
 
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.OutputStream;
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.util.ArrayList;
@@ -158,6 +161,13 @@ public class ResourceMessage {
         return sw.toString();
     }
 
+    public void marshall(OutputStream os) throws JAXBException {
+        JAXBContext context = JAXBContext.newInstance(this.getClass());
+        Marshaller marshaller = context.createMarshaller();
+        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+        marshaller.marshal(this, os);
+    }
+
     @SuppressWarnings("unchecked")
     public static <T> T unmarshal(String string, Class<T> clazz) throws Exception {
         try {
@@ -168,4 +178,14 @@ public class ResourceMessage {
         }
     }
 
+    public static <T> T unmarshall(Class<T> t, String filePath) throws JAXBException, FileNotFoundException {
+        JAXBContext context = JAXBContext.newInstance(t);
+        Unmarshaller unmarshaller = context.createUnmarshaller();
+        FileInputStream fis = new FileInputStream(filePath);
+        @SuppressWarnings("unchecked")
+        T req = (T) unmarshaller.unmarshal(fis);
+
+        return req;
+    }
+
 }
diff --git a/base/common/src/com/netscape/certsrv/key/KeyClient.java b/base/common/src/com/netscape/certsrv/key/KeyClient.java
index be326125d9ee5d540eefaaaa0598ad9d54c04767..8b7adf54222478de73be055c8c30eca6d06480e1 100644
--- a/base/common/src/com/netscape/certsrv/key/KeyClient.java
+++ b/base/common/src/com/netscape/certsrv/key/KeyClient.java
@@ -18,7 +18,6 @@
 package com.netscape.certsrv.key;
 
 import java.net.URISyntaxException;
-import java.util.Arrays;
 import java.util.List;
 
 import javax.ws.rs.core.Response;
@@ -668,38 +667,24 @@ public class KeyClient extends Client {
      *         object that describes the URL for the request and generated key.
      */
     public KeyRequestResponse generateSymmetricKey(String clientKeyId, String keyAlgorithm, int keySize,
-            String usages, String transWrappedSessionKey) {
+            List<String> usages, String transWrappedSessionKey) {
         if (clientKeyId == null) {
             throw new IllegalArgumentException("Client Key Identifier must be specified.");
         }
-
         //Validate the usages list
-        List<String> usagesList = null;
-        if (usages != null) {
-            List<String> validUsages = SymKeyGenerationRequest.getValidUsagesList();
-            String[] list = usages.split(",");
-            String invalidUsages = null;
-            ;
-            for (int i = 0; i < list.length; i++) {
-                if (!validUsages.contains(list[i])) {
-                    if (invalidUsages == null) {
-                        invalidUsages = list[i];
-                    } else {
-                        invalidUsages = invalidUsages + ", " + list[i];
-                    }
+        List<String> validUsages = SymKeyGenerationRequest.getValidUsagesList();
+        if (usages != null){
+            for (String usage : usages) {
+                if(!validUsages.contains(usage)){
+                    throw new IllegalArgumentException("Invalid usage \"" + usage + "\" specified.");
                 }
             }
-            if (invalidUsages != null) {
-                throw new IllegalArgumentException("Invalid usages specified. [" + invalidUsages + "]");
-            }
-            usagesList = Arrays.asList(list);
         }
-
         SymKeyGenerationRequest data = new SymKeyGenerationRequest();
         data.setClientKeyId(clientKeyId);
         data.setKeyAlgorithm(keyAlgorithm);
         data.setKeySize(new Integer(keySize));
-        data.setUsages(usagesList);
+        data.setUsages(usages);
         data.setTransWrappedSessionKey(transWrappedSessionKey);
 
         return createRequest(data);
diff --git a/base/common/src/com/netscape/certsrv/key/KeyTemplate.java b/base/common/src/com/netscape/certsrv/key/KeyTemplate.java
index 8f85b404b5cfc4fa2100c96a4715e40c628f1ee1..075d35820067bcf55541fe9f47b6ffdb8807ac85 100644
--- a/base/common/src/com/netscape/certsrv/key/KeyTemplate.java
+++ b/base/common/src/com/netscape/certsrv/key/KeyTemplate.java
@@ -2,20 +2,19 @@ package com.netscape.certsrv.key;
 
 public class KeyTemplate {
 
-    String ID;
+    String id;
     String name;
     String description;
 
-    public KeyTemplate(String ID, String name, String description) {
-        super();
-        this.ID = ID;
+    public KeyTemplate(String id, String name, String description) {
+        this.id = id;
         this.name = name;
         this.description = description;
     }
 
     public void printTemplateInfo() {
         System.out.println();
-        System.out.println("  Template ID: " + ID);
+        System.out.println("  Template ID: " + id);
         System.out.println("  Template Name: " + name);
         System.out.println("  Template Description: " + description);
     }
diff --git a/base/common/src/com/netscape/certsrv/key/SymKeyGenerationRequest.java b/base/common/src/com/netscape/certsrv/key/SymKeyGenerationRequest.java
index 1bbcbefbb700285c63844e340c5c90013273b728..a2440d7cbab7038628133f91426d5df4f650b1d1 100644
--- a/base/common/src/com/netscape/certsrv/key/SymKeyGenerationRequest.java
+++ b/base/common/src/com/netscape/certsrv/key/SymKeyGenerationRequest.java
@@ -17,7 +17,7 @@ import com.netscape.certsrv.base.ResourceMessage;
  * @author alee
  *
  */
-@XmlRootElement(name="SymKeyGenerationRequest")
+@XmlRootElement(name = "SymKeyGenerationRequest")
 @XmlAccessorType(XmlAccessType.FIELD)
 public class SymKeyGenerationRequest extends ResourceMessage {
 
@@ -37,7 +37,7 @@ public class SymKeyGenerationRequest extends ResourceMessage {
 
     public List<String> getUsages() {
         String usageString = attributes.get(KEY_USAGE);
-        if (! StringUtils.isBlank(usageString)) {
+        if (!StringUtils.isBlank(usageString)) {
             return new ArrayList<String>(Arrays.asList(usageString.split(",")));
         }
         return new ArrayList<String>();
@@ -49,8 +49,9 @@ public class SymKeyGenerationRequest extends ResourceMessage {
 
     public void addUsage(String usage) {
         List<String> usages = getUsages();
-        for (String u: usages) {
-            if (u.equals(usage)) return;
+        for (String u : usages) {
+            if (u.equals(usage))
+                return;
         }
         usages.add(usage);
         setUsages(usages);
@@ -69,7 +70,7 @@ public class SymKeyGenerationRequest extends ResourceMessage {
         attributes.put(TRANS_WRAPPED_SESSION_KEY, form.getFirst(TRANS_WRAPPED_SESSION_KEY));
 
         String usageString = attributes.get(KEY_USAGE);
-        if (! StringUtils.isBlank(usageString)) {
+        if (!StringUtils.isBlank(usageString)) {
             setUsages(new ArrayList<String>(Arrays.asList(usageString.split(","))));
         }
         setClassName(getClass().getName());
@@ -156,7 +157,7 @@ public class SymKeyGenerationRequest extends ResourceMessage {
         }
     }
 
-    public static List<String> getValidUsagesList(){
+    public static List<String> getValidUsagesList() {
         List<String> list = new ArrayList<String>();
         list.add(WRAP_USAGE);
         list.add(UWRAP_USAGE);
diff --git a/base/java-tools/src/com/netscape/cmstools/key/KeyGenerateCLI.java b/base/java-tools/src/com/netscape/cmstools/key/KeyGenerateCLI.java
index 2da821a45a5424a045618e835e5d9ec9ae861ebd..bcb41614ed52185a9d8ec43bb9e91fd9e1ec68fd 100644
--- a/base/java-tools/src/com/netscape/cmstools/key/KeyGenerateCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/key/KeyGenerateCLI.java
@@ -1,5 +1,8 @@
 package com.netscape.cmstools.key;
 
+import java.util.Arrays;
+import java.util.List;
+
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.Option;
 import org.apache.commons.cli.ParseException;
@@ -29,12 +32,12 @@ public class KeyGenerateCLI extends CLI {
         options.addOption(option);
 
         option = new Option(null, "key-size", true,
-                "Size of the key to be generated.\nThis is required for AES and RC2.\n"
+                "Size of the key to be generated.\nThis is required for AES, RC2 and RC4.\n"
                         + "Valid values for AES: 128, 192. 256.\nValid values for RC2: 8-128.\n Valid values for RC4: Any positive integer.");
         option.setArgName("size");
         options.addOption(option);
 
-        option = new Option(null, "usages", true, "Comma seperated list of usages."
+        option = new Option(null, "usages", true, "Comma separated list of usages."
                 + "\nValid values: wrap, unwrap, sign, verify, encrypt, decrypt.");
         option.setArgName("list of usages");
         options.addOption(option);
@@ -81,10 +84,14 @@ public class KeyGenerateCLI extends CLI {
                 System.exit(1);
             }
         }
-
+        List<String> usages = null;
+        String givenUsages = cmd.getOptionValue("usages");
+        if(givenUsages != null){
+            usages = Arrays.asList(givenUsages.split(","));
+        }
         KeyRequestResponse response = keyCLI.keyClient.generateSymmetricKey(clientKeyId, keyAlgorithm,
                 Integer.parseInt(keySize),
-                cmd.getOptionValue("usages"), null);
+                usages, null);
 
         MainCLI.printMessage("Key generation request info");
         KeyCLI.printKeyRequestInfo(response.getRequestInfo());
diff --git a/base/java-tools/src/com/netscape/cmstools/key/KeyTemplateFindCLI.java b/base/java-tools/src/com/netscape/cmstools/key/KeyTemplateFindCLI.java
index 9bbef9379c9e5294177c9c556c68897ad6ad9a68..e1ef610d566d8cde251094f547733ef92fbef13e 100644
--- a/base/java-tools/src/com/netscape/cmstools/key/KeyTemplateFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/key/KeyTemplateFindCLI.java
@@ -1,8 +1,16 @@
 package com.netscape.cmstools.key;
 
+import java.io.File;
+import java.io.FileNotFoundException;
 import java.util.ArrayList;
 
+import javax.xml.bind.JAXBException;
+
+import com.netscape.certsrv.base.ResourceMessage;
+import com.netscape.certsrv.key.KeyArchivalRequest;
+import com.netscape.certsrv.key.KeyRecoveryRequest;
 import com.netscape.certsrv.key.KeyTemplate;
+import com.netscape.certsrv.key.SymKeyGenerationRequest;
 import com.netscape.cmstools.cli.CLI;
 import com.netscape.cmstools.cli.MainCLI;
 
@@ -14,7 +22,6 @@ public class KeyTemplateFindCLI extends CLI {
     public KeyTemplateFindCLI(KeyCLI keyCLI) {
         super("template-find", "List request template IDs", keyCLI);
         this.keyCLI = keyCLI;
-        createTemplateList();
     }
 
     public void printHelp() {
@@ -22,22 +29,56 @@ public class KeyTemplateFindCLI extends CLI {
     }
 
     public void execute(String[] args) {
+
+        try {
+            createTemplateList();
+        } catch (FileNotFoundException | JAXBException e) {
+            System.err.println("Error: " + e.getMessage());
+            if (verbose)
+                e.printStackTrace();
+            System.exit(-1);
+        }
         MainCLI.printMessage("List of templates");
         for (KeyTemplate template : templates) {
             template.printTemplateInfo();
         }
+        System.out.println();
     }
 
-    public void createTemplateList() {
-        KeyTemplate template = new KeyTemplate("archiveKey", "Key Archival Request",
-                "Template file for submitting a key archival request");
-        templates.add(template);
-        template = new KeyTemplate("retrieveKey", "Key retrieval request",
-                "Template for submitting a key retrieval or key recovery request.");
-        templates.add(template);
-        template = new KeyTemplate("generateKey", "Symmetric Key generation request",
-                "Template for submitting a request for generating a symmetric key.");
-        templates.add(template);
+    public void createTemplateList() throws FileNotFoundException, JAXBException {
+        String templateDir = "/usr/share/pki/key/templates/";
+        File file = new File(templateDir);
+        if (!file.exists()) {
+            System.err.println("Error: Missing template files.");
+            System.exit(-1);
+        }
+        KeyTemplate template = null;
+        ResourceMessage data = null;
+        String[] templateFiles = file.list();
+        for (String templateName : templateFiles) {
+            if (templateName.indexOf(".xml") == -1) {
+                continue;
+            }
+            String id = templateName.substring(0, templateName.indexOf(".xml"));
+            switch (id) {
+            case "archiveKey":
+                data = ResourceMessage.unmarshall(KeyArchivalRequest.class, templateDir + templateName);
+                template = new KeyTemplate(id, "Key archival request", data.getAttribute("description"));
+                templates.add(template);
+                break;
+            case "retrieveKey":
+                data = ResourceMessage.unmarshall(KeyRecoveryRequest.class, templateDir + templateName);
+                template = new KeyTemplate(id, "Key retrieval request", data.getAttribute("description"));
+                templates.add(template);
+                break;
+            case "generateKey":
+                data = ResourceMessage.unmarshall(SymKeyGenerationRequest.class, templateDir + templateName);
+                template = new KeyTemplate(id, "Symmetric key generation request", data.getAttribute("description"));
+                templates.add(template);
+                break;
+            default:
+                break;
+            }
+        }
     }
-
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/key/KeyTemplateShowCLI.java b/base/java-tools/src/com/netscape/cmstools/key/KeyTemplateShowCLI.java
index f85bef94bdc6ca2b2ea5924f93f069fba876af88..0bfba42a358bcb4d8ec93b9e69ecaf112d9510fe 100644
--- a/base/java-tools/src/com/netscape/cmstools/key/KeyTemplateShowCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/key/KeyTemplateShowCLI.java
@@ -1,14 +1,10 @@
 package com.netscape.cmstools.key;
 
-import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
-import java.io.OutputStream;
+import java.io.IOException;
 
-import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
 
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.Option;
@@ -58,24 +54,22 @@ public class KeyTemplateShowCLI extends CLI {
 
         String templateId = cmdArgs[0];
         String writeToFile = cmd.getOptionValue("output-file");
-
+        String templateDir = "/usr/share/pki/key/templates/";
+        String templatePath = templateDir + templateId + ".xml";
         ResourceMessage data = null;
-        String message = null;
         try {
             switch (templateId) {
             case "archiveKey":
-                data = readFromTemplateFile(KeyArchivalRequest.class, "/usr/share/pki/kra/templates/key-archive.xml");
-                message = "key archival request";
+                data = ResourceMessage.unmarshall(KeyArchivalRequest.class, templatePath);
                 break;
-            case "retrieveKey":
             case "recoverKey":
-                message = "key recover request";
-                data = readFromTemplateFile(KeyRecoveryRequest.class, "/usr/share/pki/kra/templates/key-retrieve.xml");
+                templatePath = templateDir + "retrieveKey.xml";
+            case "retrieveKey":
+                data = ResourceMessage.unmarshall(KeyRecoveryRequest.class, templatePath);
                 break;
             case "generateKey":
-                message = "symmetric key generation request";
-                data = readFromTemplateFile(SymKeyGenerationRequest.class,
-                        "/usr/share/pki/kra/templates/key-generate.xml");
+                data = ResourceMessage.unmarshall(SymKeyGenerationRequest.class,
+                        templatePath);
                 break;
             default:
                 System.err.println("Error: Invalid template id.");
@@ -89,10 +83,11 @@ public class KeyTemplateShowCLI extends CLI {
             System.exit(-1);
         }
 
-        if ((writeToFile != null) && (writeToFile.trim().length() != 0)) {
+        if (writeToFile != null) {
+            FileOutputStream fOS = null;
             try {
-                FileOutputStream fOS = new FileOutputStream(writeToFile);
-                printRequestTemplate(data, fOS);
+                fOS = new FileOutputStream(writeToFile);
+                data.marshall(fOS);
             } catch (JAXBException e) {
                 System.err.println("Error: Cannot write the file");
                 if (verbose)
@@ -101,11 +96,22 @@ public class KeyTemplateShowCLI extends CLI {
                 System.err.println("Error: Cannot write the file");
                 if (verbose)
                     e.printStackTrace();
+            } finally {
+                if (fOS != null) {
+                    try {
+                        fOS.close();
+                    } catch (IOException e) {
+                        System.err.println("Error: " + e.getMessage());
+                        if (verbose)
+                            e.printStackTrace();
+                        System.exit(-1);
+                    }
+                }
             }
         } else {
-            MainCLI.printMessage("Template for " + message);
+            MainCLI.printMessage(data.getAttribute("description"));
             try {
-                printRequestTemplate(data, System.out);
+                data.marshall(System.out);
             } catch (JAXBException e) {
                 System.err.println(e.getMessage());
                 if (verbose)
@@ -113,21 +119,4 @@ public class KeyTemplateShowCLI extends CLI {
             }
         }
     }
-
-    public <T> void printRequestTemplate(T t, OutputStream os) throws JAXBException {
-        JAXBContext context = JAXBContext.newInstance(t.getClass());
-        Marshaller marshaller = context.createMarshaller();
-        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
-        marshaller.marshal(t, os);
-    }
-
-    public <T> T readFromTemplateFile(Class<T> t, String filePath) throws JAXBException, FileNotFoundException {
-        JAXBContext context = JAXBContext.newInstance(t);
-        Unmarshaller unmarshaller = context.createUnmarshaller();
-        FileInputStream fis = new FileInputStream(filePath);
-        @SuppressWarnings("unchecked")
-        T req = (T) unmarshaller.unmarshal(fis);
-
-        return req;
-    }
 }
diff --git a/base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java b/base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java
index ba2d6930aac678bc5de46d9133fa5e77baa9d14f..cb80039b76d642586b0f14bcd3c756ebf67cd44c 100644
--- a/base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java
+++ b/base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java
@@ -17,8 +17,10 @@
 // --- END COPYRIGHT BLOCK ---
 package com.netscape.cms.servlet.test;
 
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Random;
 
 import org.apache.commons.cli.CommandLine;
@@ -502,7 +504,9 @@ public class DRMTest {
 
         // test 18: Generate symmetric key
         clientKeyId = "Symmetric Key #1234f " + Calendar.getInstance().getTime().toString();
-        String usages = SymKeyGenerationRequest.DECRYPT_USAGE + "," + SymKeyGenerationRequest.ENCRYPT_USAGE;
+        List<String> usages = new ArrayList<String>();
+        usages.add(SymKeyGenerationRequest.DECRYPT_USAGE);
+        usages.add(SymKeyGenerationRequest.ENCRYPT_USAGE);
         KeyRequestResponse genKeyResponse = keyClient.generateSymmetricKey(clientKeyId,
                 KeyRequestResource.AES_ALGORITHM,
                 128, usages, null);
diff --git a/specs/pki-core.spec b/specs/pki-core.spec
index d0fa1512dac2b9139ca5478d94690840689ec8d8..65a15425371c7a2160d2c8be1d405cabc6f6097c 100644
--- a/specs/pki-core.spec
+++ b/specs/pki-core.spec
@@ -5,7 +5,7 @@ distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
 
 Name:             pki-core
 Version:          10.2.0
-Release:          0.2%{?dist}
+Release:          0.1%{?dist}
 Summary:          Certificate System - PKI Core Components
 URL:              http://pki.fedoraproject.org/
 License:          GPLv2
@@ -839,7 +839,7 @@ fi
 %{_datadir}/pki/VERSION
 %{_datadir}/pki/etc/
 %{_datadir}/pki/upgrade/
-%{_datadir}/pki/kra/templates
+%{_datadir}/pki/key/templates
 %dir %{_sysconfdir}/pki
 %config(noreplace) %{_sysconfdir}/pki/pki.conf
 %dir %{_javadir}/pki
@@ -1011,10 +1011,6 @@ fi
 %endif # %{with server}
 
 %changelog
-* Thu Apr 10 2014 Abhishek Koneru <akoneru@redhat.com> 10.2.0-0.2
-- Added template files for archive, retrieve and generate key
-  requests to the client package.
-
 * Fri Nov 22 2013 Dogtag Team <pki-devel@redhat.com> 10.2.0-0.1
 - Added option to build without server packages.
 - Replaced Jettison with Jackson.
@@ -1022,6 +1018,8 @@ fi
 - Bugzilla Bug #1057959 - pkispawn requires policycoreutils-python
 - TRAC Ticket #840 - pkispawn requires policycoreutils-python
 - Updated requirements for resteasy
+- Added template files for archive, retrieve and generate key
+  requests to the client package.
 
 * Fri Nov 15 2013 Ade Lee <alee@redhat.com> 10.1.0-1
 - Trac Ticket 788 - Clean up spec files
-- 
1.8.5.3

