HopsworksRMAppSecurityActions extends AbstractSecurityActions implements RMAppSecurityActions { @Override public int revoke(String certificateIdentifier) throws URISyntaxException, IOException, GeneralSecurityException { if (!x509Configured) { x509NotConfigured("revoke"); } CloseableHttpResponse response = null; try { URI parameterizedURI = new URIBuilder(revokePath) .addParameter(REVOKE_CERT_ID_PARAM, certificateIdentifier) .build(); HttpDelete request = new HttpDelete(parameterizedURI); response = doTextPlainCall(request, "Hopsworks CA could not revoke certificate " + certificateIdentifier); return response.getStatusLine().getStatusCode(); } finally { if (response != null) { response.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 testRevoke() throws Exception { String cn = UUID.randomUUID().toString(); PKCS10CertificationRequest csr = generateCSR(cn); RMAppSecurityActions actor = (RMAppSecurityActions) HopsSecurityActionsFactory.getInstance().getActor(conf, conf.get(YarnConfiguration.HOPS_RM_SECURITY_ACTOR_KEY, YarnConfiguration.HOPS_RM_SECURITY_ACTOR_DEFAULT)); actor.sign(csr); int response = actor.revoke(cn + "__" + O + "__" + OU); Assert.assertEquals(200, response); }