Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2014 Philip Helger (www.helger.com) philip[at]helger[dot]com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package com.helger.appbasics.security.password.constraint;
 
 
 
Password constraint defining that at least a certain amount of uppercase letters must be contained

Author(s):
Philip Helger
Since:
2.7.4
 
 {
   private static final String ATTR_MIN_LETTERS_UPPERCASE = "minletters_uppercase";
 
   private final int m_nMinLetters;

  
Ctor

Parameters:
nMinLetters The minimum number of letters that must occur in a password. Must be > 0.
 
   public PasswordConstraintMustContainLetterUpperCase (@Nonnegative final int nMinLetters)
   {
      = ValueEnforcer.isGT0 (nMinLetters"MinLetters");
   }
 
   public int getMinLetters ()
   {
     return ;
   }
 
   public boolean isPasswordValid (@Nullable final String sPlainTextPassword)
   {
     int nLetters = 0;
     if (sPlainTextPassword != null)
       for (final char c : sPlainTextPassword.toCharArray ())
         if (Character.isLetter (c) && Character.isUpperCase (c))
           ++nLetters;
     return nLetters >= ;
   }
 
   @Nullable
   public String getDescription (@Nonnull final Locale aContentLocale)
   {
                                                                                                Integer.valueOf ());
   }
 
   public void fillMicroElement (@Nonnull final IMicroElement aElement)
   {
   }
 
   @Override
   public boolean equals (final Object o)
   {
     if (o == this)
       return true;
     if (o == null || !getClass ().equals (o.getClass ()))
       return false;
     return  == rhs.m_nMinLetters;
   }
 
   @Override
   public int hashCode ()
   {
     return new HashCodeGenerator (this).append ().getHashCode ();
   }
 
  public String toString ()
  {
    return new ToStringGenerator (this).append ("minLetters").toString ();
  }
New to GrepCode? Check out our FAQ X