public boolean hasAnyGroups(String... groupNames) { for (Group group : groups) { for (String groupName : groupNames) { if (groupName.equals(group.getName())) { return true; } } } return false; }
public void write(Group group, String homePerspectiveId, Map out) { String key = GROUP + "." + group.getName() + "." + HOME; out.remove(key); if (homePerspectiveId != null) { out.put(key, homePerspectiveId); } }
public void write(Group group, int priority, Map out) { String key = GROUP + "." + group.getName() + "." + PRIORITY; out.put(key, Integer.toString(priority)); }
/** * WildFly / EAP realms based on properties do not allow groups with empty users. So the groups are created using the method #assignUsers. * * @param entity The entity to create. * @return A runtime instance for a group. * @throws SecurityManagementException */ @Override public Group create( Group entity ) throws SecurityManagementException { if (entity == null) throw new NullPointerException(); return new GroupImpl( entity.getName() ); }
protected Set<String> getGroupNames() { final Set<String> result = new LinkedHashSet<String>(user.getGroups().size()); for (final Group group : user.getGroups()) { result.add(group.getName()); } return result; }
@Override protected void open(final User user) { final Set<Group> userGroups = user.getGroups(); for (final Group group : userGroups) { if (!userSystemManager.getConstrainedGroups().contains(group.getName())) { this.entities.add(group); } } super.open(user); }
@Override public Group answer(InvocationOnMock invocationOnMock) throws Throwable { String name = (String) invocationOnMock.getArguments()[0]; Group g = mock(Group.class); when(g.getName()).thenReturn(name); return g; } }).when(groupManager).get(anyString());
@Override public Group create(Group group) throws SecurityManagementException { final String name = group.getName(); if (isConstrained(name)) { throw new IllegalArgumentException("Group with name '" + name + "' cannot be created, " + "as it is a constrained value (it is a role or the admin group"); } final GroupManager serviceImpl = getService(); return serviceImpl.create(group); }
@Override public Group update(Group group) throws SecurityManagementException { final String name = group.getName(); if (isConstrained(name)) { throw new IllegalArgumentException("Group with name '" + name + "' cannot be updated, " + "as it is a constrained value (it is a role or the admin group"); } final GroupManager serviceImpl = getService(); return serviceImpl.update(group); }
private List<Group> createTestGroups(String namePrefix, int size) { List<Group> groups = new LinkedList<Group>(); for (int x = 0; x < size; x++) { Group group = mock(Group.class); when(group.getName()).thenReturn(namePrefix + x); groups.add(group); } return groups; } }
private List<org.jboss.errai.security.shared.api.Group> mockGroups( String... names ) { ArrayList<org.jboss.errai.security.shared.api.Group> groups = new ArrayList<org.jboss.errai.security.shared.api.Group>(); for ( String name : names ) { org.jboss.errai.security.shared.api.Group g = mock( org.jboss.errai.security.shared.api.Group.class ); when( g.getName() ).thenReturn( name ); groups.add( g ); } return groups; } }
private void assertGroup(Group group, String name) { assertNotNull(group); assertEquals(name, group.getName()); }
public void write(Group group, PermissionCollection permissions, Map out) { for (Permission p : permissions.collection()) { boolean granted = p.getResult() != null && p.getResult().equals(AuthorizationResult.ACCESS_GRANTED); String key = GROUP + "." + group.getName() + "." + PERMISSION + "." + p.getName(); out.put(key, Boolean.toString(granted)); } }
@Test(expected = UnsupportedServiceCapabilityException.class) public void testUpdateGroup() { Group group = mock(Group.class); when(group.getName()).thenReturn("role10"); groupsPropertiesManager.update(group); }
@Test public void testValid() { final Group group = mock(Group.class); when(group.getName()).thenReturn("group1"); Set<ConstraintViolation<Group>> violations = new GroupValidatorTestImpl().validate(group); assertTrue(violations.isEmpty()); }
@Test public void testBlankGroupName() { final Group blankGroup = mock(Group.class); when(blankGroup.getName()).thenReturn(""); final Set<ConstraintViolation<Group>> violations1 = new GroupValidatorTestImpl().validate(blankGroup); assertTrue(violations1.size() == 1); final ConstraintViolation<Group> violation = violations1.iterator().next(); assertEquals(violation.getPropertyPath().iterator().next().getName(), "name"); assertEquals(violation.getMessage(), GroupValidator.KEY_NAME_NOT_EMPTY); }
protected void setDirty(final boolean isDirty) { this.isDirty = isDirty; view.setSaveButtonVisible(isDirty); view.setSaveButtonEnabled(isDirty); view.setCancelButtonVisible(true); if (isDirty) { view.showNotification(UsersManagementWidgetsConstants.INSTANCE.groupModified(group.getName())); } else { view.clearNotifications(); } }
private void assertGet(String name) { Group group = groupsPropertiesManager.get(name); assertNotNull(group); assertEquals(group.getName(), name); }
@Test public void testCreateGroup() { final String testId = "id1"; final Group group = SecurityManagementUtils.createGroup(testId); assertNotNull(group); final String name = group.getName(); assertEquals(name, testId); }