SamlCertificate { @GET @Path("/certificate") @Produces({MediaType.APPLICATION_OCTET_STREAM}) public byte[] getSamlCertificate() { try { File certFile = ResourceFinder.getFile(MSConfig.getConfiguration().getString("mtwilson.saml.certificate.file", "saml.crt.pem")); log.debug("Certificate File " + certFile.getPath()); try (FileInputStream in = new FileInputStream(certFile)) { String certificate = IOUtils.toString(in); X509Certificate cert = X509Util.decodePemCertificate(certificate); log.info("Read certificate successfully"); return cert.getEncoded(); } } catch (CertificateException e) { throw new MSException(ErrorCode.MS_BAD_CERTIFICATE_FILE, ErrorCode.MS_BAD_CERTIFICATE_FILE.getMessage(), e); } catch (IOException e) { throw new MSException(ErrorCode.MS_MISSING_CERTIFICATE_FILE, ErrorCode.MS_MISSING_CERTIFICATE_FILE.getMessage(), e); } } SamlCertificate(); @GET @Produces({MediaType.TEXT_PLAIN}) String defaultCaGetAction(); @GET @Path("/certificate/mtwilson-saml.crt") @Produces({MediaType.APPLICATION_OCTET_STREAM}) //@PermitAll byte[] getSamlCertificateFilename(); @GET @Path("/certificate") @Produces({MediaType.APPLICATION_OCTET_STREAM}) //@PermitAll byte[] getSamlCertificate();  }
@Test public void testGetSamlCertificate() { System.out.println("getSamlCertificate"); SamlCertificate instance = new SamlCertificate(); byte[] expResult = null; byte[] result = instance.getSamlCertificate(); System.err.println("Saml Cert == " + result.toString()); }