/** * Get an array of all of the special groups that current user is a member * of. * * @return list of groups * @throws SQLException if database error */ public List<Group> getSpecialGroups() throws SQLException { List<Group> myGroups = new ArrayList<Group>(); for (UUID groupId : specialGroups) { myGroups.add(EPersonServiceFactory.getInstance().getGroupService().find(this, groupId)); } return myGroups; }
/** * constructor, which just creates and object with a ready context * * @throws Exception if error */ protected CreateAdministrator() throws Exception { context = new Context(); groupService = EPersonServiceFactory.getInstance().getGroupService(); ePersonService = EPersonServiceFactory.getInstance().getEPersonService(); }
/** * Initialize an IP authenticator, reading in the configuration. Note this * will never fail if the configuration is bad -- a warning will be logged. */ public IPAuthentication() { ipMatchers = new ArrayList<IPMatcher>(); ipNegativeMatchers = new ArrayList<IPMatcher>(); ipMatcherGroupIDs = new HashMap<>(); ipMatcherGroupNames = new HashMap<>(); groupService = EPersonServiceFactory.getInstance().getGroupService(); clientInfoService = CoreServiceFactory.getInstance().getClientInfoService(); List<String> propNames = DSpaceServicesFactory.getInstance().getConfigurationService() .getPropertyKeys("authentication-ip"); for (String propName : propNames) { String[] nameParts = propName.split("\\."); if (nameParts.length == 2) { addMatchers(nameParts[1], DSpaceServicesFactory.getInstance().getConfigurationService().getArrayProperty(propName)); } else { log.warn("Malformed configuration property name: " + propName); } } }
.getProperty("authentication-password.login.specialgroup"); if ((groupName != null) && (!groupName.trim().equals(""))) { Group specialGroup = EPersonServiceFactory.getInstance().getGroupService() .findByName(context, groupName); if (specialGroup == null) {
List<Group> groupList = EPersonServiceFactory.getInstance().getGroupService() .allMemberGroups(context, context.getCurrentUser());
.getAuthorities(); for (SimpleGrantedAuthority grantedAuthority : specialGroups) { context.setSpecialGroup(EPersonServiceFactory.getInstance().getGroupService() .findByName(context, grantedAuthority.getAuthority()) .getID());
/** * add an anonymous group permission policy to the collection for this * action */ private static void addAnonymousPolicy(Context c, DSpaceObject t, int myaction) throws SQLException, AuthorizeException { // group 0 is the anonymous group! Group anonymousGroup = EPersonServiceFactory.getInstance().getGroupService().findByName(c, Group.ANONYMOUS); // now create the default policies for submitted items ResourcePolicyService resourcePolicyService = AuthorizeServiceFactory.getInstance().getResourcePolicyService(); ResourcePolicy myPolicy = resourcePolicyService.create(c); myPolicy.setdSpaceObject(t); myPolicy.setAction(myaction); myPolicy.setGroup(anonymousGroup); resourcePolicyService.update(c, myPolicy); } }
.createOrModifyPolicy(null, context, null, EPersonServiceFactory.getInstance() .getGroupService() .findByName(context, Group.ANONYMOUS), null, embargoDate, Constants.READ, reason, dso);
@Override public void initDefaultGroupNames(Context context) throws SQLException, AuthorizeException { GroupService groupService = EPersonServiceFactory.getInstance().getGroupService(); // Check for Anonymous group. If not found, create it Group anonymousGroup = groupService.findByName(context, Group.ANONYMOUS); if (anonymousGroup == null) { anonymousGroup = groupService.create(context); anonymousGroup.setName(Group.ANONYMOUS); anonymousGroup.setPermanent(true); groupService.update(context, anonymousGroup); } // Check for Administrator group. If not found, create it Group adminGroup = groupService.findByName(context, Group.ADMIN); if (adminGroup == null) { adminGroup = groupService.create(context); adminGroup.setName(Group.ADMIN); adminGroup.setPermanent(true); groupService.update(context, adminGroup); } }