New method added as an alternative of getUserFromUniqueId method of WSSecurityPropagationHelper
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);
        }
    }
485770
private String getAccessId(WSCredential cred) {
        String accessId = null;
        try {
            accessId = cred.getAccessId();
        } catch (CredentialExpiredException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Caught exception getting the access id: " + e);
            }
        } catch (CredentialDestroyedException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Caught exception getting the access id: " + e);
            }
        }
        // TODO if ignoreCase is Collection, then lower case the accessid
        return accessId;
    }
98275
void getUserSessionKey(byte[] challenge, byte[] dest, int offset) throws SmbException {
        if (hashesExternal) return;
        try {
            MD4 md4 = new MD4();
            md4.update(password.getBytes(SmbConstants.UNI_ENCODING)); 
            switch (LM_COMPATIBILITY) {
            case 0:
            case 1:
            case 2:
                md4.update(md4.digest()); 
                md4.digest(dest, offset, 16); 
                break; 
            case 3:
            case 4:
            case 5:
                if( clientChallenge == null ) {
                    clientChallenge = new byte[8];
                    RANDOM.nextBytes( clientChallenge );
                }

                HMACT64 hmac = new HMACT64(md4.digest());
                hmac.update(username.toUpperCase().getBytes(
                        SmbConstants.UNI_ENCODING));
                hmac.update(domain.toUpperCase().getBytes(
                        SmbConstants.UNI_ENCODING));
                byte[] ntlmv2Hash = hmac.digest();
                hmac = new HMACT64(ntlmv2Hash);
                hmac.update(challenge);
                hmac.update(clientChallenge); 
                HMACT64 userKey = new HMACT64(ntlmv2Hash); 
                userKey.update(hmac.digest()); 
                userKey.digest(dest, offset, 16); 
                break; 
            default: 
                md4.update(md4.digest()); 
                md4.digest(dest, offset, 16); 
                break; 
            } 
        } catch (Exception e) {
            throw new SmbException("", e);
        }
    }
1035389
private static String checkUserIdentifier(final FormItemList formItemList,
			final CreateUserResponse createUserResponse) {
		final String userId = formItemList
				.getField(ProtocolConstants.Parameters.Create.User.USER_IDENTIFIER);
		if (userId != null) {
			final Node user = NeoUtils.getUserByIdentifier(userId);
			if (user == null) {
				return userId;
			}

			createUserResponse.userIdentifierInvalid(userId);
		} else {
			createUserResponse.userIdentifierMissing();
		}

		return null;
	}
969803
private void removeEntryFromAuthCacheForUser(HttpServletRequest req, HttpServletResponse res) {
        getAuthCacheService();
        if (authCacheService == null) {
            return;
        }
        String user = req.getRemoteUser();
        if (user == null) {
            Principal p = req.getUserPrincipal();
            if (p != null)
                user = p.getName();
        }
        if (user != null) {
            if (collabUtils != null) {
                String realm = collabUtils.getUserRegistryRealm(securityServiceRef);
                if (!user.contains(realm + ":")) {
                    user = realm + ":" + user;
                }
            }
            authCacheService.remove(user);
        }
    }
1152389
@GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/id/{userId}")
    @Description("Returns the user having the given ID.")
    public PrincipalUserDto getUserById(@Context HttpServletRequest req,
        @PathParam("userId") final BigInteger userId) {
        if (userId == null || userId.compareTo(BigInteger.ZERO) < 1) {
            throw new WebApplicationException("User Id cannot be null and must be a positive non-zero number.", Status.BAD_REQUEST);
        }

        PrincipalUser remoteUser = validateAndGetOwner(req, null);
        PrincipalUser user = _uService.findUserByPrimaryKey(userId);

        if (user != null) {
            super.validateResourceAuthorization(req, user, remoteUser);
            return PrincipalUserDto.transformToDto(user);
        }
        throw new WebApplicationException(Response.Status.NOT_FOUND.getReasonPhrase(), Response.Status.NOT_FOUND);
    }
