Links the current user Identity to another

@param current The Identity of the current user
@param to The Identity that needs to be linked to the current user
12589
@Override
    public Future<U> link(U current, BasicProfile to) {
        return toScala(doLink(current, to));
    }
865633
public void addTo(String to) {
        if (this.to.length() > 0) {
            this.to.append(",");
        }
        this.to.append(to);
    }
776592
public void setLinkedId(Long i) {
        if ((i == null) || (i < -128 || i > 127)) {
            throw new IllegalArgumentException("Invoke ID our of range: <-128,127>: " + i);
        }
        this.linkedId = i;
    }
1231691
public void setUser(User user) {
		this.user = user;
		if (httpSender != null) {
			httpSender.setUser(user);
		}
	}
142349
@Override
    public boolean updateValuesForField(String currentValue) {
        boolean bUpdated = false;
        bUpdated |= updateLinkRemoveValues();
        bUpdated |= updateLinkAddValues();
        return bUpdated;
    }
104765
def _linkUser(self, user):
        
        KEY = "linked_contact_uid"

        username = user.getId()
        contact = self.getContactByUsername(username)

        # User is linked to another contact (fix in UI)
        if contact and contact.UID() != self.UID():
            raise ValueError("User '{}' is already linked to Contact '{}'"
                             .format(username, contact.Title()))

        # User is linked to multiple other contacts (fix in Data)
        if isinstance(contact, list):
            raise ValueError("User '{}' is linked to multiple Contacts: '{}'"
                             .format(username, ",".join(
                                 map(lambda x: x.Title(), contact))))

        # XXX: Does it make sense to "remember" the UID as a User property?
        tool = user.getTool()
        try:
            user.getProperty(KEY)
        except ValueError:
            logger.info("Adding User property {}".format(KEY))
            tool.manage_addProperty(KEY, "", "string")

        # Set the UID as a User Property
        uid = self.UID()
        user.setMemberProperties({KEY: uid})
        logger.info("Linked Contact UID {} to User {}".format(
            user.getProperty(KEY), username))

        # Set the Username
        self.setUsername(user.getId())

        # Update the Email address from the user
        self.setEmailAddress(user.getProperty("email"))

        # somehow the `getUsername` index gets out of sync
        self.reindexObject()

        # N.B. Local owner role and client group applies only to client
        #      contacts, but not lab contacts.
        if IClient.providedBy(self.aq_parent):
            # Grant local Owner role
            self._addLocalOwnerRole(username)
            # Add user to "Clients" group
            self._addUserToGroup(username, group="Clients")

        return True
1361931
public void setUser(final String user) {
        final String old = this.user;

        this.user = user;
        this.connectionConfig = System.currentTimeMillis();
        this.connectionValidated = false;

        this.pcs.firePropertyChange("user", old, this.user);
    }
9491
public void addIdentity(Identity identity) {
        identities.add(identity);
        identitiesSet.add(identity.getKey());
    }
1232146
@Override
  public void createIdentityLinkComment(String taskId, String userId, String groupId, String type, boolean create) {
    createIdentityLinkComment(taskId, userId, groupId, type, create, false);
  }
747798
@Override
    @Path("/{roleName}/users/{cuid}")
    @ApiOperation(value="Create a role or add a user to an existing role",
        notes="If users/{cuid} is present, user is added to role.", response=StatusMessage.class)
    @ApiImplicitParams({
        @ApiImplicitParam(name="Workgroup", paramType="body", dataType="com.centurylink.mdw.model.user.Role")})
    public JSONObject post(String path, JSONObject content, Map<String,String> headers)
    throws ServiceException, JSONException {
        String name = getSegment(path, 1);
        String rel = getSegment(path, 2);

        UserServices userServices = ServiceLocator.getUserServices();
        try {
            Role existing = userServices.getRoles().get(name);

            if (rel == null) {
                if (existing != null)
                    throw new ServiceException(HTTP_409_CONFLICT, "Role name already exists: " + name);
                Role role = new Role(content);
                userServices.createRole(role);
            }
            else if (rel.equals("users")) {
                String cuid = getSegment(path, 3);
                User user = UserGroupCache.getUser(cuid);
                if (user == null) {
                    throw new CachingException("Cannot find user: " + cuid);
                }
                if (user.hasRole(name))  // in case added elsewhere
                    throw new ServiceException(HTTP_409_CONFLICT, "User " + cuid + " already has role " + name);

                userServices.addUserToRole(cuid, name);
            }
            else {
                String msg = "Unsupported relationship for role " + name + ": " + rel;
                throw new ServiceException(HTTP_400_BAD_REQUEST, msg);
            }
            return null;
        }
        catch (DataAccessException ex) {
            throw new ServiceException(HTTP_500_INTERNAL_ERROR, ex.getMessage(), ex);
        }
        catch (CachingException ex) {
            throw new ServiceException(HTTP_500_INTERNAL_ERROR, ex.getMessage(), ex);
        }
    }
