HopsworksRMAppSecurityActions extends AbstractSecurityActions implements RMAppSecurityActions { @Override public X509SecurityHandler.CertificateBundle sign(PKCS10CertificationRequest csr) throws IOException, GeneralSecurityException { if (!x509Configured) { x509NotConfigured("sign"); } CloseableHttpResponse signResponse = null; try { String csrStr = stringifyCSR(csr); CSRDTO payload = new CSRDTO(); payload.csr = csrStr; HttpPost request = new HttpPost(signEndpoint); request.setEntity(new StringEntity(parser.toJson(payload))); signResponse = doJSONCall(request, "Hopsworks CA could not sign CSR"); CSRDTO csrResponse = parser.fromJson(EntityUtils.toString(signResponse.getEntity()), CSRDTO.class); X509Certificate certificate = parseCertificate(csrResponse.signedCert); X509Certificate issuer = parseCertificate(csrResponse.intermediateCaCert); return new X509SecurityHandler.CertificateBundle(certificate, issuer); } finally { if (signResponse != null) { signResponse.close(); } } } HopsworksRMAppSecurityActions(); @Override X509SecurityHandler.CertificateBundle sign(PKCS10CertificationRequest csr); @Override int revoke(String certificateIdentifier); @Override String generateJWT(JWTSecurityHandler.JWTMaterialParameter jwtParameter); @Override String renewJWT(JWTSecurityHandler.JWTMaterialParameter jwtParameter); @Override void invalidateJWT(String signingKeyName); static final String REVOKE_CERT_ID_PARAM; }
@Test public void testSign() throws Exception { PKCS10CertificationRequest csr = generateCSR(UUID.randomUUID().toString()); RMAppSecurityActions actor = (RMAppSecurityActions) HopsSecurityActionsFactory.getInstance().getActor(conf, conf.get(YarnConfiguration.HOPS_RM_SECURITY_ACTOR_KEY, YarnConfiguration.HOPS_RM_SECURITY_ACTOR_DEFAULT)); X509SecurityHandler.CertificateBundle singedBundle = actor.sign(csr); Assert.assertNotNull(singedBundle); }