| 1 16 package com.sun.slamd.example; 17 18 19 20 import java.io.*; 21 import java.security.*; 22 import java.util.*; 23 import netscape.ldap.*; 24 import netscape.ldap.factory.*; 25 import com.sun.slamd.job.*; 26 import com.sun.slamd.parameter.*; 27 import com.sun.slamd.stat.*; 28 29 30 31 62 public class WeightedSiteMinderJobClass 63 extends JobClass 64 { 65 69 public static final char[] ALPHABET = 70 "abcdefghijklmnopqrstuvwxyz".toCharArray(); 71 72 73 74 78 public static final String DEFAULT_ATTR1 = "givenName"; 79 80 81 82 86 public static final String DEFAULT_ATTR2 = "sn"; 87 88 89 90 94 public static final String DEFAULT_ATTR3= "cn"; 95 96 97 98 101 public static final String DEFAULT_LOG_ID_ATTR = "uid"; 102 103 104 105 108 public static final String SSL_KEY_STORE_PROPERTY = 109 "javax.net.ssl.keyStore"; 110 111 112 113 116 public static final String SSL_KEY_PASSWORD_PROPERTY = 117 "javax.net.ssl.keyStorePassword"; 118 119 120 121 124 public static final String SSL_TRUST_STORE_PROPERTY = 125 "javax.net.ssl.trustStore"; 126 127 128 129 132 public static final String SSL_TRUST_PASSWORD_PROPERTY = 133 "javax.net.ssl.trustStorePassword"; 134 135 136 137 141 public static final String STAT_TRACKER_OVERALL_AUTHENTICATION_ATTEMPTS = 142 "Overall Authentication Attempts"; 143 144 145 146 150 public static final String STAT_TRACKER_AUTHENTICATION_1_ATTEMPTS = 151 "Authentication 1 Attempts"; 152 153 154 155 159 public static final String STAT_TRACKER_AUTHENTICATION_2_ATTEMPTS = 160 "Authentication 2 Attempts"; 161 162 163 164 168 public static final String STAT_TRACKER_OVERALL_AUTHENTICATION_TIME = 169 "Overall Authentication Time (ms)"; 170 171 172 173 177 public static final String STAT_TRACKER_AUTHENTICATION_1_TIME = 178 "Authentication 1 Time (ms)"; 179 180 181 182 186 public static final String STAT_TRACKER_AUTHENTICATION_2_TIME = 187 "Authentication 2 Time (ms)"; 188 189 190 191 195 public static final String STAT_TRACKER_OVERALL_FAILED_AUTHENTICATIONS = 196 "Overall Failed Authentications"; 197 198 199 200 204 public static final String STAT_TRACKER_FAILED_AUTHENTICATIONS_1 = 205 "Failed Authentications 1"; 206 207 208 209 213 public static final String STAT_TRACKER_FAILED_AUTHENTICATIONS_2 = 214 "Failed Authentications 2"; 215 216 217 218 222 public static final String STAT_TRACKER_FAIL_REASON = "Failure Reason"; 223 224 225 226 230 public static final String STAT_TRACKER_OVERALL_SUCCESSFUL_AUTHENTICATIONS = 231 "Overall Successful Authentications"; 232 233 234 235 239 public static final String STAT_TRACKER_SUCCESSFUL_AUTHENTICATIONS_1 = 240 "Successful Authentications 1"; 241 242 243 244 248 public static final String STAT_TRACKER_SUCCESSFUL_AUTHENTICATIONS_2 = 249 "Successful Authentications 2"; 250 251 252 253 256 public static final String [] DEFAULT_ATTRS_TO_MODIFY = new String [] 257 { 258 "description" 259 }; 260 261 262 263 static boolean blindTrust; 265 266 static boolean ignoreInvalidCredentials; 269 270 static boolean skipBind; 272 273 static boolean useLoginIDRange1; 275 276 static boolean useLoginIDRange2; 278 279 static boolean useSequential1; 281 282 static boolean useSequential2; 284 285 static boolean useSharedConnections; 288 289 static boolean useSSL; 291 292 static int coolDownTime; 294 295 static int directoryPort; 297 298 static int loginID1Percent; 300 301 static int loginIDMax1; 303 304 static int loginIDMax2; 306 307 static int loginIDMin1; 309 310 static int loginIDMin2; 312 313 static int loginIDSpan1; 315 316 static int loginIDSpan2; 318 319 static int sequentialCounter1; 321 322 static int sequentialCounter2; 324 325 static int timeLimit; 328 329 static int warmUpTime; 331 332 static long delay; 334 335 static LDAPConnection sharedAuthConnection; 337 338 static LDAPConnection sharedBindConnection; 340 341 static Random parentRandom; 344 345 static String bindDN; 348 349 static String bindPW; 351 352 static String directoryHost; 354 355 static String filter1; 357 358 static String filter2; 360 361 static String filter3; 363 364 static String loginIDAttr; 367 368 static String loginIDFinal1; 370 371 static String loginIDFinal2; 373 374 static String loginIDInitial1; 376 377 static String loginIDInitial2; 379 380 static String loginPassword; 382 383 static String searchAttr1; 385 386 static String searchAttr2; 388 389 static String searchAttr3; 391 392 static String searchBase; 395 396 static String sslKeyStore; 398 399 static String sslKeyPassword; 401 402 static String sslTrustStore; 404 405 static String sslTrustPassword; 407 408 static String [] modAttrs; 410 411 static String [] returnAttrs1; 413 414 static String [] returnAttrs2; 416 417 static String [] returnAttrs3; 419 420 static String [] returnAttrsOC; 422 423 424 425 BooleanParameter blindTrustParameter = 427 new BooleanParameter("blind_trust", "Blindly Trust Any Certificate", 428 "Indicates whether the client should blindly trust " + 429 "any certificate presented by the server, or " + 430 "whether the key and trust stores should be used.", 431 true); 432 433 BooleanParameter ignoreInvCredParameter = 436 new BooleanParameter("ignore_49", "Ignore Invalid Credentials Errors", 437 "Indicates whether bind failures because of " + 438 "invalid credentials (err=49). This makes it " + 439 "possible to use this job without actually " + 440 "know user passwords.", false); 441 442 BooleanParameter shareConnsParameter = 444 new BooleanParameter("share_conns", "Share Connections between Threads", 445 "Indicates whether the connections to the " + 446 "directory server will be shared between threads " + 447 "or if each client thread will have its own " + 448 "connections.", true); 449 450 BooleanParameter skipBindParameter = 452 new BooleanParameter("skip_bind", "Skip Bind Operation", 453 "Indicates whether the bind attempt should be " + 454 "skipped as part of the authentication process.", 455 false); 456 457 BooleanParameter useSSLParameter = 459 new BooleanParameter("usessl", "Use SSL", 460 "Indicates whether to use SSL to encrypt the " + 461 "communication with the directory server", false); 462 463 IntegerParameter coolDownParameter = 465 new IntegerParameter("cool_down", "Cool Down Time", 466 "The time in seconds that the job should " + 467 "continue searching after ending statistics " + 468 "collection.", true, 0, true, 0, false, 0); 469 470 IntegerParameter delayParameter = 473 new IntegerParameter("delay", "Time Between Authentications (ms)", 474 "Specifies the length of time in milliseconds " + 475 "each thread should wait between authentication " + 476 "attempts. Note that this delay will be " + 477 "between the starts of consecutive attempts and " + 478 "not between the end of one attempt and the " + 479 "beginning of the next. If an authentication " + 480 "takes longer than this length of time, then " + 481 "there will be no delay.", true, 0, true, 0, false, 482 0); 483 484 IntegerParameter portParameter = 486 new IntegerParameter("ldap_port", "Directory Server Port", 487 "The port number for the directory server.", true, 488 389, true, 1, true, 65535); 489 490 IntegerParameter timeLimitParameter = 493 new IntegerParameter("time_limit", "Operation Time Limit", 494 "The maximum length of time in seconds that any " + 495 "single LDAP operation will be allowed to take " + 496 "before it is cancelled.", true, 0, true, 0, false, 497 0); 498 499 IntegerParameter warmUpParameter = 501 new IntegerParameter("warm_up", "Warm Up Time", 502 "The time in seconds that the job should " + 503 "search before beginning statistics collection.", 504 true, 0, true, 0, false, 0); 505 506 IntegerParameter weightParameter = 509 new IntegerParameter("weight", "Login ID 1 Percentage", 510 "The percentage of the time that a login ID " + 511 "should be selected according to the value " + 512 "provided for the Login ID Value 1 parameter.", 513 true, 50, true, 0, true, 100); 514 515 MultiLineTextParameter modAttrsParameter = 517 new MultiLineTextParameter("mod_attrs", "Attributes to Modify", 518 "The set of attributes to modify.", 519 DEFAULT_ATTRS_TO_MODIFY, false); 520 521 PasswordParameter bindPWParameter = 523 new PasswordParameter("bindpw", "Directory Bind Password", 524 "The password to use when binding to the " + 525 "directory server to perform search and modify " + 526 "operations.", false, ""); 527 528 PasswordParameter keyPWParameter = 530 new PasswordParameter("sslkeypw", "SSL Key Store Password", 531 "The password for the JSSE key store", false, ""); 532 533 PasswordParameter loginPasswordParameter = 536 new PasswordParameter("login_id_pw", "Login Password", 537 "The password to use when authenticating to the " + 538 "directory for user authentications.", false, ""); 539 540 PasswordParameter trustPWParameter = 542 new PasswordParameter("ssltrustpw", "SSL Trust Store Password", 543 "The password for the JSSE trust store", false, ""); 544 545 PlaceholderParameter placeholder = new PlaceholderParameter(); 547 548 StringParameter attr1Parameter = 550 new StringParameter("attr1", "First Attribute to Retrieve", 551 "The first attribute to retrieve from the user's " + 552 "entry as part of the authentication process.", 553 true, DEFAULT_ATTR1); 554 555 StringParameter attr2Parameter = 557 new StringParameter("attr2", "Second Attribute to Retrieve", 558 "The second attribute to retrieve from the user's " + 559 "entry as part of the authentication process.", 560 true, DEFAULT_ATTR2); 561 562 StringParameter attr3Parameter = 564 new StringParameter("attr3", "Third Attribute to Retrieve", 565 "The third attribute to retrieve from the user's " + 566 "entry as part of the authentication process.", 567 true, DEFAULT_ATTR3); 568 569 StringParameter bindDNParameter = 571 new StringParameter("binddn", "Directory Bind DN", 572 "The DN to use when binding to the directory " + 573 "server to perform search and modify operations.", 574 false, ""); 575 576 StringParameter hostParameter = 578 new StringParameter("ldap_host", "Directory Server Address", 579 "The address for the directory server.", true, ""); 580 581 StringParameter keyStoreParameter = 583 new StringParameter("sslkeystore", "SSL Key Store", 584 "The path to the JSSE key store to use for an " + 585 "SSL-based connection", false, ""); 586 587 StringParameter loginIDParameter = 589 new StringParameter("login_id_attr", "Login ID Attribute", 590 "The attribute to use as the login ID to find the " + 591 "user's entry.", true, DEFAULT_LOG_ID_ATTR); 592 593 StringParameter loginIDValue1Parameter = 595 new StringParameter("login_id_value_1", "Login ID Value 1", 596 "The text to use as the value of the login ID " + 597 "attribute in search filters created using the " + 598 "first set of user criteria. The value may " + 599 "contain a range of numbers in square brackets.", 600 true, ""); 601 602 StringParameter loginIDValue2Parameter = 604 new StringParameter("login_id_value_2", "Login ID Value 2", 605 "The text to use as the value of the login ID " + 606 "attribute in search filters created using the " + 607 "second set of user criteria. The value may " + 608 "contain a range of numbers in square brackets.", 609 true, ""); 610 611 StringParameter searchBaseParameter = 613 new StringParameter("search_base", "User Search Base", 614 "The DN in the directory server under which user " + 615 "entries may be found.", true, ""); 616 617 StringParameter trustStoreParameter = 619 new StringParameter("ssltruststore", "SSL Trust Store", 620 "The path to the JSSE trust store to use for an " + 621 "SSL-based connection", false, ""); 622 623 CategoricalTracker failureReasonTracker; 625 626 IncrementalTracker overallAttemptCounter; 628 IncrementalTracker attemptCounter1; 629 IncrementalTracker attemptCounter2; 630 631 IncrementalTracker overallFailureCounter; 633 IncrementalTracker failureCounter1; 634 IncrementalTracker failureCounter2; 635 636 IncrementalTracker overallSuccessCounter; 639 IncrementalTracker successCounter1; 640 IncrementalTracker successCounter2; 641 642 LDAPConnection authConnection; 645 646 LDAPConnection bindConnection; 648 649 LDAPConstraints authConstraints; 651 652 LDAPConstraints bindConstraints; 654 655 LDAPSearchConstraints authSearchConstraints; 657 658 Random random; 660 661 TimeTracker overallAuthTimer; 663 TimeTracker authTimer1; 664 TimeTracker authTimer2; 665 666 667 668 672 public WeightedSiteMinderJobClass() 673 { 674 super(); 675 } 676 677 678 679 685 public String getJobName() 686 { 687 return "LDAP Weighted SiteMinder Load Simulator"; 688 } 689 690 691 692 698 public String getJobDescription() 699 { 700 return "This job simulates the load that SiteMinder can place on the " + 701 "directory server when it is performing authentications. It uses " + 702 "a weighted access pattern to more accurately simulate real-world " + 703 "behavior."; 704 } 705 706 707 708 714 public String getJobCategoryName() 715 { 716 return "LDAP"; 717 } 718 719 720 721 726 public ParameterList getParameterStubs() 727 { 728 Parameter[] parameterArray = new Parameter[] 729 { 730 placeholder, 731 hostParameter, 732 portParameter, 733 bindDNParameter, 734 bindPWParameter, 735 placeholder, 736 searchBaseParameter, 737 loginIDValue1Parameter, 738 loginIDValue2Parameter, 739 weightParameter, 740 loginPasswordParameter, 741 loginIDParameter, 742 placeholder, 743 attr1Parameter, 744 attr2Parameter, 745 attr3Parameter, 746 modAttrsParameter, 747 placeholder, 748 warmUpParameter, 749 coolDownParameter, 750 timeLimitParameter, 751 delayParameter, 752 placeholder, 753 useSSLParameter, 754 blindTrustParameter, 755 keyStoreParameter, 756 keyPWParameter, 757 trustStoreParameter, 758 trustPWParameter, 759 placeholder, 760 skipBindParameter, 761 ignoreInvCredParameter, 762 shareConnsParameter 763 }; 764 765 return new ParameterList(parameterArray); 766 } 767 768 769 770 792 public StatTracker[] getStatTrackerStubs(String clientID, String threadID, 793 int collectionInterval) 794 { 795 return new StatTracker[] 796 { 797 new IncrementalTracker(clientID, threadID, 798 STAT_TRACKER_OVERALL_AUTHENTICATION_ATTEMPTS, 799 collectionInterval), 800 new IncrementalTracker(clientID, threadID, 801 STAT_TRACKER_AUTHENTICATION_1_ATTEMPTS, 802 collectionInterval), 803 new IncrementalTracker(clientID, threadID, 804 STAT_TRACKER_AUTHENTICATION_2_ATTEMPTS, 805 collectionInterval), 806 new IncrementalTracker(clientID, threadID, 807 STAT_TRACKER_OVERALL_SUCCESSFUL_AUTHENTICATIONS, 808 collectionInterval), 809 new IncrementalTracker(clientID, threadID, 810 STAT_TRACKER_SUCCESSFUL_AUTHENTICATIONS_1, 811 collectionInterval), 812 new IncrementalTracker(clientID, threadID, 813 STAT_TRACKER_SUCCESSFUL_AUTHENTICATIONS_2, 814 collectionInterval), 815 new IncrementalTracker(clientID, threadID, 816 STAT_TRACKER_OVERALL_FAILED_AUTHENTICATIONS, 817 collectionInterval), 818 new IncrementalTracker(clientID, threadID, 819 STAT_TRACKER_FAILED_AUTHENTICATIONS_1, 820 collectionInterval), 821 new IncrementalTracker(clientID, threadID, 822 STAT_TRACKER_FAILED_AUTHENTICATIONS_2, 823 collectionInterval), 824 new TimeTracker(clientID, threadID, 825 STAT_TRACKER_OVERALL_AUTHENTICATION_TIME, 826 collectionInterval), 827 new TimeTracker(clientID, threadID, STAT_TRACKER_AUTHENTICATION_1_TIME, 828 collectionInterval), 829 new TimeTracker(clientID, threadID, STAT_TRACKER_AUTHENTICATION_2_TIME, 830 collectionInterval), 831 new CategoricalTracker(clientID, threadID, STAT_TRACKER_FAIL_REASON, 832 collectionInterval) 833 }; 834 } 835 836 837 838 843 public StatTracker[] getStatTrackers() 844 { 845 return new StatTracker[] 846 { 847 overallAttemptCounter, 848 attemptCounter1, 849 attemptCounter2, 850 overallSuccessCounter, 851 successCounter1, 852 successCounter2, 853 overallFailureCounter, 854 failureCounter1, 855 failureCounter2, 856 overallAuthTimer, 857 authTimer1, 858 authTimer2, 859 failureReasonTracker 860 }; 861 } 862 863 864 865 873 public boolean providesParameterTest() 874 { 875 return true; 876 } 877 878 879 880 907 public boolean testJobParameters(ParameterList parameters, 908 ArrayList outputMessages) 909 { 910 StringParameter hostParam = 912 parameters.getStringParameter(hostParameter.getName()); 913 if ((hostParam == null) || (! hostParam.hasValue())) 914 { 915 outputMessages.add("ERROR: No directory server address was provided."); 916 return false; 917 } 918 String host = hostParam.getStringValue(); 919 920 921 IntegerParameter portParam = 922 parameters.getIntegerParameter(portParameter.getName()); 923 if ((portParam == null) || (! hostParam.hasValue())) 924 { 925 outputMessages.add("ERROR: No directory server port was provided."); 926 return false; 927 } 928 int port = portParam.getIntValue(); 929 930 931 boolean useSSL = false; 932 BooleanParameter useSSLParam = 933 parameters.getBooleanParameter(useSSLParameter.getName()); 934 if (useSSLParam != null) 935 { 936 useSSL = useSSLParam.getBooleanValue(); 937 } 938
|