Compare two instances of Credentials.
@param c1 instance of Credentials
@param c2 another instance of Credentials
@return comparison result. {@code true} if both are null or contain same user/password pairs, false otherwise.
325083
private static boolean areSame(Credentials c1, Credentials c2) {
        if (c1 == null) {
            return c2 == null;
        } else {
            return StringUtils.equals(c1.getUserPrincipal().getName(), c1.getUserPrincipal().getName()) &&
                    StringUtils.equals(c1.getPassword(), c1.getPassword());
        }
    }
1237240
public static boolean areEqual(@Nullable SHA256Digest first, @Nullable SHA256Digest second) {
		if (first == null) {
			return second == null;
		}
		if (second == null) {
			return false;
		}
		return Arrays.equals(first.getEncodedState(), second.getEncodedState());
	}
123597
public int compare(final SnomedConcept o1, final SnomedConcept o2) {
        if (o1 == o2) return 0;
        if (o1 != null) {
            if (o2 == null) return 1;
                // need to use BigInteger to compare SNOMED codes since some are fantastically long
            else return new BigInteger(o1.snomedId)
                    .compareTo(new BigInteger(o2.snomedId));
        }
        return -1;
    }
630557
public static UserDto fromUser(User user, boolean isIncludeCredentials) {
    UserDto userDto = new UserDto();
    userDto.setProfile(UserProfileDto.fromUser(user));
    if(isIncludeCredentials) {
      userDto.setCredentials(UserCredentialsDto.fromUser(user));
    }
    return userDto;
  }
90364
public static boolean isEqualIgnoringCaseAndUnderscores(@NotNull String s1, @NotNull String s2) {
        int index1 = 0;
        int index2 = 0;
        int length1 = s1.length();
        int length2 = s2.length();

        while (index1 < length1 && index2 < length2) {
            char nameChar = s1.charAt(index1++);
            if (nameChar == '_') continue;

            char memberNameChar = s2.charAt(index2++);
            if (memberNameChar == '_') {
                index1--;
                continue;
            }

            if (toLowerCase(nameChar) != toLowerCase(memberNameChar))
                return false;
        }

        // Skip trailing underscores
        while (index1 < length1 && s1.charAt(index1) == '_') index1++;
        while (index2 < length2 && s2.charAt(index2) == '_') index2++;

        return index1 == length1 && index2 == length2;
    }
1227110
public Credentials userSignUp(Credentials credentials) throws DAOException{
        if (getUserByEmail(dao,credentials.getEmailAddress())!=null){
            throw new DAOException(HttpStatus.SC_CONFLICT,"User Already Exists");
        }
        ServerCredentials toSave = new ServerCredentials(credentials);

        toSave.decryptPassword(keyManager.getPrivateKey()); //decrypt the password
        String de = toSave.getPassword();
        String ha = BCrypt.hashpw(de, BCrypt.gensalt(10));

        toSave.setOwnerId(dao.count(Credentials.class.getName()) + 1);
        toSave.setPassword(ha); //hash the password for storage
        toSave.setAuthToken(AuthTokenUtils.getNewToken(keyManager.getSymmetricKey(), toSave));
        toSave.setRecoveryToken(AuthTokenUtils.getNewToken(keyManager.getSymmetricKey(), toSave));

        dao.save(toSave);

        return toSave;
    }
407779
public boolean hasValidCredentials() {
        String accessToken = storage.retrieveString(KEY_ACCESS_TOKEN);
        String refreshToken = storage.retrieveString(KEY_REFRESH_TOKEN);
        String idToken = storage.retrieveString(KEY_ID_TOKEN);
        Long expiresAt = storage.retrieveLong(KEY_EXPIRES_AT);

        return !(isEmpty(accessToken) && isEmpty(idToken) ||
                expiresAt == null ||
                expiresAt <= getCurrentTimeInMillis() && refreshToken == null);
    }
928067
@Override
    public IOpaqueCredentials getOpaqueCredentials() {
        if (parentContext != null && parentContext.isAuthenticated()) {
            NotSoOpaqueCredentials oc = new CacheOpaqueCredentials();
            oc.setCredentials(this.cachedcredentials);
            return oc;
        } else return null;
    }