1289785
public void identity_user_user_DELETE(String user) throws IOException {
		String qPath = "/me/identity/user/{user}";
		StringBuilder sb = path(qPath, user);
		exec(qPath, "DELETE", sb.toString(), null);
	}
1262320
public static void setCurrentAuthentication(Authentication authentication) {
        RequestContext context = RequestContext.getCurrent();
        if (context != null) {
            setAuthentication(context.getRequest(), authentication);
        }
    }
1268828
@Override
  public void recordIdentityLinkCreated(IdentityLinkEntity identityLink) {
    // It makes no sense storing historic counterpart for an identity-link
    // that is related
    // to a process-definition only as this is never kept in history
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT) && (identityLink.getProcessInstanceId() != null || identityLink.getTaskId() != null)) {
      HistoricIdentityLinkEntity historicIdentityLinkEntity = getHistoricIdentityLinkEntityManager().create();
      historicIdentityLinkEntity.setId(identityLink.getId());
      historicIdentityLinkEntity.setGroupId(identityLink.getGroupId());
      historicIdentityLinkEntity.setProcessInstanceId(identityLink.getProcessInstanceId());
      historicIdentityLinkEntity.setTaskId(identityLink.getTaskId());
      historicIdentityLinkEntity.setType(identityLink.getType());
      historicIdentityLinkEntity.setUserId(identityLink.getUserId());
      getHistoricIdentityLinkEntityManager().insert(historicIdentityLinkEntity, false);
    }
  }
428651
public GetOfferingStatusResult withCurrent(java.util.Map<String, OfferingStatus> current) {
        setCurrent(current);
        return this;
    }
619275
private Persona establishOwner(org.hawkular.accounts.api.model.Resource resource, Persona current) {
        while (resource != null && resource.getPersona() == null) {
            resource = resource.getParent();
        }

        if (resource != null && resource.getPersona().equals(current)) {
            current = null;
        }

        return current;
    }
707972
@SuppressWarnings("unchecked")
  public void addPersistentLinkData(HashMap hm)
  {
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "addPersistentLinkData", hm);

      // For a linkHandler, we store
     // 
     //    * The uuid of the link
     //    * The name of the link
     //    * The busName at the other end of the link
     //
      
     // The uuid of the destination
     hm.put("uuid",_uuid.toByteArray());

     // The name of the destination
     hm.put("name", _name); 
     
     // The name of the bus at the other end of the link
     hm.put("busName", _busName);
     
     // Is the destination localised on the home ME
     hm.put("hasLocal", new Boolean(hasLocal()));
           
     hm.put("type", _type);
     hm.put( "inboundUserid", _inboundUserid);  
     hm.put( "outboundUserid", _outboundUserid);  
     hm.put( "TBD", new Boolean(isToBeDeleted()));       
           
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "addPersistentLinkData");
  }
624218
function _linkIdentity(userId, key, socialUserInfo, creds) {
    var identityOptions = {
            id: socialUserInfo.id_str,
            screen_name: socialUserInfo.screen_name,
            accessToken: creds.oauth_token,
            accessSecret: creds.oauth_token_secret
        };

    return db.users.linkIdentity(userId, key, identityOptions);
}