321614
public java.security.Principal getUserPrincipal()
    {
        if (WCCustomProperties.CHECK_REQUEST_OBJECT_IN_USE){
            checkRequestObjectInUse();
        }
        IWebAppSecurityCollaborator webAppSec=null;
        if (getDispatchContext()!=null && getDispatchContext().getWebApp() != null) {
            webAppSec = CollaboratorHelperImpl.getCurrentSecurityCollaborator(getDispatchContext().getWebApp());
        } else {
            webAppSec = CollaboratorHelperImpl.getCurrentSecurityCollaborator();           
        } 
            
        if (webAppSec != null) {
            if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)){  //306998.15
                logger.logp(Level.FINE, CLASS_NAME,"getUserPrincipal", "calling getUserPrincipal on " + webAppSec.getClass().getName());
            }
            return webAppSec.getUserPrincipal();
        } else {
            if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)){  //306998.15
                logger.logp(Level.FINE, CLASS_NAME,"getUserPrincipal", "returning null");
            }
            // No IWebAppSecurityCollaborator means no security, so no Principal 
            return null;
        }
    }
248196
public LdapUser getUserTemplate(String uid) {
        LdapUser user = new LdapUser(uid, this);
        user.set("dn", getDNForNode(user));
        for (String oc : userObjectClasses) {
            user.addObjectClass(oc.trim());
        }
        user = (LdapUser) updateObjectClasses(user);

        // TODO this needs to be cleaner :-/.
        // for inetOrgPerson
        if (user.getObjectClasses().contains("inetOrgPerson")
                || user.getObjectClasses().contains("person")) {
            user.set("sn", uid);
        }

        // for JabberAccount
        if (user.getObjectClasses().contains("JabberAccount")) {
            user.set("jabberID", uid + "@" + defaultValues.get("jabberServer"));
            user.set("jabberAccess", "TRUE");
        }

        // for posixAccount
        if (user.getObjectClasses().contains("posixAccount")) {
            user.set("uidNumber", "99999");
            user.set("gidNumber", "99999");
            user.set("cn", uid);
            user.set("homeDirectory", "/dev/null");
        }

        // for ldapPublicKey
        if (user.getObjectClasses().contains("ldapPublicKey")) {
            user.set("sshPublicKey", defaultValues.get("sshKey"));
        }

        return user;
    }
1198317
private OAuthHmacCredential new10aCredential(String userId) {
        ClientParametersAuthentication clientAuthentication = (ClientParametersAuthentication) getClientAuthentication();
        OAuthHmacCredential.Builder builder =
                new OAuthHmacCredential.Builder(getMethod(), clientAuthentication.getClientId(),
                        clientAuthentication.getClientSecret())
                        .setTransport(getTransport())
                        .setJsonFactory(getJsonFactory())
                        .setTokenServerEncodedUrl(getTokenServerEncodedUrl())
                        .setClientAuthentication(getClientAuthentication())
                        .setRequestInitializer(getRequestInitializer())
                        .setClock(getClock());
        if (getCredentialStore() != null) {
            builder.addRefreshListener(
                    new CredentialStoreRefreshListener(userId, getCredentialStore()));
        }

        builder.getRefreshListeners().addAll(getRefreshListeners());

        return builder.build();
    }
146944
private Node getProfileNode(Node userNode) throws RepositoryException
   {
      try
      {
         return userNode.getNode(JCROrganizationServiceImpl.JOS_PROFILE);
      }
      catch (PathNotFoundException e)
      {
         return userNode.addNode(JCROrganizationServiceImpl.JOS_PROFILE);
      }
   }
227639
@Override
  public UserGroupInformation getProxiedUser(final Props userProp)
      throws HadoopSecurityManagerException {
    final String userToProxy = verifySecureProperty(userProp, JobProperties.USER_TO_PROXY);
    final UserGroupInformation user = getProxiedUser(userToProxy);
    if (user == null) {
      throw new HadoopSecurityManagerException(
          "Proxy as any user in unsecured grid is not supported!");
    }
    return user;
  }
