ClientPermissions { public void addPermission(final String secretName, final Permissions permission) { synchronized (this.secretPermissions) { final Integer previous = this.secretPermissions.putIfAbsent(secretName, permission.getCode()); if (previous != null) { final Integer updated = (previous | permission.getCode()); this.secretPermissions.put(secretName, updated); } } } ClientPermissions();  ClientPermissions(final Map<String, Integer> secretPermissions); void addPermission(final String secretName, final Permissions permission); void removePermission(final String secretName, final Permissions permission); boolean hasPermission(final String secretName, final Permissions permission); void clearPermission(final String secretName); void clearAllPermissions();  }
@Test public void testAddPermission() { final ClientPermissions clientPermission = new ClientPermissions(); final String secret1 = "test1"; final String secret2 = "test2"; clientPermission.addPermission(secret1, Permissions.GENERATE); Assert.assertTrue(clientPermission.hasPermission(secret1, Permissions.GENERATE)); Assert.assertFalse(clientPermission.hasPermission(secret2, Permissions.GENERATE)); Assert.assertFalse(clientPermission.hasPermission(secret1, Permissions.DELETE)); Assert.assertFalse(clientPermission.hasPermission(secret1, Permissions.DISABLE)); Assert.assertFalse(clientPermission.hasPermission(secret1, Permissions.ENABLE)); Assert.assertFalse(clientPermission.hasPermission(secret1, Permissions.EXPONENTIATE)); Assert.assertFalse(clientPermission.hasPermission(secret1, Permissions.INFO)); Assert.assertFalse(clientPermission.hasPermission(secret1, Permissions.READ)); }