diff options
| author | jesus m. rodriguez <jesusr@redhat.com> | 2009-11-18 23:06:03 -0500 |
|---|---|---|
| committer | jesus m. rodriguez <jesusr@redhat.com> | 2009-11-18 23:06:03 -0500 |
| commit | d1db0051e3440f5ef4a7c9751eb8008f0ac7045a (patch) | |
| tree | b0e77cc7b2574dfc3836560b015ff5eb13583c85 /proxy/code/src | |
| parent | b78b3ce2451ca6d12ed65677ea63e7ee5e60041a (diff) | |
uploading and get of sat cert
Diffstat (limited to 'proxy/code/src')
| -rw-r--r-- | proxy/code/src/org/fedoraproject/candlepin/resource/CertificateResource.java | 30 |
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 { |
