@Test public void testPermissions() { Set<PermissionConfig> perms = securityConfig.getClientPermissionConfigs(); assertFalse(perms.isEmpty()); for (PermissionConfig permConfig : perms) { switch (permConfig.getType()) { case ALL: assertEquals("admin", permConfig.getPrincipal()); assertEquals(1, permConfig.getEndpoints().size()); assertEquals("127.0.0.1", permConfig.getEndpoints().iterator().next()); break; case MAP: assertEquals("customMap", permConfig.getName()); assertEquals("dev", permConfig.getPrincipal()); assertEquals(1, permConfig.getEndpoints().size()); assertEquals("127.0.0.1", permConfig.getEndpoints().iterator().next()); break; case QUEUE: assertEquals("customQ", permConfig.getName()); assertEquals("dev", permConfig.getPrincipal()); assertEquals(1, permConfig.getEndpoints().size()); assertEquals("127.0.0.1", permConfig.getEndpoints().iterator().next()); break; } } }
private Config decorate(Config config, String licenceKey) { config.setLicenseKey(licenceKey); config.setProperty(GroupProperties.PROP_WAIT_SECONDS_BEFORE_JOIN, "0"); final SecurityInterceptorConfig securityInterceptorConfig = new SecurityInterceptorConfig(); securityInterceptorConfig.setClassName(HazelcastSecurityInterceptor.class.getName()); final SecurityConfig securityConfig = config.getSecurityConfig(); securityConfig.setEnabled(true).addSecurityInterceptorConfig(securityInterceptorConfig); //When you enable security all client requests are denied, so we need to give permission first //security-interceptor will be run after checking this permission final PermissionConfig permissionConfig = new PermissionConfig(PermissionConfig.PermissionType.ALL, "", null); securityConfig.addClientPermissionConfig(permissionConfig); return config; }