720707
private static boolean isComparable(CompleteTransactionTask c1, CompleteTransactionTask c2) {
        return c1.getMsgTxnId() == c2.getMsgTxnId() &&
                MpRestartSequenceGenerator.isForRestart(c1.getTimestamp()) ==
                MpRestartSequenceGenerator.isForRestart(c2.getTimestamp());
    }
684219
public Session login(Credentials credentials) throws LoginException, NoSuchWorkspaceException, RepositoryException
   {
      return delegatee.login(credentials);
   }
421387
protected boolean verifyCondition1(IContextMapping<INode> mapping, IMappingElement<INode> e) {
        return findRelation(IMappingElement.LESS_GENERAL, e.getSource().getAncestors(), e.getTarget(), mapping) ||
                findRelation(IMappingElement.EQUIVALENCE, e.getSource().getAncestors(), e.getTarget(), mapping) ||

                findRelation(IMappingElement.LESS_GENERAL, e.getSource(), e.getTarget().getDescendants(), mapping) ||
                findRelation(IMappingElement.EQUIVALENCE, e.getSource(), e.getTarget().getDescendants(), mapping) ||

                findRelation(IMappingElement.LESS_GENERAL, e.getSource().getAncestors(), e.getTarget().getDescendants(), mapping) ||
                findRelation(IMappingElement.EQUIVALENCE, e.getSource().getAncestors(), e.getTarget().getDescendants(), mapping);
    }
163306
public static Credential getCredential(final RequestContext context) {
        val cFromRequest = (Credential) context.getRequestScope().get(PARAMETER_CREDENTIAL);
        val cFromFlow = (Credential) context.getFlowScope().get(PARAMETER_CREDENTIAL);
        val cFromConversation = (Credential) context.getConversationScope().get(PARAMETER_CREDENTIAL);

        var credential = cFromRequest;
        if (credential == null || StringUtils.isBlank(credential.getId())) {
            credential = cFromFlow;
        }
        if (credential == null || StringUtils.isBlank(credential.getId())) {
            credential = cFromConversation;
            if (credential != null && !StringUtils.isBlank(credential.getId())) {
                context.getFlowScope().put(PARAMETER_CREDENTIAL, credential);
            }
        }

        if (credential == null) {
            val session = context.getFlowExecutionContext().getActiveSession();
            credential = session.getScope().get(PARAMETER_CREDENTIAL, Credential.class);
        }
        if (credential != null && StringUtils.isBlank(credential.getId())) {
            return null;
        }
        return credential;
    }
1152557
@Override
    public int compare(GregorianCalendar c1, GregorianCalendar c2) {
        if (c2.getGregorianChange() == null) {
            return (int) (c1.getTime().getTime() - c2.getTime().getTime());
        } else {
            return 0;
        }
    }
420980
function comparePassword(candidatePassword, callback) {
  bcrypt.compare(candidatePassword, this.password, (err, isMatch) => {
    if (err) {
      return callback(err);
    }

    callback(null, isMatch);
  });
}
103606
public static <T extends Credential> T getCredential(final RequestContext context, final @NonNull Class<T> clazz) {
        val credential = getCredential(context);
        if (credential == null) {
            return null;
        }
        if (!clazz.isAssignableFrom(credential.getClass())) {
            throw new ClassCastException("credential [" + credential.getId()
                + " is of type " + credential.getClass()
                + " when we were expecting " + clazz);
        }
        return (T) credential;
    }
1112628
protected void validateCredentials(final UsernamePasswordCredentials credentials,
                                       final OAuthRegisteredService registeredService,
                                       final WebContext context) {
        if (!OAuth20Utils.checkClientSecret(registeredService, credentials.getPassword())) {
            throw new CredentialsException("Bad secret for client identifier: " + credentials.getPassword());
        }
    }
46137
boolean validatePasswords(String password1, String password2) {

        if (!password1.equals(password2)) {
            showPasswordMatchError(true);
            return false;
        }
        showPasswordMatchError(false);
        try {
            OpenCms.getPasswordHandler().validatePassword(password1);
            m_form.getPassword1Field().setComponentError(null);
            return true;
        } catch (CmsException e) {
            m_form.setErrorPassword1(new UserError(e.getLocalizedMessage(m_locale)), OpenCmsTheme.SECURITY_INVALID);
            return false;
        }
    }