From 628c2a61e714cffb39c372f4aa000d146820938b Mon Sep 17 00:00:00 2001
From: Jack Magne <jmagne@redhat.com>
Date: Mon, 13 Feb 2012 16:27:13 -0800
Subject: [PATCH] KRA symmetric key cmake support.

Changes to make the cmake build of this feature work.
Change to the .classpath to allow the DRMTest.java test client to run under Eclipse,
by adding additional jar paths to allow the client to run.
---
 pki/.classpath                                     |    5 +++++
 .../src/com/netscape/certsrv/request/IRequest.java |    2 ++
 .../com/netscape/cms/servlet/key/model/KeyDAO.java |   11 ++++-------
 pki/base/kra/src/CMakeLists.txt                    |    3 +++
 .../netscape/kra/SecurityDataRecoveryService.java  |    6 ++----
 5 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/pki/.classpath b/pki/.classpath
index c4d60d8..8ce6c7f 100644
--- a/pki/.classpath
+++ b/pki/.classpath
@@ -28,5 +28,10 @@
 	<classpathentry kind="lib" path="/usr/share/candlepin/lib/jaxrs-api-2.2.1.GA.jar"/>
 	<classpathentry kind="lib" path="/usr/share/candlepin/lib/resteasy-jaxrs-2.2.1.GA.jar"/>
 	<classpathentry kind="lib" path="/usr/share/java/apache-commons-cli.jar"/>
+        <classpathentry kind="lib" path="/usr/share/java/jakarta-commons-httpclient.jar"/>
+        <classpathentry kind="lib" path="/usr/share/java/apache-commons-logging.jar"/>
+        <classpathentry kind="lib" path="/usr/share/java/commons-codec.jar"/>
+        <classpathentry kind="lib" path="/usr/share/candlepin/lib/jaxb-impl-2.1.12.jar"/>
+        <classpathentry kind="lib" path="/usr/share/candlepin/lib/resteasy-jaxb-provider-2.2.1.GA.jar"/>
 	<classpathentry kind="output" path="build/classes"/>
 </classpath>
