a global user that exists already in service, but not in web
490095
public function sendGlobalUserActivated()
    {
        if ($this->_sendMails) {
            $row = $this->getModel()->getKwfUserRowById($this->id);
            $mail = new Kwf_User_Mail_GlobalUserActivated($row);
            $mail->send();
            $this->writeLog('user_mail_GlobalUserActivation');
        }
    }
259077
def AddUser(self, uid, username, active):
    '''
    '''
    user_path = '/org/freedesktop/login1/user/%i' % uid
    if user_path in mockobject.objects:
        raise dbus.exceptions.DBusException('User %i already exists' % uid,
                                            name=MOCK_IFACE + '.UserExists')

    self.AddObject(user_path,
                   'org.freedesktop.login1.User',
                   {
                       'Sessions': dbus.Array([], signature='(so)'),
                       'IdleHint': False,
                       'DefaultControlGroup': 'systemd:/user/' + username,
                       'Name': username,
                       'RuntimePath': '/run/user/%i' % uid,
                       'Service': '',
                       'State': (active and 'active' or 'online'),
                       'Display': ('', dbus.ObjectPath('/')),
                       'UID': dbus.UInt32(uid),
                       'GID': dbus.UInt32(uid),
                       'IdleSinceHint': dbus.UInt64(0),
                       'IdleSinceHintMonotonic': dbus.UInt64(0),
                       'Timestamp': dbus.UInt64(42),
                       'TimestampMonotonic': dbus.UInt64(42),
                   },
                   [
                       ('Kill', 's', '', ''),
                       ('Terminate', '', '', ''),
                   ])

    return user_path
1133987
def filter_factory(global_conf, **local_conf):
    """"""
    conf = global_conf.copy()
    conf.update(local_conf)

    def auth_filter(app):
        return Swauth(app, conf)
    return auth_filter
491600
function(user) {
                console.log('oauthInterface.user.create', user);

                return this.request({
                        url: this._buildUri(this.uri),
                        method: corbel.request.method.POST,
                        headers: {
                            Authorization: 'Basic ' + this.getSerializer()(this.clientId + ':' + this.clientSecret)
                        },
                        dataType: 'text',
                        data: user
                    })
                    .then(function(res) {
                        return corbel.Services.getLocationId(res);
                    });
            }
921390
def migrate_user(instance):
    
    instance._resource.pop('verified', None)

    if 'role' in instance._resource:
        return instance

    global_org = instance.organisations.pop('global', {})
    instance.role = global_org.get('role', perch.User.roles.default.value)

    return instance
1271493
private Result<NsDAO.Data> mayUserVirtueOfNS(AuthzTrans trans, String user,	NsDAO.Data nsd, String ns_and_type, String access) {
		String ns = nsd.name;

		// If an ADMIN of the Namespace, then allow
		
		Result<List<UserRoleDAO.Data>> rurd;
		if ((rurd = userRoleDAO.readUserInRole(trans, user, nsd.name+ADMIN)).isOKhasData()) {
			return Result.ok(nsd);
		} else if(rurd.status==Result.ERR_Backend) {
			return Result.err(rurd);
		}
		
		// If Specially granted Global Permission
		if (isGranted(trans, user, Define.ROOT_NS,NS, ns_and_type, access)) {
			return Result.ok(nsd);
		}

		// Check recur

		int dot = ns.length();
		if ((dot = ns.lastIndexOf('.', dot - 1)) >= 0) {
			Result<NsDAO.Data> rnsd = deriveNs(trans, ns.substring(0, dot));
			if (rnsd.isOK()) {
				rnsd = mayUserVirtueOfNS(trans, user, rnsd.value, ns_and_type,access);
			} else if(rnsd.status==Result.ERR_Backend) {
				return Result.err(rnsd);
			}
			if (rnsd.isOK()) {
				return Result.ok(nsd);
			} else if(rnsd.status==Result.ERR_Backend) {
				return Result.err(rnsd);
			}
		}
		return Result.err(Status.ERR_Denied, "%s may not %s %s", user, access,
				ns_and_type);
	}
1298225
def get_current_user(self, objectmask=None):
        """"""

        if objectmask is None:
            objectmask = "mask[userStatus[name], parent[id, username]]"
        return self.account_service.getCurrentUser(mask=objectmask)
1013330
def su(user)
      if defined?(Etc)
        pw = Etc.getpwnam(user)
        Process::initgroups(user, pw.gid)
        Process::Sys::setgid(pw.gid)
        Process::Sys::setuid(pw.uid)
      else
        warn("WEBrick::Utils::su doesn't work on this platform")
      end
    end