231030
private static UserIdentifier createUserIdentifier(
      OfflineDataUploadUserIdentifierType identifierType, String value)
      throws UnsupportedEncodingException {
    // If the user identifier type is a hashed type, also call hash function
    // on the value.
    if (HASHED_IDENTIFIER_TYPES.contains(identifierType)) {
      value = toSHA256String(value);
    }
    UserIdentifier userIdentifier = new UserIdentifier();
    userIdentifier.setUserIdentifierType(identifierType);
    userIdentifier.setValue(value);
    return userIdentifier;
  }
869394
@Override
    public IPersonAttributes getOriginalUserAttributes(String uid) {
        final IPersonAttributeDao delegatePersonAttributeDao =
                this.portalRootPersonAttributeDao.getDelegatePersonAttributeDao();
        return delegatePersonAttributeDao.getPerson(uid);
    }
1168299
@Deprecated
    private <T> java.security.Identity (EJBSecurityCollaborator<T> collaborator, EJSDeployedSupport s)
    {
        @SuppressWarnings("unchecked")
        T uncheckedCookie = s == null ? null : (T) s.securityCookie;
        return collaborator.(home.beanMetaData, s, uncheckedCookie);
    }
336792
@Override
    public com.ibm.websphere.security.UserRegistry getExternalUserRegistry(UserRegistry userRegistry) {
        if (userRegistry instanceof ExternalUserRegistryWrapper) {
            return ((ExternalUserRegistryWrapper) userRegistry).getExternalUserRegistry();
        }
        return new UserRegistryWrapper(userRegistry);
    }
489921
function(userId) {
    var self = this;

    if (userId !== null && typeof userId !== "string")
      throw new Error("setUserId must be called on string or null, not " +
                      typeof userId);

    // Prevent newly-created universal subscriptions from being added to our
    // session; they will be found below when we call startUniversalSubs.
    //
    // (We don't have to worry about named subscriptions, because we only add
    // them when we process a 'sub' message. We are currently processing a
    // 'method' message, and the method did not unblock, because it is illegal
    // to call setUserId after unblock. Thus we cannot be concurrently adding a
    // new named subscription.)
    self._dontStartNewUniversalSubs = true;

    // Prevent current subs from updating our collectionViews and call their
    // stop callbacks. This may yield.
    self._eachSub(function (sub) {
      sub._deactivate();
    });

    // All subs should now be deactivated. Stop sending messages to the client,
    // save the state of the published collections, reset to an empty view, and
    // update the userId.
    self._isSending = false;
    var beforeCVs = self.collectionViews;
    self.collectionViews = {};
    self.userId = userId;

    // Save the old named subs, and reset to having no subscriptions.
    var oldNamedSubs = self._namedSubs;
    self._namedSubs = {};
    self._universalSubs = [];

    _.each(oldNamedSubs, function (sub, subscriptionId) {
      self._namedSubs[subscriptionId] = sub._recreate();
      // nb: if the handler throws or calls this.error(), it will in fact
      // immediately send its 'nosub'. This is OK, though.
      self._namedSubs[subscriptionId]._runHandler();
    });

    // Allow newly-created universal subs to be started on our connection in
    // parallel with the ones we're spinning up here, and spin up universal
    // subs.
    self._dontStartNewUniversalSubs = false;
    self.startUniversalSubs();

    // Start sending messages again, beginning with the diff from the previous
    // state of the world to the current state. No yields are allowed during
    // this diff, so that other changes cannot interleave.
    Meteor._noYieldsAllowed(function () {
      self._isSending = true;
      self._diffCollectionViews(beforeCVs);
      if (!_.isEmpty(self._pendingReady)) {
        self.sendReady(self._pendingReady);
        self._pendingReady = [];
      }
    });
  }
61297
public static String getUniqueId(String accessId, String realm) {
    
        if (realm != null) {
            Pattern pattern = Pattern.compile("([^:]+):(" + Pattern.quote(realm) + ")/(.*)");
            Matcher m = pattern.matcher(accessId);
            if (m.matches()) {
                if (m.group(3).length() > 0) {
                    return m.group(3);
                }
            }
        }
        // if there is no match, fall back.
        return getUniqueId(accessId);
    }