@Test public void deleteIdentityNoServerResponse() throws Exception { thrown.expect(IdentityException.class); thrown.expectMessage("Error while deleting user"); HFCAClient client = HFCAClient.createNewInstance("http: client.setCryptoSuite(crypto); HFCAIdentity ident = client.newHFCAIdentity("testuser1"); ident.delete(admin); }
public int delete(User registrar) throws IdentityException, InvalidArgumentException { if (this.deleted) { throw new IdentityException("Identity has been deleted"); } if (registrar == null) { throw new InvalidArgumentException("Registrar should be a valid member"); } String deleteURL = ""; try { deleteURL = client.getURL(HFCA_IDENTITY + "/" + getEnrollmentId()); logger.debug(format("identity url: %s, registrar: %s", deleteURL, registrar.getName())); JsonObject result = client.httpDelete(deleteURL, registrar); statusCode = result.getInt("statusCode"); if (statusCode < 400) { getHFCAIdentity(result); logger.debug(format("identity url: %s, registrar: %s done.", deleteURL, registrar)); } this.deleted = true; return statusCode; } catch (HTTPException e) { String msg = format("[Code: %d] - Error while deleting user '%s' from url '%s': %s", e.getStatusCode(), getEnrollmentId(), deleteURL, e.getMessage()); IdentityException identityException = new IdentityException(msg, e); logger.error(msg); throw identityException; } catch (Exception e) { String msg = format("Error while deleting user '%s' from url '%s': %s", getEnrollmentId(), deleteURL, e.getMessage()); IdentityException identityException = new IdentityException(msg, e); logger.error(msg); throw identityException; } }
HFCAIdentity { public int delete(User registrar) throws IdentityException, InvalidArgumentException { if (this.deleted) { throw new IdentityException("Identity has been deleted"); } if (registrar == null) { throw new InvalidArgumentException("Registrar should be a valid member"); } String deleteURL = ""; try { deleteURL = client.getURL(HFCA_IDENTITY + "/" + getEnrollmentId()); logger.debug(format("identity url: %s, registrar: %s", deleteURL, registrar.getName())); JsonObject result = client.httpDelete(deleteURL, registrar); statusCode = result.getInt("statusCode"); if (statusCode < 400) { getHFCAIdentity(result); logger.debug(format("identity url: %s, registrar: %s done.", deleteURL, registrar)); } this.deleted = true; return statusCode; } catch (HTTPException e) { String msg = format("[Code: %d] - Error while deleting user '%s' from url '%s': %s", e.getStatusCode(), getEnrollmentId(), deleteURL, e.getMessage()); IdentityException identityException = new IdentityException(msg, e); logger.error(msg); throw identityException; } catch (Exception e) { String msg = format("Error while deleting user '%s' from url '%s': %s", getEnrollmentId(), deleteURL, e.getMessage()); IdentityException identityException = new IdentityException(msg, e); logger.error(msg); throw identityException; } } }
HFCAIdentity { public int delete(User registrar) throws IdentityException, InvalidArgumentException { if (this.deleted) { throw new IdentityException("Identity has been deleted"); } if (registrar == null) { throw new InvalidArgumentException("Registrar should be a valid member"); } String deleteURL = ""; try { deleteURL = client.getURL(HFCA_IDENTITY + "/" + getEnrollmentId()); logger.debug(format("identity url: %s, registrar: %s", deleteURL, registrar.getName())); JsonObject result = client.httpDelete(deleteURL, registrar); statusCode = result.getInt("statusCode"); if (statusCode < 400) { getHFCAIdentity(result); logger.debug(format("identity url: %s, registrar: %s done.", deleteURL, registrar)); } this.deleted = true; return statusCode; } catch (HTTPException e) { String msg = format("[Code: %d] - Error while deleting user '%s' from url '%s': %s", e.getStatusCode(), getEnrollmentId(), deleteURL, e.getMessage()); IdentityException identityException = new IdentityException(msg, e); logger.error(msg); throw identityException; } catch (Exception e) { String msg = format("Error while deleting user '%s' from url '%s': %s", getEnrollmentId(), deleteURL, e.getMessage()); IdentityException identityException = new IdentityException(msg, e); logger.error(msg); throw identityException; } } HFCAIdentity(String enrollmentID, HFCAClient client);   HFCAIdentity(JsonObject result); }
HFCAIdentity { public int delete(User registrar) throws IdentityException, InvalidArgumentException { if (this.deleted) { throw new IdentityException("Identity has been deleted"); } if (registrar == null) { throw new InvalidArgumentException("Registrar should be a valid member"); } String deleteURL = ""; try { deleteURL = client.getURL(HFCA_IDENTITY + "/" + getEnrollmentId()); logger.debug(format("identity url: %s, registrar: %s", deleteURL, registrar.getName())); JsonObject result = client.httpDelete(deleteURL, registrar); statusCode = result.getInt("statusCode"); if (statusCode < 400) { getHFCAIdentity(result); logger.debug(format("identity url: %s, registrar: %s done.", deleteURL, registrar)); } this.deleted = true; return statusCode; } catch (HTTPException e) { String msg = format("[Code: %d] - Error while deleting user '%s' from url '%s': %s", e.getStatusCode(), getEnrollmentId(), deleteURL, e.getMessage()); IdentityException identityException = new IdentityException(msg, e); logger.error(msg); throw identityException; } catch (Exception e) { String msg = format("Error while deleting user '%s' from url '%s': %s", getEnrollmentId(), deleteURL, e.getMessage()); IdentityException identityException = new IdentityException(msg, e); logger.error(msg); throw identityException; } } HFCAIdentity(String enrollmentID, HFCAClient client);   HFCAIdentity(JsonObject result); String getEnrollmentId(); String getType(); void setType(String type); String getSecret(); void setSecret(String secret); Integer getMaxEnrollments(); void setMaxEnrollments(Integer maxEnrollments); String getAffiliation(); void setAffiliation(String affiliation); void setAffiliation(HFCAAffiliation affiliation); Collection<Attribute> getAttributes(); void setAttributes(Collection<Attribute> attributes); boolean isDeleted(); int read(User registrar); int create(User registrar); int update(User registrar); int delete(User registrar); }
HFCAIdentity { public int delete(User registrar) throws IdentityException, InvalidArgumentException { if (this.deleted) { throw new IdentityException("Identity has been deleted"); } if (registrar == null) { throw new InvalidArgumentException("Registrar should be a valid member"); } String deleteURL = ""; try { deleteURL = client.getURL(HFCA_IDENTITY + "/" + getEnrollmentId()); logger.debug(format("identity url: %s, registrar: %s", deleteURL, registrar.getName())); JsonObject result = client.httpDelete(deleteURL, registrar); statusCode = result.getInt("statusCode"); if (statusCode < 400) { getHFCAIdentity(result); logger.debug(format("identity url: %s, registrar: %s done.", deleteURL, registrar)); } this.deleted = true; return statusCode; } catch (HTTPException e) { String msg = format("[Code: %d] - Error while deleting user '%s' from url '%s': %s", e.getStatusCode(), getEnrollmentId(), deleteURL, e.getMessage()); IdentityException identityException = new IdentityException(msg, e); logger.error(msg); throw identityException; } catch (Exception e) { String msg = format("Error while deleting user '%s' from url '%s': %s", getEnrollmentId(), deleteURL, e.getMessage()); IdentityException identityException = new IdentityException(msg, e); logger.error(msg); throw identityException; } } HFCAIdentity(String enrollmentID, HFCAClient client);   HFCAIdentity(JsonObject result); String getEnrollmentId(); String getType(); void setType(String type); String getSecret(); void setSecret(String secret); Integer getMaxEnrollments(); void setMaxEnrollments(Integer maxEnrollments); String getAffiliation(); void setAffiliation(String affiliation); void setAffiliation(HFCAAffiliation affiliation); Collection<Attribute> getAttributes(); void setAttributes(Collection<Attribute> attributes); boolean isDeleted(); int read(User registrar); int create(User registrar); int update(User registrar); int delete(User registrar);  }