summaryrefslogtreecommitdiffstats
path: root/proxy/code/src
diff options
context:
space:
mode:
authorjesus m. rodriguez <jesusr@redhat.com>2009-11-18 23:06:03 -0500
committerjesus m. rodriguez <jesusr@redhat.com>2009-11-18 23:06:03 -0500
commitd1db0051e3440f5ef4a7c9751eb8008f0ac7045a (patch)
treeb0e77cc7b2574dfc3836560b015ff5eb13583c85 /proxy/code/src
parentb78b3ce2451ca6d12ed65677ea63e7ee5e60041a (diff)
uploading and get of sat cert
Diffstat (limited to 'proxy/code/src')
-rw-r--r--proxy/code/src/org/fedoraproject/candlepin/resource/CertificateResource.java30
1 files changed, 23 insertions, 7 deletions
diff --git a/proxy/code/src/org/fedoraproject/candlepin/resource/CertificateResource.java b/proxy/code/src/org/fedoraproject/candlepin/resource/CertificateResource.java
index b0ae0c7..c749f0e 100644
--- a/proxy/code/src/org/fedoraproject/candlepin/resource/CertificateResource.java
+++ b/proxy/code/src/org/fedoraproject/candlepin/resource/CertificateResource.java
@@ -31,6 +31,7 @@ import java.text.ParseException;
import java.util.Date;
import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@@ -46,6 +47,7 @@ import javax.ws.rs.core.Response;
@Path("/certificate")
public class CertificateResource extends BaseResource {
public static Certificate cert;
+ public static String encodedCert = ""; // bad bad bad
/**
* default ctor
@@ -69,6 +71,7 @@ public class CertificateResource extends BaseResource {
throw new WebApplicationException(Response.Status.BAD_REQUEST);
}
+ encodedCert = base64cert;
String decoded = Base64.base64Decode(base64cert);
System.out.println(decoded);
cert = CertificateFactory.read(decoded);
@@ -90,14 +93,27 @@ public class CertificateResource extends BaseResource {
return "uuid";
}
-// @GET
-// @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-// public String get() {
-// return "Hello Certificate";
-// }
+ private String createString(byte[] bytes) {
+ StringBuffer buf = new StringBuffer();
+ for (byte b : bytes) {
+ buf.append((char) Integer.parseInt(Integer.toHexString(b), 16));
+ }
+
+ return buf.toString();
+ }
- public static Certificate get() {
- return cert;
+ @GET
+ @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+ public String get() {
+// byte[] s = null;
+// if (cert != null) {
+// s = Base64.encode(cert.asXmlString());
+// }
+//
+// String str = createString(s);
+// System.out.println(str);
+// return str;
+ return encodedCert;
}
private void addProducts(Certificate cert) throws ParseException {