private void generateNewRealmKey() {
    String realmId = adminClient.realm(DEMO).toRepresentation().getId();

    ComponentRepresentation keys = new ComponentRepresentation();
    keys.setName("generated");
    keys.setProviderType(KeyProvider.class.getName());
    keys.setProviderId("rsa-generated");
    keys.setParentId(realmId);
    keys.setConfig(new MultivaluedHashMap<>());
    keys.getConfig().putSingle("priority", "150");
    Response response = adminClient.realm(DEMO).components().add(keys);
    assertEquals(201, response.getStatus());
    response.close();
  }
  private void rotateKeys() {
    String activeKid = providerRealm().keys().getKeyMetadata().getActive().get("RSA");

    // Rotate public keys on the parent broker
    String realmId = providerRealm().toRepresentation().getId();
    ComponentRepresentation keys = new ComponentRepresentation();
    keys.setName("generated");
    keys.setProviderType(KeyProvider.class.getName());
    keys.setProviderId("rsa-generated");
    keys.setParentId(realmId);
    keys.setConfig(new MultivaluedHashMap<>());
    keys.getConfig().putSingle("priority", Long.toString(System.currentTimeMillis()));
    Response response = providerRealm().components().add(keys);
    assertEquals(201, response.getStatus());
    response.close();

    String updatedActiveKid = providerRealm().keys().getKeyMetadata().getActive().get("RSA");
    assertNotEquals(activeKid, updatedActiveKid);
  }