Package org.owasp.passfault

Examples of org.owasp.passfault.PasswordPattern


  }
 
  @Test
  public void twoPattern_overlap(){
    PasswordAnalysis_Unoptimized pa = new PasswordAnalysis_Unoptimized("12345");
    pa.foundPattern(new PasswordPattern(1, 1, "2", 15, "worstPattern"));
    pa.foundPattern(new PasswordPattern(1, 1, "2", 4, "bestPattern"));
    pa.foundPattern(new PasswordPattern(1, 1, "2", 20, "worsePattern"));
    pa.foundPattern(new PasswordPattern(1, 1, "2", 23, "worserPattern"));
   
    pa.foundPattern(new PasswordPattern(2, 2, "34", 15, "worstPattern"));
    pa.foundPattern(new PasswordPattern(2, 2, "34", 20, "worsePattern"));
    pa.foundPattern(new PasswordPattern(2, 2, "34", 23, "worserPattern"));
    pa.foundPattern(new PasswordPattern(2, 2, "34", 4, "bestPattern"));
   
    pa.foundPattern(new PasswordPattern(4, 1, "5", 15, "worstPattern"));
    pa.foundPattern(new PasswordPattern(4, 1, "5", 20, "worsePattern"));
    pa.foundPattern(new PasswordPattern(4, 1, "5", 4, "bestPattern"));
    pa.foundPattern(new PasswordPattern(4, 1, "5", 23, "worserPattern"));
   
    PathCost patterns = pa.calculateHighestProbablePatterns();
   
    List<PasswordPattern> list = patterns.getPath();
    assertEquals(4, list.size());
View Full Code Here


      assertAdaptedReverse(instance, reverseStartingIndex, actualStartingIndex);
    }
  }

  private void assertAdaptedReverse(BackwardsAnalysisAdapter instance, int reverseStartingIndex, int actualStartingIndex) {
    instance.foundPattern(new PasswordPattern(reverseStartingIndex, 4, "word", 4, "word", "word", "english"));
    List<PasswordPattern> path = instance.calculateHighestProbablePatterns().getPath();
    boolean foundPattern = false;
    for (PasswordPattern patt : path) {
      if (BackwardsAnalysisAdapter.NAME.equalsIgnoreCase(patt.getName())) {
        assertEquals(actualStartingIndex, patt.getStartIndex());
View Full Code Here

    return this.wrappedPasswordAnalysis.calculateHighestProbablePatterns();
  }

  @Override
  public void foundPattern(PasswordPattern patt) {
    PasswordPattern adaptedPattern = reversePattern(patt);
    this.wrappedPasswordAnalysis.foundPattern(adaptedPattern);
  }
View Full Code Here

    return this.wrappedPasswordAnalysis.getPossiblePatternCount();
  }

  private PasswordPattern reversePattern(PasswordPattern patt) {
    int nonReverseStartIndex = backwardsChars.length - patt.getStartIndex() - patt.getLength();
    return new PasswordPattern(nonReverseStartIndex, patt.getLength(), patt.getMatchString(), patt.getCost(), BackwardsAnalysisAdapter.NAME + ": " + patt.getDescription(), BackwardsAnalysisAdapter.NAME, patt.getClassification());
  }
View Full Code Here

public class JsonWriterTest {

  @Test
  public void testPatternToJSON() throws IOException {
    MockPasswordResults results = new MockPasswordResults("test");
    results.foundPattern(new PasswordPattern(1, 2, "te", 300, "This is a test pattern", "testPattern", "test"));
    results.foundPattern(new PasswordPattern(3, 2, "st", 350, "This is another test pattern", "testPattern2", "test"));
    PathCost pathCost = results.calculateHighestProbablePatterns();
    JsonWriter writer = new JsonWriter();
    writer.write(new PrintWriter(System.out, true), pathCost);
  }
View Full Code Here

  public void testDup() {
    System.out.println("process");

    PasswordAnalysis password = new PasswordAnalysis("abcabc");
    PathCost cost = new PathCost(password);
    cost.addPattern(new PasswordPattern(3, 3, "abc", 100, "test pattern"));
    cost.addPattern(new PasswordPattern(0, 3, "abc", 100, "test pattern"));

    RepeatingPatternFinder instance = new RepeatingPatternFinder();
    PathCost result = instance.process(cost, password);
    assertEquals(100, (int) result.getTotalCost());
    List<PasswordPattern> pattList = result.getPath();
View Full Code Here

  public void testNonDup() {
    System.out.println("process");

    PasswordAnalysis password = new PasswordAnalysis("abcabc");
    PathCost cost = new PathCost(password);
    cost.addPattern(new PasswordPattern(3, 3, "abc", 100, "test pattern"));
    cost.addPattern(new PasswordPattern(0, 3, "xyz", 100, "test pattern"));

    RepeatingPatternFinder instance = new RepeatingPatternFinder();
    PathCost result = instance.process(cost, password);
    assertEquals(100 * 100, (int) result.getTotalCost());
    List<PasswordPattern> pattList = result.getPath();
View Full Code Here

  public void test2dup() {
    System.out.println("process");

    PasswordAnalysis password = new PasswordAnalysis("abcabcabc");
    PathCost cost = new PathCost(password);
    cost.addPattern(new PasswordPattern(6, 3, "abc", 100, "test pattern"));
    cost.addPattern(new PasswordPattern(3, 3, "abc", 100, "test pattern"));
    cost.addPattern(new PasswordPattern(0, 3, "abc", 100, "test pattern"));

    RepeatingPatternFinder instance = new RepeatingPatternFinder();
    PathCost result = instance.process(cost, password);
    assertEquals(100, (int) result.getTotalCost());
    List<PasswordPattern> pattList = result.getPath();
View Full Code Here

  public void testDupExtra() {
    System.out.println("process");

    PasswordAnalysis password = new PasswordAnalysis("123abc456abc789");
    PathCost cost = new PathCost(password);
    cost.addPattern(new PasswordPattern(9, 3, "abc", 100, "test pattern"));
    cost.addPattern(new PasswordPattern(3, 3, "abc", 100, "test pattern"));

    RepeatingPatternFinder instance = new RepeatingPatternFinder();
    PathCost result = instance.process(cost, password);
    List<PasswordPattern> pattList = result.getPath();
    assertEquals(2, pattList.size());
View Full Code Here

    System.out.println("getRandomPattern");
    CharSequence chars = "afaf";
    int start = 0;
    int length = 4;
    RandomPattern instance = new RandomPattern();
    PasswordPattern result = instance.getRandomPattern(chars, start, length);
    assertEquals(Math.pow(RandomPattern.RandomClasses.Latin.getSize(false), 4), result.getCost(), .1);

  }
View Full Code Here

TOP

Related Classes of org.owasp.passfault.PasswordPattern

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.