public User toUser(final String providerName) { Set<JaxbRole> roleSet = new HashSet<JaxbRole>(); for (JpaRole role : roles) { roleSet.add(JaxbRole.fromRole(role)); } return new JaxbUser(username, null, name, email, providerName, JaxbOrganization.fromOrganization(organization), roleSet); }
@Override public Iterator<User> findUsers(String query, int offset, int limit) { if (query == null) throw new IllegalArgumentException("Query must be set"); if (query.endsWith("%")) { query = query.substring(0, query.length() - 1); } if (query.isEmpty()) { return Collections.emptyIterator(); } // Verify if a user exists (non-wildcard searches only) if (!verifySakaiUser(query)) { return Collections.emptyIterator(); } List<User> users = new LinkedList<User>(); JaxbOrganization jaxbOrganization = JaxbOrganization.fromOrganization(organization); JaxbUser queryUser = new JaxbUser(query, PROVIDER_NAME, jaxbOrganization, new HashSet<JaxbRole>()); users.add(queryUser); return users.iterator(); }
User user = new JaxbUser(userName, null, displayName, email, PROVIDER_NAME, true, jaxbOrganization, roles);
/** * Create the global anonymous user with the given organization. * * @param org * the organization * @return the global anonymous user */ public static User createAnonymousUser(Organization org) { JaxbOrganization jaxbOrganization = JaxbOrganization.fromOrganization(org); return new JaxbUser(GLOBAL_ANONYMOUS_USERNAME, null, jaxbOrganization, new JaxbRole( jaxbOrganization.getAnonymousRole(), jaxbOrganization)); }
return new JaxbUser(moodleUser.getUsername(), null, moodleUser.getFullname(), moodleUser.getEmail(), this.getName(), true, jaxbOrganization, roles); } catch (Exception e) {
user = new JaxbUser(userDetails.getUsername(), null, jaxbOrganization, roles); } else {
/** * Create a system user for the given organization with global and organization local admin role. Get the * <code>systemUserName</code> from the global config where it is stored under {@link #PROPERTY_KEY_SYS_USER}. In an * OSGi environment this is typically done calling * <code>componentContext.getBundleContext().getProperty(PROPERTY_KEY_SYS_USER)</code>. * * @see #createSystemUser(org.osgi.service.component.ComponentContext, org.opencastproject.security.api.Organization) */ public static User createSystemUser(String systemUserName, Organization org) { JaxbOrganization jaxbOrganization = JaxbOrganization.fromOrganization(org); return new JaxbUser(systemUserName, null, jaxbOrganization, new JaxbRole(GLOBAL_ADMIN_ROLE, jaxbOrganization), new JaxbRole(org.getAdminRole(), jaxbOrganization)); }
/** * Creates a JAXB user from a regular user object with an additional set of roles. * * @param user * the user * @return the JAXB user */ public static JaxbUser fromUser(User user, Collection<? extends Role> extraRoles) { Set<JaxbRole> roles = new HashSet<JaxbRole>(); for (Role role : user.getRoles()) { roles.add(JaxbRole.fromRole(role)); } for (Role role : extraRoles) { roles.add(JaxbRole.fromRole(role)); } JaxbUser jaxbUser = new JaxbUser(user.getUsername(), user.getPassword(), user.getName(), user.getEmail(), user.getProvider(), user.canLogin(), JaxbOrganization.fromOrganization(user.getOrganization()), roles); jaxbUser.setManageable(user.isManageable()); return jaxbUser; }
requestedUser = new JaxbUser(requestedUser.getUsername(), requestedUser.getPassword(), requestedUser.getName(), requestedUser.getEmail(), requestedUser.getProvider(), requestedUser.canLogin(), JaxbOrganization.fromOrganization(requestedUser.getOrganization()),