diff --git a/pki/base/common/src/com/netscape/certsrv/request/IRequest.java b/pki/base/common/src/com/netscape/certsrv/request/IRequest.java
index ec1f43f..e43856e 100644
--- a/pki/base/common/src/com/netscape/certsrv/request/IRequest.java
+++ b/pki/base/common/src/com/netscape/certsrv/request/IRequest.java
@@ -160,6 +160,8 @@ public interface IRequest {
     public static final String SECURITY_DATA_SESS_PASS_PHRASE = "sessionWrappedPassphrase";
     public static final String SECURITY_DATA_IV_STRING_IN = "iv_in";
     public static final String SECURITY_DATA_IV_STRING_OUT = "iv_out";
+    public static final String SECURITY_DATA_SESS_WRAPPED_DATA = "sessWrappedSecData";
+    public static final String SECURITY_DATA_PASS_WRAPPED_DATA = "passPhraseWrappedData";
 
 
     // requestor type values.
diff --git a/pki/base/common/src/com/netscape/cms/servlet/key/model/KeyDAO.java b/pki/base/common/src/com/netscape/cms/servlet/key/model/KeyDAO.java
index fd9d2d2..6a90a7c 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/key/model/KeyDAO.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/key/model/KeyDAO.java
@@ -23,8 +23,6 @@ import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.List;
 
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
 import com.netscape.certsrv.apps.CMS;
@@ -37,7 +35,6 @@ import com.netscape.certsrv.request.IRequestQueue;
 import com.netscape.certsrv.request.RequestId;
 import com.netscape.certsrv.request.RequestStatus;
 import com.netscape.cms.servlet.request.model.RecoveryRequestData;
-import com.netscape.kra.SecurityDataRecoveryService;
 
 /**
  * @author alee
@@ -116,8 +113,8 @@ public class KeyDAO {
             throw new EBaseException("Can't obtain Volatile requestParams in KeyDAO.getKey!");
         }
 
-        String sessWrappedKeyData = (String) requestParams.get(SecurityDataRecoveryService.ATTR_SESS_WRAPPED_DATA);
-        String passWrappedKeyData = (String) requestParams.get(SecurityDataRecoveryService.ATTR_PASS_WRAPPED_DATA);
+        String sessWrappedKeyData = (String) requestParams.get(IRequest.SECURITY_DATA_SESS_WRAPPED_DATA);
+        String passWrappedKeyData = (String) requestParams.get(IRequest.SECURITY_DATA_PASS_WRAPPED_DATA);
         String nonceData = (String) requestParams.get(IRequest.SECURITY_DATA_IV_STRING_OUT);
 
         if (sessWrappedKeyData != null || passWrappedKeyData != null) {
@@ -164,8 +161,8 @@ public class KeyDAO {
             nonceData = null;
             keyData = new KeyData();
 
-            sessWrappedKeyData = (String) requestParams.get(SecurityDataRecoveryService.ATTR_SESS_WRAPPED_DATA);
-            passWrappedKeyData = (String) requestParams.get(SecurityDataRecoveryService.ATTR_PASS_WRAPPED_DATA);
+            sessWrappedKeyData = (String) requestParams.get(IRequest.SECURITY_DATA_SESS_WRAPPED_DATA);
+            passWrappedKeyData = (String) requestParams.get(IRequest.SECURITY_DATA_PASS_WRAPPED_DATA);
             nonceData = (String) requestParams.get(IRequest.SECURITY_DATA_IV_STRING_OUT);
 
         }
diff --git a/pki/base/kra/src/CMakeLists.txt b/pki/base/kra/src/CMakeLists.txt
index a023c00..d265eee 100644
--- a/pki/base/kra/src/CMakeLists.txt
+++ b/pki/base/kra/src/CMakeLists.txt
@@ -75,14 +75,17 @@ set(pki-kra_java_SRCS
     com/netscape/kra/KeyRecoveryAuthority.java
     com/netscape/kra/EnrollmentService.java
     com/netscape/kra/RecoveryService.java
+    com/netscape/kra/SecurityDataRecoveryService.java
     com/netscape/kra/TokenKeyRecoveryService.java
     com/netscape/kra/EncryptionUnit.java
     com/netscape/kra/KRAService.java
     com/netscape/kra/NetkeyKeygenService.java
+    com/netscape/kra/SecurityDataService.java
     com/netscape/kra/KRANotify.java
     com/netscape/kra/KRAPolicy.java
     com/netscape/kra/TransportKeyUnit.java
     com/netscape/kra/StorageKeyUnit.java
+    com/netscape/kra/ArchiveOptions.java
 )
 
 
diff --git a/pki/base/kra/src/com/netscape/kra/SecurityDataRecoveryService.java b/pki/base/kra/src/com/netscape/kra/SecurityDataRecoveryService.java
index b387309..6673488 100644
--- a/pki/base/kra/src/com/netscape/kra/SecurityDataRecoveryService.java
+++ b/pki/base/kra/src/com/netscape/kra/SecurityDataRecoveryService.java
@@ -79,8 +79,6 @@ public class SecurityDataRecoveryService implements IService {
     private ITransportKeyUnit mTransportUnit = null;
 
     public static final String ATTR_SERIALNO = "serialNumber";
-    public static final String ATTR_SESS_WRAPPED_DATA = "sessWrappedSecData";
-    public static final String ATTR_PASS_WRAPPED_DATA = "passPhraseWrappedData";
     public static final String ATTR_KEY_RECORD = "keyRecord";
 
     public SecurityDataRecoveryService(IKeyRecoveryAuthority kra) {
@@ -200,7 +198,7 @@ public class SecurityDataRecoveryService implements IService {
                             pass);
                 }
 
-                params.put(ATTR_PASS_WRAPPED_DATA, pbeWrappedData);
+                params.put(IRequest.SECURITY_DATA_PASS_WRAPPED_DATA, pbeWrappedData);
 
             } catch (Exception e) {
                 throw new EBaseException("Can't unwrap pass phase! " + e.toString());
@@ -242,7 +240,7 @@ public class SecurityDataRecoveryService implements IService {
             }
 
             String wrappedKeyData = com.netscape.osutil.OSUtil.BtoA(key_data);
-            params.put(ATTR_SESS_WRAPPED_DATA, wrappedKeyData);
+            params.put(IRequest.SECURITY_DATA_SESS_WRAPPED_DATA, wrappedKeyData);
             params.put(IRequest.SECURITY_DATA_IV_STRING_OUT, ivStr);
 
         }
-- 
1.7.7.1