858842
public void handleRemoveUser(String jsonp, String target,
            HttpServletRequest request,
            HttpServletResponse response, AuthenticationResult ar)
            throws IOException, ServletException {
        try {
            DeploymentType newDeployment = CatalogUtil.getDeployment(new ByteArrayInputStream(getDeploymentBytes()));
            User user = null;
            String[] splitTarget = target.split("/");
            if (splitTarget.length == 3) {
                user = findUser(splitTarget[2], newDeployment);
            }
            if (user == null) {
                response.setStatus(HttpServletResponse.SC_NOT_FOUND);
                response.getWriter().print(buildClientResponse(jsonp, ClientResponse.UNEXPECTED_FAILURE, "User not found"));
                return;
            }
            if (newDeployment.getUsers().getUser().size() == 1) {
                newDeployment.setUsers(null);
            } else {
                newDeployment.getUsers().getUser().remove(user);
            }

            String dep = CatalogUtil.getDeployment(newDeployment);
            if (dep == null || dep.trim().length() <= 0) {
                response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
                response.getWriter().print(buildClientResponse(jsonp, ClientResponse.UNEXPECTED_FAILURE, "Failed to build deployment information."));
                return;
            }
            Object[] params = new Object[]{null, dep};
            //Call sync as nothing else can happen when this is going on.
            SyncCallback cb = new SyncCallback();
            httpClientInterface.callProcedure(request.getRemoteHost(), ar, BatchTimeoutOverrideType.NO_TIMEOUT, cb, "@UpdateApplicationCatalog", params);
            cb.waitForResponse();
            ClientResponseImpl r = ClientResponseImpl.class.cast(cb.getResponse());
            response.setStatus(HttpServletResponse.SC_NO_CONTENT);
            if (r.getStatus() == ClientResponse.SUCCESS) {
                response.getWriter().print(buildClientResponse(jsonp, ClientResponse.SUCCESS, "User Removed."));
            } else {
                response.getWriter().print(HTTPClientInterface.asJsonp(jsonp, r.toJSONString()));
            }
        } catch (Exception ex) {
            m_log.error("Failed to update role from API", ex);
            response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
            response.getWriter().print(buildClientResponse(jsonp, ClientResponse.UNEXPECTED_FAILURE, Throwables.getStackTraceAsString(ex)));
        }
    }
802628
def currentUser(extras=nil)
      method = 'currentUser'
      type = User
      args = {}
      args[:extras] = extras if extras
      return_object type,method,args,true
    end
1246751
function(newuser, newaliases) {
		console.log("setUser", newuser, newaliases);
		var oldxid = Login.user && Login.user.xid;
		if (Login.user && Login.user.xid === newuser.xid) {
			// keep old info... but newuser overrides
			newuser = $.extend({}, Login.user, newuser);
			// TODO extend aliases
		}
		// set user
		Login.user = newuser;
		// service
		if ( ! Login.user.service) {
			Login.user.service = getService(Login.user.xid);
		}
		// set aliases
		if (newaliases && newaliases.length !== 0) {
			Login.aliases = newaliases;
			assert(newaliases[0].xid, newaliases);
		} else if (newuser.xid === oldxid) {
			// leave as is
		} else {
			// aliases = just the user
			Login.aliases = [newuser];
		}
		Cookies.set(COOKIE_UXID, Login.user.xid, {path: COOKIE_PATH});
		// webtoken: set by the server
		if (oldxid != newuser.xid) {
			Login.change();
		}
	}
871298
def given_i_am_logged_in(context, username):
    
    user = get_user_model().objects.get(username=username)
    context.apiClient.force_authenticate(user=user)
621538
@Override
    @Path("/{cuid}/rel/{relId}")
    @ApiOperation(value="Create a user or add existing user to a workgroup or role",
        notes="If rel/{relId} is present, user is added to workgroup or role.", response=StatusMessage.class)
    @ApiImplicitParams({
        @ApiImplicitParam(name="Workgroup", paramType="body", dataType="com.centurylink.mdw.model.user.User")})
    public JSONObject post(String path, JSONObject content, Map<String, String> headers)
    throws ServiceException, JSONException {
        String cuid = getSegment(path, 1);
        String rel = getSegment(path, 2);

        UserServices userServices = ServiceLocator.getUserServices();
        try {
            if (rel == null) {
                User existing = userServices.getUsers().get(cuid);
                if (existing != null)
                    throw new ServiceException(HTTP_409_CONFLICT, "User ID already exists: " + cuid);
                User user = new User(content);
                userServices.createUser(user);
            }
            else if (rel.equals("workgroups")) {
                String group = getSegment(path, 3);
                userServices.addUserToWorkgroup(cuid, group);
            }
            else if (rel.equals("roles")) {
                String role = getSegment(path, 3);
                userServices.addUserToRole(cuid, role);
            }
            else {
                String msg = "Unsupported relationship for user " + cuid + ": " + rel;
                throw new ServiceException(HTTP_400_BAD_REQUEST, msg);
            }
            return null;
        }
        catch (DataAccessException ex) {
            if (ex.getCode() >= HTTP_400_BAD_REQUEST)
                throw new ServiceException(ex.getCode(), ex.getMessage(), ex);
            else
                throw new ServiceException(HTTP_500_INTERNAL_ERROR, ex.getMessage(), ex);
        }
    }
790025
function(isGlobal, server, msg, session, cb) {
  var fm;
  if(isGlobal) {
    fm = server.globalFilterService;
  } else {
    fm = server.filterService;
  }
  if(fm) {
    fm.beforeFilter(msg, session, cb);
  } else {
    utils.invokeCallback(cb);
  }
}
5652
private String getUserFromUniqueID(String id) {
        if (id == null) {
            return "";
        }
        id = id.trim();
        int realmDelimiterIndex = id.indexOf("/");
        if (realmDelimiterIndex < 0) {
            return "";
        } else {
            return id.substring(realmDelimiterIndex + 1);
        }
    }
696254
def handle_existing_user(self, provider, user, access, info):
        ""
        login(self.request, user)
        return redirect(self.get_login_redirect(provider, user, access))
136527
public void setUser(String user, boolean isSIBServerSubject)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "setUser", user);

        this.user = user;
        this.isSIBServerSubject = isSIBServerSubject;
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "setUser");
    }