1 13 14 package org.ejbca.core.model.ra; 15 16 import java.util.Arrays ; 17 import java.util.List ; 18 19 import org.ejbca.util.passgen.PasswordGeneratorFactory; 20 21 27 public class UsernameGeneratorParams { 28 29 30 protected static final int MODE_RANDOM = 0; 31 32 protected static final int MODE_USERNAME = 1; 33 34 protected static final int MODE_DN = 2; 35 36 public static final String RANDOM = "RANDOM"; 37 public static final String USERNAME = "USERNAME"; 38 public static final String DN = "DN"; 39 40 private String [] modes = {"RANDOM", "USERNAME", "DN"}; 41 private List modeList = null; 42 43 private int mode = MODE_RANDOM; 45 private int randomNameLength = 12; 46 private int randomGeneratorType = PasswordGeneratorFactory.PASSWORDTYPE_LETTERSANDDIGITS; 47 private String dNGeneratorComponent = "CN"; private String prefix = null; 49 private String postfix = null; 50 private int randomPrefixLength = 12; 51 52 public UsernameGeneratorParams() { 53 } 55 56 public String getDNGeneratorComponent() { 57 return dNGeneratorComponent; 58 } 59 public void setDNGeneratorComponent(String generatorComponent) { 60 dNGeneratorComponent = generatorComponent; 61 } 62 public String getPostfix() { 63 return postfix; 64 } 65 public void setPostfix(String postfix) { 66 this.postfix = postfix; 67 } 68 public String getPrefix() { 69 return prefix; 70 } 71 public void setPrefix(String prefix) { 72 this.prefix = prefix; 73 } 74 public int getRandomGeneratorType() { 75 return randomGeneratorType; 76 } 77 public void setRandomGeneratorType(int randomGeneratorType) { 78 this.randomGeneratorType = randomGeneratorType; 79 } 80 public int getRandomNameLength() { 81 return randomNameLength; 82 } 83 public void setRandomNameLength(int randomNameLength) { 84 this.randomNameLength = randomNameLength; 85 } 86 public int getRandomPrefixLength() { 87 return randomPrefixLength; 88 } 89 public void setRandomPrefixLength(int randomPrefixLength) { 90 this.randomPrefixLength = randomPrefixLength; 91 } 92 93 public int getMode() { 94 return mode; 95 } 96 97 public void setMode(int mode) { 98 this.mode = mode; 99 } 100 101 public void setMode(String mode) { 102 modeList = Arrays.asList(modes); 103 if (!modeList.contains(mode)) { 104 throw new IllegalArgumentException ("Mode " + mode + " is not supported"); 105 } 106 this.mode = modeList.indexOf(mode); 107 } 108 109 110 } 111 | Popular Tags |