001/* 002 * Copyright 2008-2017 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2015-2017 Ping Identity Corporation 007 * 008 * This program is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU General Public License (GPLv2 only) 010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 011 * as published by the Free Software Foundation. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Public License for more details. 017 * 018 * You should have received a copy of the GNU General Public License 019 * along with this program; if not, see <http://www.gnu.org/licenses>. 020 */ 021package com.unboundid.ldap.sdk.unboundidds.extensions; 022 023 024 025import java.io.Serializable; 026import java.text.ParseException; 027import java.util.ArrayList; 028import java.util.Date; 029 030import com.unboundid.asn1.ASN1Element; 031import com.unboundid.asn1.ASN1Enumerated; 032import com.unboundid.asn1.ASN1OctetString; 033import com.unboundid.asn1.ASN1Sequence; 034import com.unboundid.ldap.sdk.LDAPException; 035import com.unboundid.ldap.sdk.ResultCode; 036import com.unboundid.util.NotMutable; 037import com.unboundid.util.ThreadSafety; 038import com.unboundid.util.ThreadSafetyLevel; 039 040import static com.unboundid.ldap.sdk.unboundidds.extensions.ExtOpMessages.*; 041import static com.unboundid.util.Debug.*; 042import static com.unboundid.util.StaticUtils.*; 043 044 045 046/** 047 * This class defines an operation that may be used in conjunction with the 048 * password policy state extended operation. A password policy state operation 049 * can be used to get or set various properties of the password policy state for 050 * a user. 051 * <BR> 052 * <BLOCKQUOTE> 053 * <B>NOTE:</B> This class, and other classes within the 054 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 055 * supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661 056 * server products. These classes provide support for proprietary 057 * functionality or for external specifications that are not considered stable 058 * or mature enough to be guaranteed to work in an interoperable way with 059 * other types of LDAP servers. 060 * </BLOCKQUOTE> 061 * <BR> 062 * Operations that are available for use with the password policy state 063 * operation include: 064 * <UL> 065 * <LI>Get the DN of the password policy configuration entry for the target 066 * user.</LI> 067 * <LI>Determine whether an account is usable (may authenticate or be used as 068 * an alternate authorization identity.</LI> 069 * <LI>Retrieve the set of account usability notice, warning, and error 070 * messages for a user.</LI> 071 * <LI>Get, set, and clear the account disabled flag for the target user.</LI> 072 * <LI>Get, set, and clear the account activation time for the target 073 * user.</LI> 074 * <LI>Get, set, and clear the account expiration time for the target 075 * user.</LI> 076 * <LI>Get the length of time in seconds until the target user account 077 * expires.</LI> 078 * <LI>Get the time that the target user's password was last changed.</LI> 079 * <LI>Get and clear the time that the first password expiration warning was 080 * sent to the user.</LI> 081 * <LI>Get the length of time in seconds until the target user's password 082 * expires and the password expiration time for the account.</LI> 083 * <LI>Get the length of time in seconds until the user should receive the 084 * first warning about an upcoming password expiration.</LI> 085 * <LI>Determine whether the user's password is expired.</LI> 086 * <LI>Determine whether the account is locked because of failed 087 * authentication attempts, an idle lockout, or a password reset 088 * lockout.</LI> 089 * <LI>Get, update, set, and clear the list of times that the target user has 090 * unsuccessfully tried to authenticate since the last successful 091 * authentication.</LI> 092 * <LI>Get the number of remaining failed authentication attempts for the 093 * target user before the account is locked.</LI> 094 * <LI>Get the length of time in seconds until the target user's account is 095 * automatically unlocked after it was locked due to failed authentication 096 * attempts.</LI> 097 * <LI>Get, set, and clear the time that the user last authenticated to the 098 * server.</LI> 099 * <LI>Get, set, and clear the IP address of the client from which the user 100 * last authenticated to the server.</LI> 101 * <LI>Get the length of time in seconds until the user account may be locked 102 * after remaining idle.</LI> 103 * <LI>Get, set, and clear the flag that controls whether the target user must 104 * change his/her password before being allowed to perform any other 105 * operations.</LI> 106 * <LI>Get the length of time in seconds until the user's account is locked 107 * after failing to change the password after an administrative 108 * reset.</LI> 109 * <LI>Get, update, set, and clear the times that the target user has 110 * authenticated using a grace login after the password had expired.</LI> 111 * <LI>Retrieve the number of remaining grace logins for the user.</LI> 112 * <LI>Get, set, and clear the required password change time for the target 113 * user.</LI> 114 * <LI>Retrieve the length of time in seconds until the target user's account 115 * will be locked as a result of failing to comply with a password change 116 * by required time.</LI> 117 * <LI>Get the password history count for the target user.</LI> 118 * <LI>Clear the password history for the target user.</LI> 119 * <LI>Get information about or purge a user's retired password.</LI> 120 * <LI>Get information about which SASL mechanisms are available for a 121 * user.</LI> 122 * <LI>Get information about which OTP delivery mechanisms are available for a 123 * user.</LI> 124 * <LI>Determine whether a user has any TOTP shared secrets and manipulate the 125 * registered secrets.</LI> 126 * <LI>Get, set, and clear the public IDs of any YubiKey OTP devices 127 * registered for a user.</LI> 128 * </UL> 129 * Note that many of these methods are dependent upon the password policy 130 * configuration for the target user and therefore some of them may not be 131 * applicable for some users. For example, if password expiration is not 132 * enabled in the password policy associated with the target user, then 133 * operations that involve password expiration will have no effect and/or will 134 * have a return value that indicates that password expiration is not in effect. 135 */ 136@NotMutable() 137@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 138public final class PasswordPolicyStateOperation 139 implements Serializable 140{ 141 /** 142 * The operation type that may be used to retrieve the DN of the password 143 * policy to which the user is subject. 144 */ 145 public static final int OP_TYPE_GET_PW_POLICY_DN = 0; 146 147 148 149 /** 150 * The operation type that may be used to determine whether the user account 151 * is disabled. 152 */ 153 public static final int OP_TYPE_GET_ACCOUNT_DISABLED_STATE = 1; 154 155 156 157 /** 158 * The operation type that may be used to specify whether the user account is 159 * disabled. 160 */ 161 public static final int OP_TYPE_SET_ACCOUNT_DISABLED_STATE = 2; 162 163 164 165 /** 166 * The operation type that may be used to clear the account disabled flag in 167 * the user's entry. 168 */ 169 public static final int OP_TYPE_CLEAR_ACCOUNT_DISABLED_STATE = 3; 170 171 172 173 /** 174 * The operation type that may be used to get the time that the user's account 175 * will expire. 176 */ 177 public static final int OP_TYPE_GET_ACCOUNT_EXPIRATION_TIME = 4; 178 179 180 181 /** 182 * The operation type that may be used to set the time that the user's account 183 * will expire. 184 */ 185 public static final int OP_TYPE_SET_ACCOUNT_EXPIRATION_TIME = 5; 186 187 188 189 /** 190 * The operation type that may be used to clear the user's account expiration 191 * time. 192 */ 193 public static final int OP_TYPE_CLEAR_ACCOUNT_EXPIRATION_TIME = 6; 194 195 196 197 /** 198 * The operation type that may be used to retrieve the length of time in 199 * seconds until the user's account expires. 200 */ 201 public static final int OP_TYPE_GET_SECONDS_UNTIL_ACCOUNT_EXPIRATION = 7; 202 203 204 205 /** 206 * The operation type that may be used to get the time that the user's 207 * password was last changed. 208 */ 209 public static final int OP_TYPE_GET_PW_CHANGED_TIME = 8; 210 211 212 213 /** 214 * The operation type that may be used to set the time that the user's 215 * password was last changed. 216 */ 217 public static final int OP_TYPE_SET_PW_CHANGED_TIME = 9; 218 219 220 221 /** 222 * The operation type that may be used to clear the password changed time in 223 * the user's account. 224 */ 225 public static final int OP_TYPE_CLEAR_PW_CHANGED_TIME = 10; 226 227 228 229 /** 230 * The operation type that may be used to get the time that the user was 231 * first sent a password expiration warning. 232 */ 233 public static final int OP_TYPE_GET_PW_EXPIRATION_WARNED_TIME = 11; 234 235 236 237 /** 238 * The operation type that may be used to set the time that the user was 239 * first sent a password expiration warning. 240 */ 241 public static final int OP_TYPE_SET_PW_EXPIRATION_WARNED_TIME = 12; 242 243 244 245 /** 246 * The operation type that may be used to clear the password expiration warned 247 * time from the user's entry. 248 */ 249 public static final int OP_TYPE_CLEAR_PW_EXPIRATION_WARNED_TIME = 13; 250 251 252 253 /** 254 * The operation type that may be used to get the length of time in seconds 255 * until the user's password expires. 256 */ 257 public static final int OP_TYPE_GET_SECONDS_UNTIL_PW_EXPIRATION = 14; 258 259 260 261 /** 262 * The operation type that may be used to get the length of time in seconds 263 * until the user will be eligible to receive a password expiration warning. 264 */ 265 public static final int OP_TYPE_GET_SECONDS_UNTIL_PW_EXPIRATION_WARNING = 15; 266 267 268 269 /** 270 * The operation type that may be used to get the set of times that the user 271 * has unsuccessfully tried to authenticate since the last successful attempt. 272 */ 273 public static final int OP_TYPE_GET_AUTH_FAILURE_TIMES = 16; 274 275 276 277 /** 278 * The operation type that may be used to add a new authentication failure 279 * time to the user's account. 280 */ 281 public static final int OP_TYPE_ADD_AUTH_FAILURE_TIME = 17; 282 283 284 285 /** 286 * The operation type that may be used to set the set of times that the user 287 * has unsuccessfully tried to authenticate since the last successful attempt. 288 */ 289 public static final int OP_TYPE_SET_AUTH_FAILURE_TIMES = 18; 290 291 292 293 /** 294 * The operation type that may be used to clear the authentication failure 295 * times in the user account. 296 */ 297 public static final int OP_TYPE_CLEAR_AUTH_FAILURE_TIMES = 19; 298 299 300 301 /** 302 * The operation type that may be used to retrieve the length of time in 303 * seconds until the user's account is unlocked. 304 */ 305 public static final int OP_TYPE_GET_SECONDS_UNTIL_AUTH_FAILURE_UNLOCK = 20; 306 307 308 309 /** 310 * The operation type that may be used to retrieve the number of failed 311 * authentication attempts that the user has before the account is locked. 312 */ 313 public static final int OP_TYPE_GET_REMAINING_AUTH_FAILURE_COUNT = 21; 314 315 316 317 /** 318 * The operation type that may be used to retrieve the time that the user last 319 * authenticated to the server. 320 */ 321 public static final int OP_TYPE_GET_LAST_LOGIN_TIME = 22; 322 323 324 325 /** 326 * The operation type that may be used to set the time that the user last 327 * authenticated to the server. 328 */ 329 public static final int OP_TYPE_SET_LAST_LOGIN_TIME = 23; 330 331 332 333 /** 334 * The operation type that may be used to clear the last login time in the 335 * user's entry. 336 */ 337 public static final int OP_TYPE_CLEAR_LAST_LOGIN_TIME = 24; 338 339 340 341 /** 342 * The operation type that may be used to get the length of time in seconds 343 * until the user account is locked due to inactivity. 344 */ 345 public static final int OP_TYPE_GET_SECONDS_UNTIL_IDLE_LOCKOUT = 25; 346 347 348 349 /** 350 * The operation type that may be used to determine whether a user's password 351 * has been reset by an administrator and must be changed. 352 */ 353 public static final int OP_TYPE_GET_PW_RESET_STATE = 26; 354 355 356 357 /** 358 * The operation type that may be used to set the flag to indicate whether a 359 * user's password has been reset by an administrator and must be changed. 360 */ 361 public static final int OP_TYPE_SET_PW_RESET_STATE = 27; 362 363 364 365 /** 366 * The operation type that may be used to clear the password reset flag in the 367 * user's entry. 368 */ 369 public static final int OP_TYPE_CLEAR_PW_RESET_STATE = 28; 370 371 372 373 /** 374 * The operation type that may be used to get the length of time in seconds 375 * until the user's account is locked due to failure to change the password 376 * after an administrative reset. 377 */ 378 public static final int OP_TYPE_GET_SECONDS_UNTIL_PW_RESET_LOCKOUT = 29; 379 380 381 382 /** 383 * The operation type that may be used to retrieve the times that the user has 384 * authenticated using a grace login after his/her password has expired. 385 */ 386 public static final int OP_TYPE_GET_GRACE_LOGIN_USE_TIMES = 30; 387 388 389 390 /** 391 * The operation type that may be used add a value to the set of times that 392 * the user has authenticated using a grace login after his/her password has 393 * expired. 394 */ 395 public static final int OP_TYPE_ADD_GRACE_LOGIN_USE_TIME = 31; 396 397 398 399 /** 400 * The operation type that may be used to set the times that the user has 401 * authenticated using a grace login after his/her password has expired. 402 */ 403 public static final int OP_TYPE_SET_GRACE_LOGIN_USE_TIMES = 32; 404 405 406 407 /** 408 * The operation type that may be used to clear the set of times that the user 409 * has authenticated using a grace login after his/her password has expired. 410 */ 411 public static final int OP_TYPE_CLEAR_GRACE_LOGIN_USE_TIMES = 33; 412 413 414 415 /** 416 * The operation type that may be used to retrieve the number of grace logins 417 * available for the user. 418 */ 419 public static final int OP_TYPE_GET_REMAINING_GRACE_LOGIN_COUNT = 34; 420 421 422 423 /** 424 * The operation type that may be used to retrieve the last time that the 425 * user's password was changed during a required change period. 426 */ 427 public static final int OP_TYPE_GET_PW_CHANGED_BY_REQUIRED_TIME = 35; 428 429 430 431 /** 432 * The operation type that may be used to set the last time that the 433 * user's password was changed during a required change period. 434 */ 435 public static final int OP_TYPE_SET_PW_CHANGED_BY_REQUIRED_TIME = 36; 436 437 438 439 /** 440 * The operation type that may be used to clear the last time that the 441 * user's password was changed during a required change period. 442 */ 443 public static final int OP_TYPE_CLEAR_PW_CHANGED_BY_REQUIRED_TIME = 37; 444 445 446 447 /** 448 * The operation type that may be used to get the length of time in seconds 449 * until the user's account will be locked due to a failure to change the 450 * password by a required time. 451 */ 452 public static final int OP_TYPE_GET_SECONDS_UNTIL_REQUIRED_CHANGE_TIME = 38; 453 454 455 456 /** 457 * The operation type that may be used to retrieve the stored password history 458 * values for a user. 459 * 460 * @deprecated This operation type has been deprecated in favor of the 461 * {@link #OP_TYPE_GET_PW_HISTORY_COUNT} operation type. 462 */ 463 @Deprecated() 464 public static final int OP_TYPE_GET_PW_HISTORY = 39; 465 466 467 468 /** 469 * The operation type that may be used to clear the stored password history 470 * values for a user. 471 */ 472 public static final int OP_TYPE_CLEAR_PW_HISTORY = 40; 473 474 475 476 /** 477 * The operation type that may be used to determine whether a user has a valid 478 * retired password. 479 */ 480 public static final int OP_TYPE_HAS_RETIRED_PASSWORD = 41; 481 482 483 484 /** 485 * The operation type that may be used to retrieve the time that the user's 486 * former password was retired. 487 */ 488 public static final int OP_TYPE_GET_PASSWORD_RETIRED_TIME = 42; 489 490 491 492 /** 493 * The operation type that may be used to retrieve the time that the user's 494 * retired password will expire. 495 */ 496 public static final int OP_TYPE_GET_RETIRED_PASSWORD_EXPIRATION_TIME = 43; 497 498 499 500 /** 501 * The operation type that may be used to purge any retired password from the 502 * user's entry. 503 */ 504 public static final int OP_TYPE_PURGE_RETIRED_PASSWORD = 44; 505 506 507 508 /** 509 * The operation type that may be used to get the time that the user's account 510 * will become active. 511 */ 512 public static final int OP_TYPE_GET_ACCOUNT_ACTIVATION_TIME = 45; 513 514 515 516 /** 517 * The operation type that may be used to set the time that the user's account 518 * will become active. 519 */ 520 public static final int OP_TYPE_SET_ACCOUNT_ACTIVATION_TIME = 46; 521 522 523 524 /** 525 * The operation type that may be used to clear the user's account activation 526 * time. 527 */ 528 public static final int OP_TYPE_CLEAR_ACCOUNT_ACTIVATION_TIME = 47; 529 530 531 532 /** 533 * The operation type that may be used to retrieve the length of time in 534 * seconds until the user's account will become active. 535 */ 536 public static final int OP_TYPE_GET_SECONDS_UNTIL_ACCOUNT_ACTIVATION = 48; 537 538 539 540 /** 541 * The operation type that may be used to retrieve the IP address from which 542 * the user last authenticated to the server. 543 */ 544 public static final int OP_TYPE_GET_LAST_LOGIN_IP_ADDRESS = 49; 545 546 547 548 /** 549 * The operation type that may be used to set the IP address from which the 550 * user last authenticated to the server. 551 */ 552 public static final int OP_TYPE_SET_LAST_LOGIN_IP_ADDRESS = 50; 553 554 555 556 /** 557 * The operation type that may be used to clear the last login IP address in 558 * the user's entry. 559 */ 560 public static final int OP_TYPE_CLEAR_LAST_LOGIN_IP_ADDRESS = 51; 561 562 563 564 /** 565 * The operation type that may be used to retrieve a list of structured 566 * strings that provide information about notices pertaining to account 567 * usability. 568 */ 569 public static final int OP_TYPE_GET_ACCOUNT_USABILITY_NOTICES = 52; 570 571 572 573 /** 574 * The operation type that may be used to retrieve a list of structured 575 * strings that provide information about warnings that may affect the account 576 * usability. 577 */ 578 public static final int OP_TYPE_GET_ACCOUNT_USABILITY_WARNINGS = 53; 579 580 581 582 /** 583 * The operation type that may be used to retrieve a list of structured 584 * strings that provide information about errors that may affect the account 585 * usability. 586 */ 587 public static final int OP_TYPE_GET_ACCOUNT_USABILITY_ERRORS = 54; 588 589 590 591 /** 592 * The operation type that may be used to determine whether an account is 593 * usable (i.e., the account may authenticate or be used as an alternate 594 * authorization identity). 595 */ 596 public static final int OP_TYPE_GET_ACCOUNT_IS_USABLE = 55; 597 598 599 600 /** 601 * The operation type that may be used to determine whether an account is 602 * not yet active (because the account activation time is in the future). 603 */ 604 public static final int OP_TYPE_GET_ACCOUNT_IS_NOT_YET_ACTIVE = 56; 605 606 607 608 /** 609 * The operation type that may be used to determine whether an account is 610 * expired (because the account expiration time is in the past). 611 */ 612 public static final int OP_TYPE_GET_ACCOUNT_IS_EXPIRED = 57; 613 614 615 616 /** 617 * The operation type that may be used to determine when a user's password 618 * will expire. 619 */ 620 public static final int OP_TYPE_GET_PW_EXPIRATION_TIME = 58; 621 622 623 624 /** 625 * The operation type that may be used to determine whether a user's account 626 * is locked because of too many authentication failures. 627 */ 628 public static final int OP_TYPE_GET_ACCOUNT_IS_FAILURE_LOCKED = 59; 629 630 631 632 /** 633 * The operation type that may be used to specify whether a user's account 634 * is locked because of too many authentication failures. 635 */ 636 public static final int OP_TYPE_SET_ACCOUNT_IS_FAILURE_LOCKED = 60; 637 638 639 640 /** 641 * The operation type that may be used to determine the failure lockout time 642 * for a user account. 643 */ 644 public static final int OP_TYPE_GET_FAILURE_LOCKOUT_TIME = 61; 645 646 647 648 /** 649 * The operation type that may be used to determine whether a user's account 650 * is locked because it has been idle for too long. 651 */ 652 public static final int OP_TYPE_GET_ACCOUNT_IS_IDLE_LOCKED = 62; 653 654 655 656 /** 657 * The operation type that may be used to determine the idle lockout time for 658 * a user account. 659 */ 660 public static final int OP_TYPE_GET_IDLE_LOCKOUT_TIME = 63; 661 662 663 664 /** 665 * The operation type that may be used to determine whether a user's account 666 * is locked because the user did not change their password in a timely manner 667 * after an administrative reset. 668 */ 669 public static final int OP_TYPE_GET_ACCOUNT_IS_RESET_LOCKED = 64; 670 671 672 673 /** 674 * The operation type that may be used to determine the reset lockout time for 675 * a user account. 676 */ 677 public static final int OP_TYPE_GET_RESET_LOCKOUT_TIME = 65; 678 679 680 681 /** 682 * The operation type that may be used to retrieve the password history count 683 * for a user. 684 */ 685 public static final int OP_TYPE_GET_PW_HISTORY_COUNT = 66; 686 687 688 689 /** 690 * The operation type that may be used to determine whether a user's password 691 * is expired. 692 */ 693 public static final int OP_TYPE_GET_PW_IS_EXPIRED = 67; 694 695 696 697 /** 698 * The operation type that may be used to retrieve a list of the SASL 699 * mechanisms that are available for a user. 700 */ 701 public static final int OP_TYPE_GET_AVAILABLE_SASL_MECHANISMS = 68; 702 703 704 705 /** 706 * The operation type that may be used to retrieve a list of the one-time 707 * password delivery mechanisms that are available for a user. 708 */ 709 public static final int OP_TYPE_GET_AVAILABLE_OTP_DELIVERY_MECHANISMS = 69; 710 711 712 713 /** 714 * The operation type that may be used to determine whether a user has one or 715 * more TOTP shared secrets. 716 */ 717 public static final int OP_TYPE_HAS_TOTP_SHARED_SECRET = 70; 718 719 720 721 /** 722 * The operation type that may be used to retrieve get the set of public IDs 723 * for the registered YubiKey OTP devices for a user. 724 */ 725 public static final int OP_TYPE_GET_REGISTERED_YUBIKEY_PUBLIC_IDS = 71; 726 727 728 729 /** 730 * The operation type that may be used to add a value to the set of registered 731 * YubiKey OTP device public IDs for a user. 732 */ 733 public static final int OP_TYPE_ADD_REGISTERED_YUBIKEY_PUBLIC_ID = 72; 734 735 736 737 /** 738 * The operation type that may be used to remove a value from the set of 739 * registered YubiKey OTP device public IDs for a user. 740 */ 741 public static final int OP_TYPE_REMOVE_REGISTERED_YUBIKEY_PUBLIC_ID = 73; 742 743 744 745 /** 746 * The operation type that may be used to replace the set of public IDs for 747 * the registered YubiKey OTP devices for a user. 748 */ 749 public static final int OP_TYPE_SET_REGISTERED_YUBIKEY_PUBLIC_IDS = 74; 750 751 752 753 /** 754 * The operation type that may be used to clear the set of public IDs for 755 * the registered YubiKey OTP devices for a user. 756 */ 757 public static final int OP_TYPE_CLEAR_REGISTERED_YUBIKEY_PUBLIC_IDS = 75; 758 759 760 761 /** 762 * The operation type that may be used to add a value to the set of registered 763 * TOTP shared secrets for a user. 764 */ 765 public static final int OP_TYPE_ADD_TOTP_SHARED_SECRET = 76; 766 767 768 769 /** 770 * The operation type that may be used to remove a value from the set of 771 * registered TOTP shared secrets for a user. 772 */ 773 public static final int OP_TYPE_REMOVE_TOTP_SHARED_SECRET = 77; 774 775 776 777 /** 778 * The operation type that may be used to replace the set of registered TOTP 779 * shared secrets for a user. 780 */ 781 public static final int OP_TYPE_SET_TOTP_SHARED_SECRETS = 78; 782 783 784 785 /** 786 * The operation type that may be used to clear the set of TOTP shared secrets 787 * for a user. 788 */ 789 public static final int OP_TYPE_CLEAR_TOTP_SHARED_SECRETS = 79; 790 791 792 793 /** 794 * The operation type that may be used to determine whether a user has one 795 * or more registered YubiKey OTP devices. 796 * shared secret. 797 */ 798 public static final int OP_TYPE_HAS_REGISTERED_YUBIKEY_PUBLIC_ID = 80; 799 800 801 802 /** 803 * The set of values that will be used if there are no values. 804 */ 805 private static final ASN1OctetString[] NO_VALUES = new ASN1OctetString[0]; 806 807 808 809 /** 810 * The serial version UID for this serializable class. 811 */ 812 private static final long serialVersionUID = 5266077746088110528L; 813 814 815 816 // The set of values for this operation. 817 private final ASN1OctetString[] values; 818 819 // The operation type for this operation. 820 private final int opType; 821 822 823 824 /** 825 * Creates a new password policy state operation with the specified operation 826 * type and no values. 827 * 828 * @param opType The operation type for this password policy state 829 * operation. 830 */ 831 public PasswordPolicyStateOperation(final int opType) 832 { 833 this(opType, NO_VALUES); 834 } 835 836 837 838 /** 839 * Creates a new password policy state operation with the specified operation 840 * type and set of values. 841 * 842 * @param opType The operation type for this password policy state 843 * operation. 844 * @param values The set of values for this password policy state operation. 845 */ 846 public PasswordPolicyStateOperation(final int opType, 847 final ASN1OctetString[] values) 848 { 849 this.opType = opType; 850 851 if (values == null) 852 { 853 this.values = NO_VALUES; 854 } 855 else 856 { 857 this.values = values; 858 } 859 } 860 861 862 863 /** 864 * Creates a new password policy state operation that may be used to request 865 * the DN of the password policy configuration entry for the user. The result 866 * returned should include an operation of type 867 * {@link #OP_TYPE_GET_PW_POLICY_DN} with a single string value that is the 868 * DN of the password policy configuration entry. 869 * 870 * @return The created password policy state operation. 871 */ 872 public static PasswordPolicyStateOperation 873 createGetPasswordPolicyDNOperation() 874 { 875 return new PasswordPolicyStateOperation(OP_TYPE_GET_PW_POLICY_DN); 876 } 877 878 879 880 /** 881 * Creates a new password policy state operation that may be used to determine 882 * whether the user account is disabled. The result returned should include 883 * an operation of type {@link #OP_TYPE_GET_ACCOUNT_DISABLED_STATE} with a 884 * single boolean value of {@code true} if the account is disabled, or 885 * {@code false} if the account is not disabled. 886 * 887 * @return The created password policy state operation. 888 */ 889 public static PasswordPolicyStateOperation 890 createGetAccountDisabledStateOperation() 891 { 892 return new PasswordPolicyStateOperation(OP_TYPE_GET_ACCOUNT_DISABLED_STATE); 893 } 894 895 896 897 /** 898 * Creates a new password policy state operation that may be used to specify 899 * whether the user account is disabled. The result returned should include 900 * an operation of type {@link #OP_TYPE_GET_ACCOUNT_DISABLED_STATE} with a 901 * single boolean value of {@code true} if the account has been disabled, or 902 * {@code false} if the account is not disabled. 903 * 904 * @param isDisabled Indicates whether the user account should be disabled. 905 * 906 * @return The created password policy state operation. 907 */ 908 public static PasswordPolicyStateOperation 909 createSetAccountDisabledStateOperation( 910 final boolean isDisabled) 911 { 912 final ASN1OctetString[] values = 913 { 914 new ASN1OctetString(String.valueOf(isDisabled)) 915 }; 916 917 return new PasswordPolicyStateOperation(OP_TYPE_SET_ACCOUNT_DISABLED_STATE, 918 values); 919 } 920 921 922 923 /** 924 * Creates a new password policy state operation that may be used to clear 925 * the user account disabled state in the user's entry. The result returned 926 * should include an operation of type 927 * {@link #OP_TYPE_GET_ACCOUNT_DISABLED_STATE} with a single boolean value of 928 * {@code true} if the account is disabled, or {@code false} if the account is 929 * not disabled. 930 * 931 * @return The created password policy state operation. 932 */ 933 public static PasswordPolicyStateOperation 934 createClearAccountDisabledStateOperation() 935 { 936 return new PasswordPolicyStateOperation( 937 OP_TYPE_CLEAR_ACCOUNT_DISABLED_STATE); 938 } 939 940 941 942 /** 943 * Creates a new password policy state operation that may be used to retrieve 944 * the time that the user's account will become active. The result returned 945 * should include an operation of type 946 * {@link #OP_TYPE_GET_ACCOUNT_ACTIVATION_TIME} with a single string value 947 * that is the generalized time representation of the account activation time, 948 * or a {@code null} value if the account does not have an activation time. 949 * 950 * @return The created password policy state operation. 951 */ 952 public static PasswordPolicyStateOperation 953 createGetAccountActivationTimeOperation() 954 { 955 return new PasswordPolicyStateOperation( 956 OP_TYPE_GET_ACCOUNT_ACTIVATION_TIME); 957 } 958 959 960 961 /** 962 * Creates a new password policy state operation that may be used to set the 963 * time that the user's account expires. The result returned should include 964 * an operation of type {@link #OP_TYPE_GET_ACCOUNT_ACTIVATION_TIME} with a 965 * single string value that is the generalized time representation of the 966 * account activation time, or a {@code null} value if the account does not 967 * have an activation time. 968 * 969 * @param expirationTime The time that the user's account should expire. It 970 * may be {@code null} if the server should use the 971 * current time. 972 * 973 * @return The created password policy state operation. 974 */ 975 public static PasswordPolicyStateOperation 976 createSetAccountActivationTimeOperation( 977 final Date expirationTime) 978 { 979 return new PasswordPolicyStateOperation(OP_TYPE_SET_ACCOUNT_ACTIVATION_TIME, 980 createValues(expirationTime)); 981 } 982 983 984 985 /** 986 * Creates a new password policy state operation that may be used to clear 987 * the account expiration time in the user's entry. The result returned 988 * should include an operation of type 989 * {@link #OP_TYPE_GET_ACCOUNT_ACTIVATION_TIME} with a single string value 990 * that is the generalized time representation of the account activation time, 991 * or a {@code null} value if the account does not have an activation time. 992 * 993 * @return The created password policy state operation. 994 */ 995 public static PasswordPolicyStateOperation 996 createClearAccountActivationTimeOperation() 997 { 998 return new PasswordPolicyStateOperation( 999 OP_TYPE_CLEAR_ACCOUNT_ACTIVATION_TIME); 1000 } 1001 1002 1003 1004 /** 1005 * Creates a new password policy state operation that may be used to determine 1006 * the length of time in seconds until the user's account becomes active. The 1007 * result returned should include an operation of type 1008 * {@link #OP_TYPE_GET_SECONDS_UNTIL_ACCOUNT_ACTIVATION} with a single integer 1009 * value representing the number of seconds until the account becomes active, 1010 * or a {@code null} value if the account does not have an activation time. 1011 * 1012 * @return The created password policy state operation. 1013 */ 1014 public static PasswordPolicyStateOperation 1015 createGetSecondsUntilAccountActivationOperation() 1016 { 1017 return new PasswordPolicyStateOperation( 1018 OP_TYPE_GET_SECONDS_UNTIL_ACCOUNT_ACTIVATION); 1019 } 1020 1021 1022 1023 /** 1024 * Creates a new password policy state operation that may be used to retrieve 1025 * the time that the user's account expires. The result returned should 1026 * include an operation of type {@link #OP_TYPE_GET_ACCOUNT_EXPIRATION_TIME} 1027 * with a single string value that is the generalized time representation of 1028 * the account expiration time, or a {@code null} value if the account does 1029 * not have an expiration time. 1030 * 1031 * @return The created password policy state operation. 1032 */ 1033 public static PasswordPolicyStateOperation 1034 createGetAccountExpirationTimeOperation() 1035 { 1036 return new PasswordPolicyStateOperation( 1037 OP_TYPE_GET_ACCOUNT_EXPIRATION_TIME); 1038 } 1039 1040 1041 1042 /** 1043 * Creates a new password policy state operation that may be used to set the 1044 * time that the user's account expires. The result returned should include 1045 * an operation of type {@link #OP_TYPE_GET_ACCOUNT_EXPIRATION_TIME} with a 1046 * single string value that is the generalized time representation of the 1047 * account expiration time, or a {@code null} value if the account does not 1048 * have an expiration time. 1049 * 1050 * @param expirationTime The time that the user's account should expire. It 1051 * may be {@code null} if the server should use the 1052 * current time. 1053 * 1054 * @return The created password policy state operation. 1055 */ 1056 public static PasswordPolicyStateOperation 1057 createSetAccountExpirationTimeOperation( 1058 final Date expirationTime) 1059 { 1060 return new PasswordPolicyStateOperation(OP_TYPE_SET_ACCOUNT_EXPIRATION_TIME, 1061 createValues(expirationTime)); 1062 } 1063 1064 1065 1066 /** 1067 * Creates a new password policy state operation that may be used to clear 1068 * the account expiration time in the user's entry. The result returned 1069 * should include an operation of type 1070 * {@link #OP_TYPE_GET_ACCOUNT_EXPIRATION_TIME} with a single string value 1071 * that is the generalized time representation of the account expiration time, 1072 * or a {@code null} value if the account does not have an expiration time. 1073 * 1074 * @return The created password policy state operation. 1075 */ 1076 public static PasswordPolicyStateOperation 1077 createClearAccountExpirationTimeOperation() 1078 { 1079 return new PasswordPolicyStateOperation( 1080 OP_TYPE_CLEAR_ACCOUNT_EXPIRATION_TIME); 1081 } 1082 1083 1084 1085 /** 1086 * Creates a new password policy state operation that may be used to determine 1087 * the length of time in seconds until the user's account is expired. The 1088 * result returned should include an operation of type 1089 * {@link #OP_TYPE_GET_SECONDS_UNTIL_ACCOUNT_EXPIRATION} with a single integer 1090 * value representing the number of seconds until the account will expire, or 1091 * a {@code null} value if the account does not have an expiration time. 1092 * 1093 * @return The created password policy state operation. 1094 */ 1095 public static PasswordPolicyStateOperation 1096 createGetSecondsUntilAccountExpirationOperation() 1097 { 1098 return new PasswordPolicyStateOperation( 1099 OP_TYPE_GET_SECONDS_UNTIL_ACCOUNT_EXPIRATION); 1100 } 1101 1102 1103 1104 /** 1105 * Creates a new password policy state operation that may be used to determine 1106 * when the user's password was last changed. The result returned should 1107 * include an operation of type {@link #OP_TYPE_GET_PW_CHANGED_TIME} with a 1108 * single string value that is the generalized time representation of the 1109 * time the password was last changed. 1110 * 1111 * @return The created password policy state operation. 1112 */ 1113 public static PasswordPolicyStateOperation 1114 createGetPasswordChangedTimeOperation() 1115 { 1116 return new PasswordPolicyStateOperation(OP_TYPE_GET_PW_CHANGED_TIME); 1117 } 1118 1119 1120 1121 /** 1122 * Creates a new password policy state operation that may be used to specify 1123 * when the user's password was last changed. The result returned should 1124 * include an operation of type {@link #OP_TYPE_GET_PW_CHANGED_TIME} with a 1125 * single string value that is the generalized time representation of the 1126 * time the password was last changed. 1127 * 1128 * @param passwordChangedTime The time the user's password was last changed. 1129 * It may be {@code null} if the server should 1130 * use the current time. 1131 * 1132 * @return The created password policy state operation. 1133 */ 1134 public static PasswordPolicyStateOperation 1135 createSetPasswordChangedTimeOperation( 1136 final Date passwordChangedTime) 1137 { 1138 return new PasswordPolicyStateOperation(OP_TYPE_SET_PW_CHANGED_TIME, 1139 createValues(passwordChangedTime)); 1140 } 1141 1142 1143 1144 /** 1145 * Creates a new password policy state operation that may be used to clear 1146 * the password changed time from a user's entry. The result returned should 1147 * include an operation of type {@link #OP_TYPE_GET_PW_CHANGED_TIME} with a 1148 * single string value that is the generalized time representation of the 1149 * time the password was last changed, or {@code null} if it can no longer be 1150 * determined. 1151 * 1152 * @return The created password policy state operation. 1153 */ 1154 public static PasswordPolicyStateOperation 1155 createClearPasswordChangedTimeOperation() 1156 { 1157 return new PasswordPolicyStateOperation(OP_TYPE_CLEAR_PW_CHANGED_TIME); 1158 } 1159 1160 1161 1162 /** 1163 * Creates a new password policy state operation that may be used to determine 1164 * when the user first received a password expiration warning. The result 1165 * returned should include an operation of type 1166 * {@link #OP_TYPE_GET_PW_EXPIRATION_WARNED_TIME} with a single string value 1167 * that is the generalized time representation of the time the user received 1168 * the first expiration warning. 1169 * 1170 * @return The created password policy state operation. 1171 */ 1172 public static PasswordPolicyStateOperation 1173 createGetPasswordExpirationWarnedTimeOperation() 1174 { 1175 return new PasswordPolicyStateOperation( 1176 OP_TYPE_GET_PW_EXPIRATION_WARNED_TIME); 1177 } 1178 1179 1180 1181 /** 1182 * Creates a new password policy state operation that may be used to specify 1183 * when the user first received a password expiration warning. The result 1184 * returned should include an operation of type 1185 * {@link #OP_TYPE_GET_PW_EXPIRATION_WARNED_TIME} with a single string value 1186 * that is the generalized time representation of the time the user received 1187 * the first expiration warning. 1188 * 1189 * @param passwordExpirationWarnedTime The password expiration warned time 1190 * for the user. It may be {@code null} 1191 * if the server should use the current 1192 * time. 1193 * 1194 * @return The created password policy state operation. 1195 */ 1196 public static PasswordPolicyStateOperation 1197 createSetPasswordExpirationWarnedTimeOperation( 1198 final Date passwordExpirationWarnedTime) 1199 { 1200 return new PasswordPolicyStateOperation( 1201 OP_TYPE_SET_PW_EXPIRATION_WARNED_TIME, 1202 createValues(passwordExpirationWarnedTime)); 1203 } 1204 1205 1206 1207 /** 1208 * Creates a new password policy state operation that may be used to clear the 1209 * password expiration warned time from the user's entry. The result returned 1210 * should include an operation of type 1211 * {@link #OP_TYPE_GET_PW_EXPIRATION_WARNED_TIME} with a single string value 1212 * that is the generalized time representation of the time the user received 1213 * the first expiration warning. 1214 * 1215 * @return The created password policy state operation. 1216 */ 1217 public static PasswordPolicyStateOperation 1218 createClearPasswordExpirationWarnedTimeOperation() 1219 { 1220 return new PasswordPolicyStateOperation( 1221 OP_TYPE_CLEAR_PW_EXPIRATION_WARNED_TIME); 1222 } 1223 1224 1225 1226 /** 1227 * Creates a new password policy state operation that may be used to determine 1228 * the length of time in seconds until the user's password expires. The 1229 * result returned should include an operation of type 1230 * {@link #OP_TYPE_GET_SECONDS_UNTIL_PW_EXPIRATION} with a single integer 1231 * value that is the number of seconds until the user's password expires, or 1232 * a {@code null} value if the user's password will not expire. 1233 * 1234 * @return The created password policy state operation. 1235 */ 1236 public static PasswordPolicyStateOperation 1237 createGetSecondsUntilPasswordExpirationOperation() 1238 { 1239 return new PasswordPolicyStateOperation( 1240 OP_TYPE_GET_SECONDS_UNTIL_PW_EXPIRATION); 1241 } 1242 1243 1244 1245 /** 1246 * Creates a new password policy state operation that may be used to determine 1247 * the length of time in seconds until the user is eligible to start receiving 1248 * password expiration warnings. The result returned should include an 1249 * operation of type {@link #OP_TYPE_GET_SECONDS_UNTIL_PW_EXPIRATION_WARNING} 1250 * with a single integer value that is the number of seconds until the user is 1251 * eligible to receive the first expiration warning, or a {@code null} value 1252 * if the user's password will not expire. 1253 * 1254 * @return The created password policy state operation. 1255 */ 1256 public static PasswordPolicyStateOperation 1257 createGetSecondsUntilPasswordExpirationWarningOperation() 1258 { 1259 return new PasswordPolicyStateOperation( 1260 OP_TYPE_GET_SECONDS_UNTIL_PW_EXPIRATION_WARNING); 1261 } 1262 1263 1264 1265 /** 1266 * Creates a new password policy state operation that may be used to retrieve 1267 * the times that the user has unsuccessfully tried to authenticate since the 1268 * last successful authentication. The result returned should include an 1269 * operation of type {@link #OP_TYPE_GET_AUTH_FAILURE_TIMES} with an array of 1270 * string values representing the timestamps (in generalized time format) of 1271 * the authentication failures. 1272 * 1273 * @return The created password policy state operation. 1274 */ 1275 public static PasswordPolicyStateOperation 1276 createGetAuthenticationFailureTimesOperation() 1277 { 1278 return new PasswordPolicyStateOperation(OP_TYPE_GET_AUTH_FAILURE_TIMES); 1279 } 1280 1281 1282 1283 /** 1284 * Creates a new password policy state operation that may be used to add the 1285 * current time to the set of times that the user has unsuccessfully tried to 1286 * authenticate since the last successful authentication. The result returned 1287 * should include an operation of type {@link #OP_TYPE_GET_AUTH_FAILURE_TIMES} 1288 * with an array of string values representing the timestamps (in generalized 1289 * time format) of the authentication failures. 1290 * 1291 * @return The created password policy state operation. 1292 */ 1293 public static PasswordPolicyStateOperation 1294 createAddAuthenticationFailureTimeOperation() 1295 { 1296 return createAddAuthenticationFailureTimeOperation(null); 1297 } 1298 1299 1300 1301 /** 1302 * Creates a new password policy state operation that may be used to add the 1303 * specified values to the set of times that the user has unsuccessfully tried 1304 * to authenticate since the last successful authentication. The result 1305 * returned should include an operation of type 1306 * {@link #OP_TYPE_GET_AUTH_FAILURE_TIMES} with an array of string values 1307 * representing the timestamps (in generalized time format) of the 1308 * authentication failures. 1309 * 1310 * @param authFailureTimes The set of authentication failure time values to 1311 * add. It may be {@code null} or empty if the 1312 * server should add the current time. 1313 * 1314 * @return The created password policy state operation. 1315 */ 1316 public static PasswordPolicyStateOperation 1317 createAddAuthenticationFailureTimeOperation( 1318 final Date[] authFailureTimes) 1319 { 1320 return new PasswordPolicyStateOperation(OP_TYPE_ADD_AUTH_FAILURE_TIME, 1321 createValues(authFailureTimes)); 1322 } 1323 1324 1325 1326 /** 1327 * Creates a new password policy state operation that may be used to specify 1328 * the set of times that the user has unsuccessfully tried to authenticate 1329 * since the last successful authentication. The result returned should 1330 * include an operation of type {@link #OP_TYPE_GET_AUTH_FAILURE_TIMES} with 1331 * an array of string values representing the timestamps (in generalized time 1332 * format) of the authentication failures. 1333 * 1334 * @param authFailureTimes The set of times that the user has unsuccessfully 1335 * tried to authenticate since the last successful 1336 * authentication. It may be {@code null} or empty 1337 * if the server should use the current time as the 1338 * only failure time. 1339 * 1340 * @return The created password policy state operation. 1341 */ 1342 public static PasswordPolicyStateOperation 1343 createSetAuthenticationFailureTimesOperation( 1344 final Date[] authFailureTimes) 1345 { 1346 return new PasswordPolicyStateOperation(OP_TYPE_SET_AUTH_FAILURE_TIMES, 1347 createValues(authFailureTimes)); 1348 } 1349 1350 1351 1352 /** 1353 * Creates a new password policy state operation that may be used to clear the 1354 * set of times that the user has unsuccessfully tried to authenticate since 1355 * the last successful authentication. The result returned should include an 1356 * operation of type {@link #OP_TYPE_GET_AUTH_FAILURE_TIMES} with an array of 1357 * string values representing the timestamps (in generalized time format) of 1358 * the authentication failures. 1359 * 1360 * @return The created password policy state operation. 1361 */ 1362 public static PasswordPolicyStateOperation 1363 createClearAuthenticationFailureTimesOperation() 1364 { 1365 return new PasswordPolicyStateOperation(OP_TYPE_CLEAR_AUTH_FAILURE_TIMES); 1366 } 1367 1368 1369 1370 /** 1371 * Creates a new password policy state operation that may be used to determine 1372 * the length of time in seconds until the user's account is automatically 1373 * unlocked after too many failed authentication attempts. The result 1374 * returned should include an operation of type 1375 * {@link #OP_TYPE_GET_SECONDS_UNTIL_AUTH_FAILURE_UNLOCK} with a single 1376 * integer value that represents the number of seconds until the account 1377 * becomes unlocked, or a {@code null} value if the account is not temporarily 1378 * locked as a result of authentication failures. 1379 * 1380 * @return The created password policy state operation. 1381 */ 1382 public static PasswordPolicyStateOperation 1383 createGetSecondsUntilAuthenticationFailureUnlockOperation() 1384 { 1385 return new PasswordPolicyStateOperation( 1386 OP_TYPE_GET_SECONDS_UNTIL_AUTH_FAILURE_UNLOCK); 1387 } 1388 1389 1390 1391 /** 1392 * Creates a new password policy state operation that may be used to determine 1393 * the number of authentication failures required to lock the user's account. 1394 * The result returned should include an operation of type 1395 * {@link #OP_TYPE_GET_REMAINING_AUTH_FAILURE_COUNT} with a single integer 1396 * value that represents the number of authentication failures that a user 1397 * will be permitted before the account is locked, or a {@code null} value if 1398 * the password policy is not configured to lock accounts as a result of too 1399 * many failed authentication attempts. 1400 * 1401 * @return The created password policy state operation. 1402 */ 1403 public static PasswordPolicyStateOperation 1404 createGetRemainingAuthenticationFailureCountOperation() 1405 { 1406 return new PasswordPolicyStateOperation( 1407 OP_TYPE_GET_REMAINING_AUTH_FAILURE_COUNT); 1408 } 1409 1410 1411 1412 /** 1413 * Creates a new password policy state operation that may be used to determine 1414 * the time that the user last successfully authenticated to the server. The 1415 * result returned should include an operation of type 1416 * {@link #OP_TYPE_GET_LAST_LOGIN_TIME} with a single string value that is 1417 * the generalized time representation of the user's last login time, or a 1418 * {@code null} value if no last login time is available. 1419 * 1420 * @return The created password policy state operation. 1421 */ 1422 public static PasswordPolicyStateOperation createGetLastLoginTimeOperation() 1423 { 1424 return new PasswordPolicyStateOperation(OP_TYPE_GET_LAST_LOGIN_TIME); 1425 } 1426 1427 1428 1429 /** 1430 * Creates a new password policy state operation that may be used to set 1431 * the time that the user last successfully authenticated to the server. The 1432 * result returned should include an operation of type 1433 * {@link #OP_TYPE_GET_LAST_LOGIN_TIME} with a single string value that is 1434 * the generalized time representation of the user's last login time, or a 1435 * {@code null} value if no last login time is available. 1436 * 1437 * @param lastLoginTime The last login time to set in the user's entry. It 1438 * may be {@code null} if the server should use the 1439 * current time. 1440 * 1441 * @return The created password policy state operation. 1442 */ 1443 public static PasswordPolicyStateOperation 1444 createSetLastLoginTimeOperation(final Date lastLoginTime) 1445 { 1446 return new PasswordPolicyStateOperation(OP_TYPE_SET_LAST_LOGIN_TIME, 1447 createValues(lastLoginTime)); 1448 } 1449 1450 1451 1452 /** 1453 * Creates a new password policy state operation that may be used to clear 1454 * the last login time from the user's entry. The result returned should 1455 * include an operation of type {@link #OP_TYPE_GET_LAST_LOGIN_TIME} with a 1456 * single string value that is the generalized time representation of the 1457 * user's last login time, or a {@code null} value if no last login time is 1458 * available. 1459 * 1460 * @return The created password policy state operation. 1461 */ 1462 public static PasswordPolicyStateOperation createClearLastLoginTimeOperation() 1463 { 1464 return new PasswordPolicyStateOperation(OP_TYPE_CLEAR_LAST_LOGIN_TIME); 1465 } 1466 1467 1468 1469 /** 1470 * Creates a new password policy state operation that may be used to determine 1471 * the IP address from which the user last successfully authenticated to the 1472 * server. The result returned should include an operation of type 1473 * {@link #OP_TYPE_GET_LAST_LOGIN_IP_ADDRESS} with a single string value that 1474 * is the user's last login IP address, or a {@code null} value if no last 1475 * login IP address is available. 1476 * 1477 * @return The created password policy state operation. 1478 */ 1479 public static PasswordPolicyStateOperation 1480 createGetLastLoginIPAddressOperation() 1481 { 1482 return new PasswordPolicyStateOperation(OP_TYPE_GET_LAST_LOGIN_IP_ADDRESS); 1483 } 1484 1485 1486 1487 /** 1488 * Creates a new password policy state operation that may be used to set 1489 * the IP address from which the user last successfully authenticated to the 1490 * server. The result returned should include an operation of type 1491 * {@link #OP_TYPE_GET_LAST_LOGIN_IP_ADDRESS} with a single string value that 1492 * is the user's last login IP address, or a {@code null} value if no last 1493 * login IP address is available. 1494 * 1495 * @param lastLoginIPAddress The last login IP address to set in the user's 1496 * entry. It must not be {@code null}. 1497 * 1498 * @return The created password policy state operation. 1499 */ 1500 public static PasswordPolicyStateOperation 1501 createSetLastLoginIPAddressOperation( 1502 final String lastLoginIPAddress) 1503 { 1504 final ASN1OctetString[] values = 1505 { 1506 new ASN1OctetString(lastLoginIPAddress) 1507 }; 1508 1509 return new PasswordPolicyStateOperation(OP_TYPE_SET_LAST_LOGIN_IP_ADDRESS, 1510 values); 1511 } 1512 1513 1514 1515 /** 1516 * Creates a new password policy state operation that may be used to clear 1517 * the last login IP address from the user's entry. The result returned 1518 * should include an operation of type 1519 * {@link #OP_TYPE_GET_LAST_LOGIN_IP_ADDRESS} with a single string value that 1520 * is the user's last login IP address, or a {@code null} value if no last 1521 * login IP address is available. 1522 * 1523 * @return The created password policy state operation. 1524 */ 1525 public static PasswordPolicyStateOperation 1526 createClearLastLoginIPAddressOperation() 1527 { 1528 return new PasswordPolicyStateOperation( 1529 OP_TYPE_CLEAR_LAST_LOGIN_IP_ADDRESS); 1530 } 1531 1532 1533 1534 /** 1535 * Creates a new password policy state operation that may be used to determine 1536 * the length of time in seconds until the user's account is locked due to 1537 * inactivity. The result returned should include an operation of type 1538 * {@link #OP_TYPE_GET_SECONDS_UNTIL_IDLE_LOCKOUT} with a single integer value 1539 * that represents the number of seconds until the user's account is locked as 1540 * a result of being idle for too long, or a {@code null} value if no idle 1541 * account lockout is configured. 1542 * 1543 * @return The created password policy state operation. 1544 */ 1545 public static PasswordPolicyStateOperation 1546 createGetSecondsUntilIdleLockoutOperation() 1547 { 1548 return new PasswordPolicyStateOperation( 1549 OP_TYPE_GET_SECONDS_UNTIL_IDLE_LOCKOUT); 1550 } 1551 1552 1553 1554 /** 1555 * Creates a new password policy state operation that may be used to determine 1556 * whether the user's password has been reset by an administrator and must be 1557 * changed before performing any other operations. The result returned should 1558 * include an operation of type {@link #OP_TYPE_GET_PW_RESET_STATE} with a 1559 * single boolean value of {@code true} if the user's password must be changed 1560 * before the account can be used, or {@code false} if not. 1561 * 1562 * @return The created password policy state operation. 1563 */ 1564 public static PasswordPolicyStateOperation 1565 createGetPasswordResetStateOperation() 1566 { 1567 return new PasswordPolicyStateOperation(OP_TYPE_GET_PW_RESET_STATE); 1568 } 1569 1570 1571 1572 /** 1573 * Creates a new password policy state operation that may be used to specify 1574 * whether the user's password has been reset by an administrator and must be 1575 * changed before performing any other operations. The result returned should 1576 * include an operation of type {@link #OP_TYPE_GET_PW_RESET_STATE} with a 1577 * single boolean value of {@code true} if the user's password must be changed 1578 * before the account can be used, or {@code false} if not. 1579 * 1580 * @param isReset Specifies whether the user's password must be changed 1581 * before performing any other operations. 1582 * 1583 * @return The created password policy state operation. 1584 */ 1585 public static PasswordPolicyStateOperation 1586 createSetPasswordResetStateOperation(final boolean isReset) 1587 { 1588 final ASN1OctetString[] values = 1589 { 1590 new ASN1OctetString(String.valueOf(isReset)) 1591 }; 1592 1593 return new PasswordPolicyStateOperation(OP_TYPE_SET_PW_RESET_STATE, values); 1594 } 1595 1596 1597 1598 /** 1599 * Creates a new password policy state operation that may be used to clear the 1600 * password reset state information in the user's entry. The result returned 1601 * should include an operation of type {@link #OP_TYPE_GET_PW_RESET_STATE} 1602 * with a single boolean value of {@code true} if the user's password must be 1603 * changed before the account can be used, or {@code false} if not. 1604 * 1605 * @return The created password policy state operation. 1606 */ 1607 public static PasswordPolicyStateOperation 1608 createClearPasswordResetStateOperation() 1609 { 1610 return new PasswordPolicyStateOperation(OP_TYPE_CLEAR_PW_RESET_STATE); 1611 } 1612 1613 1614 1615 /** 1616 * Creates a new password policy state operation that may be used to determine 1617 * the length of time in seconds that the user has left to change his/her 1618 * password after an administrative reset before the account is locked. The 1619 * result returned should include an operation of type 1620 * {@link #OP_TYPE_GET_SECONDS_UNTIL_PW_RESET_LOCKOUT} with a single integer 1621 * value that represents the number of seconds until the user's account will 1622 * be locked unless the password is reset, or a {@code null} value if the 1623 * user's password is not in a "must change" state. 1624 * 1625 * @return The created password policy state operation. 1626 */ 1627 public static PasswordPolicyStateOperation 1628 createGetSecondsUntilPasswordResetLockoutOperation() 1629 { 1630 return new PasswordPolicyStateOperation( 1631 OP_TYPE_GET_SECONDS_UNTIL_PW_RESET_LOCKOUT); 1632 } 1633 1634 1635 1636 /** 1637 * Creates a new password policy state operation that may be used to retrieve 1638 * the set of times that the user has authenticated using grace logins since 1639 * his/her password expired. The result returned should include an operation 1640 * of type {@link #OP_TYPE_GET_GRACE_LOGIN_USE_TIMES} with an array of string 1641 * values in generalized time format. 1642 * 1643 * @return The created password policy state operation. 1644 */ 1645 public static PasswordPolicyStateOperation 1646 createGetGraceLoginUseTimesOperation() 1647 { 1648 return new PasswordPolicyStateOperation(OP_TYPE_GET_GRACE_LOGIN_USE_TIMES); 1649 } 1650 1651 1652 1653 /** 1654 * Creates a new password policy state operation that may be used to add the 1655 * current time to the set of times that the user has authenticated using 1656 * grace logins since his/her password expired. The result returned should 1657 * include an operation of type {@link #OP_TYPE_GET_GRACE_LOGIN_USE_TIMES} 1658 * with an array of string values in generalized time format. 1659 * 1660 * @return The created password policy state operation. 1661 */ 1662 public static PasswordPolicyStateOperation 1663 createAddGraceLoginUseTimeOperation() 1664 { 1665 return createAddGraceLoginUseTimeOperation(null); 1666 } 1667 1668 1669 1670 /** 1671 * Creates a new password policy state operation that may be used to add the 1672 * current time to the set of times that the user has authenticated using 1673 * grace logins since his/her password expired. The result returned should 1674 * include an operation of type {@link #OP_TYPE_GET_GRACE_LOGIN_USE_TIMES} 1675 * with an array of string values in generalized time format. 1676 * 1677 * @param graceLoginUseTimes The set of grace login use times to add. It 1678 * may be {@code null} or empty if the server 1679 * should add the current time to the set of grace 1680 * login times. 1681 * 1682 * @return The created password policy state operation. 1683 */ 1684 public static PasswordPolicyStateOperation 1685 createAddGraceLoginUseTimeOperation( 1686 final Date[] graceLoginUseTimes) 1687 { 1688 return new PasswordPolicyStateOperation(OP_TYPE_ADD_GRACE_LOGIN_USE_TIME, 1689 createValues(graceLoginUseTimes)); 1690 } 1691 1692 1693 1694 /** 1695 * Creates a new password policy state operation that may be used to specify 1696 * the set of times that the user has authenticated using grace logins since 1697 * his/her password expired. The result returned should include an operation 1698 * of type {@link #OP_TYPE_GET_GRACE_LOGIN_USE_TIMES} with an array of string 1699 * values in generalized time format. 1700 * 1701 * @param graceLoginUseTimes The set of times that the user has 1702 * authenticated using grace logins since his/her 1703 * password expired. It amy be {@code null} or 1704 * empty if the server should use the current time 1705 * as the only grace login use time. 1706 * 1707 * @return The created password policy state operation. 1708 */ 1709 public static PasswordPolicyStateOperation 1710 createSetGraceLoginUseTimesOperation( 1711 final Date[] graceLoginUseTimes) 1712 { 1713 return new PasswordPolicyStateOperation(OP_TYPE_SET_GRACE_LOGIN_USE_TIMES, 1714 createValues(graceLoginUseTimes)); 1715 } 1716 1717 1718 1719 /** 1720 * Creates a new password policy state operation that may be used to clear 1721 * the set of times that the user has authenticated using grace logins since 1722 * his/her password expired. The result returned should include an operation 1723 * of type {@link #OP_TYPE_GET_GRACE_LOGIN_USE_TIMES} with an array of string 1724 * values in generalized time format. 1725 * 1726 * @return The created password policy state operation. 1727 */ 1728 public static PasswordPolicyStateOperation 1729 createClearGraceLoginUseTimesOperation() 1730 { 1731 return new PasswordPolicyStateOperation( 1732 OP_TYPE_CLEAR_GRACE_LOGIN_USE_TIMES); 1733 } 1734 1735 1736 1737 /** 1738 * Creates a new password policy state operation that may be used to retrieve 1739 * the number of remaining grace logins available to the user. The result 1740 * returned should include an operation of type 1741 * {@link #OP_TYPE_GET_REMAINING_GRACE_LOGIN_COUNT} with a single integer 1742 * value that represents the number of remaining grace logins, or a 1743 * {@code null} value if grace login functionality is not enabled for the 1744 * user. 1745 * 1746 * @return The created password policy state operation. 1747 */ 1748 public static PasswordPolicyStateOperation 1749 createGetRemainingGraceLoginCountOperation() 1750 { 1751 return new PasswordPolicyStateOperation( 1752 OP_TYPE_GET_REMAINING_GRACE_LOGIN_COUNT); 1753 } 1754 1755 1756 1757 /** 1758 * Creates a new password policy state operation that may be used to retrieve 1759 * the last required password change time that with which the user has 1760 * complied. The result returned should include an operation of type 1761 * {@link #OP_TYPE_GET_PW_CHANGED_BY_REQUIRED_TIME} with a single string 1762 * value that is the generalized time representation of the most recent 1763 * required password change time with which the user complied, or a 1764 * {@code null} value if this is not available for the user. 1765 * 1766 * @return The created password policy state operation. 1767 */ 1768 public static PasswordPolicyStateOperation 1769 createGetPasswordChangedByRequiredTimeOperation() 1770 { 1771 return new PasswordPolicyStateOperation( 1772 OP_TYPE_GET_PW_CHANGED_BY_REQUIRED_TIME); 1773 } 1774 1775 1776 1777 /** 1778 * Creates a new password policy state operation that may be used to update 1779 * the user's entry to indicate that he/she has complied with the required 1780 * password change time. The result returned should include an operation of 1781 * type {@link #OP_TYPE_GET_PW_CHANGED_BY_REQUIRED_TIME} with a single string 1782 * value that is the generalized time representation of the most recent 1783 * required password change time with which the user complied, or a 1784 * {@code null} value if this is not available for the user. 1785 * 1786 * @return The created password policy state operation. 1787 */ 1788 public static PasswordPolicyStateOperation 1789 createSetPasswordChangedByRequiredTimeOperation() 1790 { 1791 return createSetPasswordChangedByRequiredTimeOperation(null); 1792 } 1793 1794 1795 1796 /** 1797 * Creates a new password policy state operation that may be used to update 1798 * the user's entry to indicate that he/she has complied with the required 1799 * password change time. The result returned should include an operation of 1800 * type {@link #OP_TYPE_GET_PW_CHANGED_BY_REQUIRED_TIME} with a single string 1801 * value that is the generalized time representation of the most recent 1802 * required password change time with which the user complied, or a 1803 * {@code null} value if this is not available for the user. 1804 * 1805 * @param requiredTime The required password changed time with which the 1806 * user has complied. It may be {@code null} if the 1807 * server should use the most recent required change 1808 * time. 1809 * 1810 * @return The created password policy state operation. 1811 */ 1812 public static PasswordPolicyStateOperation 1813 createSetPasswordChangedByRequiredTimeOperation( 1814 final Date requiredTime) 1815 { 1816 return new PasswordPolicyStateOperation( 1817 OP_TYPE_SET_PW_CHANGED_BY_REQUIRED_TIME, createValues(requiredTime)); 1818 } 1819 1820 1821 1822 /** 1823 * Creates a new password policy state operation that may be used to clear 1824 * the last required password change time from the user's entry. The result 1825 * returned should include an operation of type 1826 * {@link #OP_TYPE_GET_PW_CHANGED_BY_REQUIRED_TIME} with a single string value 1827 * that is the generalized time representation of the most recent required 1828 * password change time with which the user complied, or a {@code null} value 1829 * if this is not available for the user. 1830 * 1831 * @return The created password policy state operation. 1832 */ 1833 public static PasswordPolicyStateOperation 1834 createClearPasswordChangedByRequiredTimeOperation() 1835 { 1836 return new PasswordPolicyStateOperation( 1837 OP_TYPE_CLEAR_PW_CHANGED_BY_REQUIRED_TIME); 1838 } 1839 1840 1841 1842 /** 1843 * Creates a new password policy state operation that may be used to retrieve 1844 * the length of time in seconds until the required password change time 1845 * arrives. The result returned should include an operation of type 1846 * {@link #OP_TYPE_GET_SECONDS_UNTIL_REQUIRED_CHANGE_TIME} with a single 1847 * integer value that represents the number of seconds before the user will 1848 * be required to change his/her password as a result of the 1849 * require-change-by-time property, or a {@code null} value if the user is 1850 * not required to change their password for this reason. 1851 * 1852 * @return The created password policy state operation. 1853 */ 1854 public static PasswordPolicyStateOperation 1855 createGetSecondsUntilRequiredChangeTimeOperation() 1856 { 1857 return new PasswordPolicyStateOperation( 1858 OP_TYPE_GET_SECONDS_UNTIL_REQUIRED_CHANGE_TIME); 1859 } 1860 1861 1862 1863 /** 1864 * Creates a new password policy state operation that may be used to retrieve 1865 * the password history values stored in the user's entry. The result 1866 * returned should include an operation of type 1867 * {@link #OP_TYPE_GET_PW_HISTORY} with an array of strings representing the 1868 * user's password history content. 1869 * 1870 * @return The created password policy state operation. 1871 * 1872 * @deprecated This method has been deprecated in favor of the 1873 * {@link #createGetPasswordHistoryCountOperation} method. 1874 */ 1875 @Deprecated() 1876 @SuppressWarnings("deprecation") 1877 public static PasswordPolicyStateOperation createGetPasswordHistoryOperation() 1878 { 1879 return new PasswordPolicyStateOperation(OP_TYPE_GET_PW_HISTORY); 1880 } 1881 1882 1883 1884 /** 1885 * Creates a new password policy state operation that may be used to clear the 1886 * password history values stored in the user's entry. The result returned 1887 * should include an operation of type {@link #OP_TYPE_GET_PW_HISTORY} with an 1888 * array of strings representing the user's password history content. 1889 * 1890 * @return The created password policy state operation. 1891 */ 1892 public static PasswordPolicyStateOperation 1893 createClearPasswordHistoryOperation() 1894 { 1895 return new PasswordPolicyStateOperation(OP_TYPE_CLEAR_PW_HISTORY); 1896 } 1897 1898 1899 1900 /** 1901 * Creates a new password policy state operation that may be used to determine 1902 * whether the user has a valid retired password. The result returned should 1903 * include an operation of type {@link #OP_TYPE_HAS_RETIRED_PASSWORD} with a 1904 * single boolean value of {@code true} if the user has a valid retired 1905 * password, or {@code false} if not. 1906 * 1907 * @return The created password policy state operation. 1908 */ 1909 public static PasswordPolicyStateOperation createHasRetiredPasswordOperation() 1910 { 1911 return new PasswordPolicyStateOperation(OP_TYPE_HAS_RETIRED_PASSWORD); 1912 } 1913 1914 1915 1916 /** 1917 * Creates a new password policy state operation that may be used to determine 1918 * the time that the user's former password was retired. The result returned 1919 * should include an operation of type 1920 * {@link #OP_TYPE_GET_PASSWORD_RETIRED_TIME} with a single string value that 1921 * is the generalized time representation of the time the user's former 1922 * password was retired, or a {@code null} value if the user does not have a 1923 * valid retired password. 1924 * 1925 * @return The created password policy state operation. 1926 */ 1927 public static PasswordPolicyStateOperation 1928 createGetPasswordRetiredTimeOperation() 1929 { 1930 return new PasswordPolicyStateOperation(OP_TYPE_GET_PASSWORD_RETIRED_TIME); 1931 } 1932 1933 1934 1935 /** 1936 * Creates a new password policy state operation that may be used to determine 1937 * the length of time until the user's retired password expires. The result 1938 * returned should include an operation of type 1939 * {@link #OP_TYPE_GET_RETIRED_PASSWORD_EXPIRATION_TIME} with a single string 1940 * value that is the generalized time representation of the time the user's 1941 * retired password will cease to be valid, or a {@code null} value if the 1942 * user does not have a valid retired password. 1943 * 1944 * @return The created password policy state operation. 1945 */ 1946 public static PasswordPolicyStateOperation 1947 createGetRetiredPasswordExpirationTimeOperation() 1948 { 1949 return new PasswordPolicyStateOperation( 1950 OP_TYPE_GET_RETIRED_PASSWORD_EXPIRATION_TIME); 1951 } 1952 1953 1954 1955 /** 1956 * Creates a new password policy state operation that may be used to purge 1957 * any retired password from the user's entry. The result returned should 1958 * include an operation of type {@link #OP_TYPE_HAS_RETIRED_PASSWORD} with a 1959 * single boolean value of {@code true} if the user has a valid retired 1960 * password, or {@code false} if not. 1961 * 1962 * @return The created password policy state operation. 1963 */ 1964 public static PasswordPolicyStateOperation 1965 createPurgeRetiredPasswordOperation() 1966 { 1967 return new PasswordPolicyStateOperation(OP_TYPE_PURGE_RETIRED_PASSWORD); 1968 } 1969 1970 1971 1972 /** 1973 * Creates a new password policy state operation that may be used to retrieve 1974 * information about any password policy state notices pertaining to the 1975 * usability of the user's account. The result returned should include an 1976 * operation of type {@link #OP_TYPE_GET_ACCOUNT_USABILITY_NOTICES} with an 1977 * array of strings that represent 1978 * {@link PasswordPolicyStateAccountUsabilityWarning} values. 1979 * 1980 * @return The created password policy state operation. 1981 */ 1982 public static PasswordPolicyStateOperation 1983 createGetAccountUsabilityNoticesOperation() 1984 { 1985 return new PasswordPolicyStateOperation( 1986 OP_TYPE_GET_ACCOUNT_USABILITY_NOTICES); 1987 } 1988 1989 1990 1991 /** 1992 * Creates a new password policy state operation that may be used to retrieve 1993 * information about any password policy state warnings that may impact the 1994 * usability of the user's account. The result returned should include an 1995 * operation of type {@link #OP_TYPE_GET_ACCOUNT_USABILITY_WARNINGS} with an 1996 * array of strings that represent 1997 * {@link PasswordPolicyStateAccountUsabilityWarning} values. 1998 * 1999 * @return The created password policy state operation. 2000 */ 2001 public static PasswordPolicyStateOperation 2002 createGetAccountUsabilityWarningsOperation() 2003 { 2004 return new PasswordPolicyStateOperation( 2005 OP_TYPE_GET_ACCOUNT_USABILITY_WARNINGS); 2006 } 2007 2008 2009 2010 /** 2011 * Creates a new password policy state operation that may be used to retrieve 2012 * information about any password policy state errors that may impact the 2013 * usability of the user's account. The result returned should include an 2014 * operation of type {@link #OP_TYPE_GET_ACCOUNT_USABILITY_ERRORS} with an 2015 * array of strings that represent 2016 * {@link PasswordPolicyStateAccountUsabilityError} values. 2017 * 2018 * @return The created password policy state operation. 2019 */ 2020 public static PasswordPolicyStateOperation 2021 createGetAccountUsabilityErrorsOperation() 2022 { 2023 return new PasswordPolicyStateOperation( 2024 OP_TYPE_GET_ACCOUNT_USABILITY_ERRORS); 2025 } 2026 2027 2028 2029 /** 2030 * Creates a new password policy state operation that may be used to determine 2031 * whether an account is usable (i.e., the account will be allowed to 2032 * authenticate and/or be used as an alternate authorization identity. The 2033 * result returned should include an operation of type 2034 * {@link #OP_TYPE_GET_ACCOUNT_IS_USABLE} with a single boolean value that 2035 * indicates whether the account is usable. 2036 * 2037 * @return The created password policy state operation. 2038 */ 2039 public static PasswordPolicyStateOperation 2040 createGetAccountIsUsableOperation() 2041 { 2042 return new PasswordPolicyStateOperation(OP_TYPE_GET_ACCOUNT_IS_USABLE); 2043 } 2044 2045 2046 2047 /** 2048 * Creates a new password policy state operation that may be used to determine 2049 * whether an account has an activation time that is in the future. The 2050 * result returned should include an operation of type 2051 * {@link #OP_TYPE_GET_ACCOUNT_IS_NOT_YET_ACTIVE} with a single boolean value 2052 * that indicates whether the account is not yet active. 2053 * 2054 * @return The created password policy state operation. 2055 */ 2056 public static PasswordPolicyStateOperation 2057 createGetAccountIsNotYetActiveOperation() 2058 { 2059 return new PasswordPolicyStateOperation( 2060 OP_TYPE_GET_ACCOUNT_IS_NOT_YET_ACTIVE); 2061 } 2062 2063 2064 2065 /** 2066 * Creates a new password policy state operation that may be used to determine 2067 * whether an account has an expiration time that is in the past. The result 2068 * returned should include an operation of type 2069 * {@link #OP_TYPE_GET_ACCOUNT_IS_EXPIRED} with a single boolean value that 2070 * indicates whether the account is expired. 2071 * 2072 * @return The created password policy state operation. 2073 */ 2074 public static PasswordPolicyStateOperation 2075 createGetAccountIsExpiredOperation() 2076 { 2077 return new PasswordPolicyStateOperation(OP_TYPE_GET_ACCOUNT_IS_EXPIRED); 2078 } 2079 2080 2081 2082 /** 2083 * Creates a new password policy state operation that may be used to determine 2084 * when a user's password is expected to expire. The result returned should 2085 * include an operation of type {@link #OP_TYPE_GET_PW_EXPIRATION_TIME} with a 2086 * single string value that is the generalized time representation of the 2087 * password expiration time. 2088 * 2089 * @return The created password policy state operation. 2090 */ 2091 public static PasswordPolicyStateOperation 2092 createGetPasswordExpirationTimeOperation() 2093 { 2094 return new PasswordPolicyStateOperation(OP_TYPE_GET_PW_EXPIRATION_TIME); 2095 } 2096 2097 2098 2099 /** 2100 * Creates a new password policy state operation that may be used to determine 2101 * whether an account has been locked because of too many failed 2102 * authentication attempts. The result returned should include an operation 2103 * of type {@link #OP_TYPE_GET_ACCOUNT_IS_FAILURE_LOCKED} with a single 2104 * boolean value that indicates whether the account is failure locked. 2105 * 2106 * @return The created password policy state operation. 2107 */ 2108 public static PasswordPolicyStateOperation 2109 createGetAccountIsFailureLockedOperation() 2110 { 2111 return new PasswordPolicyStateOperation( 2112 OP_TYPE_GET_ACCOUNT_IS_FAILURE_LOCKED); 2113 } 2114 2115 2116 2117 /** 2118 * Creates a new password policy state operation that may be used to specify 2119 * whether an account should be locked because of too many failed 2120 * authentication attempts. The result returned should include an operation 2121 * of type {@link #OP_TYPE_GET_ACCOUNT_IS_FAILURE_LOCKED} with a single 2122 * boolean value that indicates whether the account is failure locked. 2123 * 2124 * @param isFailureLocked Indicates whether the account should be locked 2125 * because of too many failed attempts. 2126 * 2127 * @return The created password policy state operation. 2128 */ 2129 public static PasswordPolicyStateOperation 2130 createSetAccountIsFailureLockedOperation( 2131 final boolean isFailureLocked) 2132 { 2133 final ASN1OctetString[] values = 2134 { 2135 new ASN1OctetString(String.valueOf(isFailureLocked)) 2136 }; 2137 2138 return new PasswordPolicyStateOperation( 2139 OP_TYPE_SET_ACCOUNT_IS_FAILURE_LOCKED, values); 2140 } 2141 2142 2143 2144 /** 2145 * Creates a new password policy state operation that may be used to determine 2146 * when a user's password is was locked because of too many failed 2147 * authentication attempts. The result returned should include an operation 2148 * of type {@link #OP_TYPE_GET_FAILURE_LOCKOUT_TIME} with a single string 2149 * value that is the generalized time representation of the failure lockout 2150 * time. 2151 * 2152 * @return The created password policy state operation. 2153 */ 2154 public static PasswordPolicyStateOperation 2155 createGetFailureLockoutTimeOperation() 2156 { 2157 return new PasswordPolicyStateOperation(OP_TYPE_GET_FAILURE_LOCKOUT_TIME); 2158 } 2159 2160 2161 2162 /** 2163 * Creates a new password policy state operation that may be used to determine 2164 * whether an account has been locked because it has remained idle for too 2165 * long. The result returned should include an operation of type 2166 * {@link #OP_TYPE_GET_ACCOUNT_IS_IDLE_LOCKED} with a single boolean value 2167 * that indicates whether the account is idle locked. 2168 * 2169 * @return The created password policy state operation. 2170 */ 2171 public static PasswordPolicyStateOperation 2172 createGetAccountIsIdleLockedOperation() 2173 { 2174 return new PasswordPolicyStateOperation(OP_TYPE_GET_ACCOUNT_IS_IDLE_LOCKED); 2175 } 2176 2177 2178 2179 /** 2180 * Creates a new password policy state operation that may be used to determine 2181 * when a user's password is was locked because of the idle account lockout. 2182 * The result returned should include an operation of type 2183 * {@link #OP_TYPE_GET_IDLE_LOCKOUT_TIME} with a single string value that is 2184 * the generalized time representation of the idle lockout time. 2185 * 2186 * @return The created password policy state operation. 2187 */ 2188 public static PasswordPolicyStateOperation 2189 createGetIdleLockoutTimeOperation() 2190 { 2191 return new PasswordPolicyStateOperation(OP_TYPE_GET_IDLE_LOCKOUT_TIME); 2192 } 2193 2194 2195 2196 /** 2197 * Creates a new password policy state operation that may be used to determine 2198 * whether an account has been locked because the user failed to change their 2199 * password in a timely manner after an administrative reset. The result 2200 * returned should include an operation of type 2201 * {@link #OP_TYPE_GET_ACCOUNT_IS_RESET_LOCKED} with a single boolean value 2202 * that indicates whether the account is reset locked. 2203 * 2204 * @return The created password policy state operation. 2205 */ 2206 public static PasswordPolicyStateOperation 2207 createGetAccountIsResetLockedOperation() 2208 { 2209 return new PasswordPolicyStateOperation( 2210 OP_TYPE_GET_ACCOUNT_IS_RESET_LOCKED); 2211 } 2212 2213 2214 2215 /** 2216 * Creates a new password policy state operation that may be used to determine 2217 * when a user's password is was locked because the user failed to change 2218 * their password in a timely manner after an administrative reset. The 2219 * result returned should include an operation of type 2220 * {@link #OP_TYPE_GET_RESET_LOCKOUT_TIME} with a single string value that is 2221 * the generalized time representation of the reset lockout time. 2222 * 2223 * @return The created password policy state operation. 2224 */ 2225 public static PasswordPolicyStateOperation 2226 createGetResetLockoutTimeOperation() 2227 { 2228 return new PasswordPolicyStateOperation(OP_TYPE_GET_RESET_LOCKOUT_TIME); 2229 } 2230 2231 2232 2233 /** 2234 * Creates a new password policy state operation that may be used to retrieve 2235 * the number of passwords currently held in a user's password history. The 2236 * result returned should include an operation of type 2237 * {@link #OP_TYPE_GET_PW_HISTORY_COUNT} with a single integer value that 2238 * represents the number of passwords in the history, or a {@code null} value 2239 * if a password history is not enabled for the user. 2240 * 2241 * @return The created password policy state operation. 2242 */ 2243 public static PasswordPolicyStateOperation 2244 createGetPasswordHistoryCountOperation() 2245 { 2246 return new PasswordPolicyStateOperation(OP_TYPE_GET_PW_HISTORY_COUNT); 2247 } 2248 2249 2250 2251 /** 2252 * Creates a new password policy state operation that may be used to determine 2253 * whether a user's password is expired. The result returned should include 2254 * an operation of type {@link #OP_TYPE_GET_PW_IS_EXPIRED} with a single 2255 * Boolean value that indicates whether the password is expired, or a 2256 * {@code null} value if password expiration is not enabled for the user. 2257 * 2258 * @return The created password policy state operation. 2259 */ 2260 public static PasswordPolicyStateOperation 2261 createGetPasswordIsExpiredOperation() 2262 { 2263 return new PasswordPolicyStateOperation(OP_TYPE_GET_PW_IS_EXPIRED); 2264 } 2265 2266 2267 2268 /** 2269 * Creates a new password policy state operation that may be used to retrieve 2270 * a list of the SASL mechanisms that are available for a user. This will 2271 * take into consideration the server's configuration, the types of 2272 * credentials that a user has, and per-user constraints and preferences. 2273 * 2274 * @return The created password policy state operation. 2275 */ 2276 public static PasswordPolicyStateOperation 2277 createGetAvailableSASLMechanismsOperation() 2278 { 2279 return new PasswordPolicyStateOperation( 2280 OP_TYPE_GET_AVAILABLE_SASL_MECHANISMS); 2281 } 2282 2283 2284 2285 /** 2286 * Creates a new password policy state operation that may be used to retrieve 2287 * a list of the one-time password delivery mechanisms that are available for 2288 * a user. If the user's entry includes information about which OTP delivery 2289 * mechanisms are preferred, the list will be ordered from most preferred to 2290 * least preferred. 2291 * 2292 * @return The created password policy state operation. 2293 */ 2294 public static PasswordPolicyStateOperation 2295 createGetAvailableOTPDeliveryMechanismsOperation() 2296 { 2297 return new PasswordPolicyStateOperation( 2298 OP_TYPE_GET_AVAILABLE_OTP_DELIVERY_MECHANISMS); 2299 } 2300 2301 2302 2303 /** 2304 * Creates a new password policy state operation that may be used to determine 2305 * whether the user has at least one TOTP shared secret. The result returned 2306 * should include an operation of type {@link #OP_TYPE_HAS_TOTP_SHARED_SECRET} 2307 * with a single boolean value of {@code true} if the user has one or more 2308 * TOTP shared secrets, or {@code false} if not. 2309 * 2310 * @return The created password policy state operation. 2311 */ 2312 public static PasswordPolicyStateOperation createHasTOTPSharedSecret() 2313 { 2314 return new PasswordPolicyStateOperation(OP_TYPE_HAS_TOTP_SHARED_SECRET); 2315 } 2316 2317 2318 2319 /** 2320 * Creates a new password policy state operation that may be used to add one 2321 * or more values to the set of TOTP shared secrets for a user. The result 2322 * returned should include an operation of type 2323 * {@link #OP_TYPE_HAS_TOTP_SHARED_SECRET} with a single boolean value of 2324 * {@code true} if the user has one or more TOTP shared secrets, or 2325 * {@code false} if not. 2326 * 2327 * @param totpSharedSecrets The base32-encoded representations of the TOTP 2328 * shared secrets to add to the user. It must not 2329 * be {@code null} or empty. 2330 * 2331 * @return The created password policy state operation. 2332 */ 2333 public static PasswordPolicyStateOperation 2334 createAddTOTPSharedSecretOperation( 2335 final String... totpSharedSecrets) 2336 { 2337 final ASN1OctetString[] values = 2338 new ASN1OctetString[totpSharedSecrets.length]; 2339 for (int i=0; i < totpSharedSecrets.length; i++) 2340 { 2341 values[i] = new ASN1OctetString(totpSharedSecrets[i]); 2342 } 2343 2344 return new PasswordPolicyStateOperation(OP_TYPE_ADD_TOTP_SHARED_SECRET, 2345 values); 2346 } 2347 2348 2349 2350 /** 2351 * Creates a new password policy state operation that may be used to remove 2352 * one or more values from the set of TOTP shared secrets for a user. The 2353 * result returned should include an operation of type 2354 * {@link #OP_TYPE_HAS_TOTP_SHARED_SECRET} with a single boolean value of 2355 * {@code true} if the user has one or more TOTP shared secrets, or 2356 * {@code false} if not. 2357 * 2358 * @param totpSharedSecrets The base32-encoded representations of the TOTP 2359 * shared secrets to remove from the user. It must 2360 * not be {@code null} or empty. 2361 * 2362 * @return The created password policy state operation. 2363 */ 2364 public static PasswordPolicyStateOperation 2365 createRemoveTOTPSharedSecretOperation( 2366 final String... totpSharedSecrets) 2367 { 2368 final ASN1OctetString[] values = 2369 new ASN1OctetString[totpSharedSecrets.length]; 2370 for (int i=0; i < totpSharedSecrets.length; i++) 2371 { 2372 values[i] = new ASN1OctetString(totpSharedSecrets[i]); 2373 } 2374 2375 return new PasswordPolicyStateOperation(OP_TYPE_REMOVE_TOTP_SHARED_SECRET, 2376 values); 2377 } 2378 2379 2380 2381 /** 2382 * Creates a new password policy state operation that may be used to replace 2383 * the set of TOTP shared secrets for a user. The result returned should 2384 * include an operation of type {@link #OP_TYPE_HAS_TOTP_SHARED_SECRET} with a 2385 * single boolean value of {@code true} if the user has one or more TOTP 2386 * shared secrets, or {@code false} if not. 2387 * 2388 * @param totpSharedSecrets The base32-encoded representations of the TOTP 2389 * shared secrets for the user. It must not be 2390 * {@code null} but may be empty. 2391 * 2392 * @return The created password policy state operation. 2393 */ 2394 public static PasswordPolicyStateOperation 2395 createSetTOTPSharedSecretsOperation( 2396 final String... totpSharedSecrets) 2397 { 2398 final ASN1OctetString[] values = 2399 new ASN1OctetString[totpSharedSecrets.length]; 2400 for (int i=0; i < totpSharedSecrets.length; i++) 2401 { 2402 values[i] = new ASN1OctetString(totpSharedSecrets[i]); 2403 } 2404 2405 return new PasswordPolicyStateOperation(OP_TYPE_SET_TOTP_SHARED_SECRETS, 2406 values); 2407 } 2408 2409 2410 2411 /** 2412 * Creates a new password policy state operation that may be used to clear 2413 * the set of TOTP shared secrets for a user. The result returned should 2414 * include an operation of type {@link #OP_TYPE_HAS_TOTP_SHARED_SECRET} with a 2415 * single boolean value of {@code true} if the user has one or more TOTP 2416 * shared secrets, or {@code false} if not. 2417 * 2418 * @return The created password policy state operation. 2419 */ 2420 public static PasswordPolicyStateOperation 2421 createClearTOTPSharedSecretsOperation() 2422 { 2423 return new PasswordPolicyStateOperation(OP_TYPE_CLEAR_TOTP_SHARED_SECRETS); 2424 } 2425 2426 2427 2428 /** 2429 * Creates a new password policy state operation that may be used to determine 2430 * whether the user has at least one registered YubiKey OTP device. The 2431 * result returned should include an operation of type 2432 * {@link #OP_TYPE_HAS_REGISTERED_YUBIKEY_PUBLIC_ID} 2433 * with a single boolean value of {@code true} if the user has one or more 2434 * registered devices, or {@code false} if not. 2435 * 2436 * @return The created password policy state operation. 2437 */ 2438 public static PasswordPolicyStateOperation createHasYubiKeyPublicIDOperation() 2439 { 2440 return new PasswordPolicyStateOperation( 2441 OP_TYPE_HAS_REGISTERED_YUBIKEY_PUBLIC_ID); 2442 } 2443 2444 2445 2446 /** 2447 * Creates a new password policy state operation that may be used to retrieve 2448 * the public IDs of the YubiKey OTP devices registered for a user. The 2449 * result returned should include an operation of type 2450 * {@link #OP_TYPE_GET_REGISTERED_YUBIKEY_PUBLIC_IDS} with an array of string 2451 * values that represent the public IDs of the registered YubiKey OTP devices. 2452 * 2453 * @return The created password policy state operation. 2454 */ 2455 public static PasswordPolicyStateOperation 2456 createGetRegisteredYubiKeyPublicIDsOperation() 2457 { 2458 return new PasswordPolicyStateOperation( 2459 OP_TYPE_GET_REGISTERED_YUBIKEY_PUBLIC_IDS); 2460 } 2461 2462 2463 2464 /** 2465 * Creates a new password policy state operation that may be used to add one 2466 * or more values to the set of the public IDs of the YubiKey OTP devices 2467 * registered for a user. The result returned should include an operation of 2468 * type {@link #OP_TYPE_GET_REGISTERED_YUBIKEY_PUBLIC_IDS} with an array of 2469 * string values that represent the public IDs of the registered YubiKey OTP 2470 * devices. 2471 * 2472 * @param publicIDs The set of public IDs to add to the set of YubiKey OTP 2473 * devices registered for the user. It must not be 2474 * {@code null} or empty. 2475 * 2476 * @return The created password policy state operation. 2477 */ 2478 public static PasswordPolicyStateOperation 2479 createAddRegisteredYubiKeyPublicIDOperation( 2480 final String... publicIDs) 2481 { 2482 final ASN1OctetString[] values = new ASN1OctetString[publicIDs.length]; 2483 for (int i=0; i < publicIDs.length; i++) 2484 { 2485 values[i] = new ASN1OctetString(publicIDs[i]); 2486 } 2487 2488 return new PasswordPolicyStateOperation( 2489 OP_TYPE_ADD_REGISTERED_YUBIKEY_PUBLIC_ID, values); 2490 } 2491 2492 2493 2494 /** 2495 * Creates a new password policy state operation that may be used to remove 2496 * one or more values from the set of the public IDs of the YubiKey OTP 2497 * devices registered for a user. The result returned should include an 2498 * operation of type {@link #OP_TYPE_GET_REGISTERED_YUBIKEY_PUBLIC_IDS} with 2499 * an array of string values that represent the public IDs of the registered 2500 * YubiKey OTP devices. 2501 * 2502 * @param publicIDs The set of public IDs to remove from the set of YubiKey 2503 * OTP devices registered for the user. It must not be 2504 * {@code null} or empty. 2505 * 2506 * @return The created password policy state operation. 2507 */ 2508 public static PasswordPolicyStateOperation 2509 createRemoveRegisteredYubiKeyPublicIDOperation( 2510 final String... publicIDs) 2511 { 2512 final ASN1OctetString[] values = new ASN1OctetString[publicIDs.length]; 2513 for (int i=0; i < publicIDs.length; i++) 2514 { 2515 values[i] = new ASN1OctetString(publicIDs[i]); 2516 } 2517 2518 return new PasswordPolicyStateOperation( 2519 OP_TYPE_REMOVE_REGISTERED_YUBIKEY_PUBLIC_ID, values); 2520 } 2521 2522 2523 2524 /** 2525 * Creates a new password policy state operation that may be used to replace 2526 * the set of the public IDs of the YubiKey OTP devices registered for a user. 2527 * The result returned should include an operation of type 2528 * {@link #OP_TYPE_GET_REGISTERED_YUBIKEY_PUBLIC_IDS} with an array of string 2529 * values that represent the public IDs of the registered YubiKey OTP devices. 2530 * 2531 * @param publicIDs The set of public IDs for the YubiKey OTP devices 2532 * registered for the user. It must not be {@code null} 2533 * but may be empty. 2534 * 2535 * @return The created password policy state operation. 2536 */ 2537 public static PasswordPolicyStateOperation 2538 createSetRegisteredYubiKeyPublicIDsOperation( 2539 final String... publicIDs) 2540 { 2541 final ASN1OctetString[] values = new ASN1OctetString[publicIDs.length]; 2542 for (int i=0; i < publicIDs.length; i++) 2543 { 2544 values[i] = new ASN1OctetString(publicIDs[i]); 2545 } 2546 2547 return new PasswordPolicyStateOperation( 2548 OP_TYPE_SET_REGISTERED_YUBIKEY_PUBLIC_IDS, values); 2549 } 2550 2551 2552 2553 /** 2554 * Creates a new password policy state operation that may be used to clear 2555 * the set of the public IDs of the YubiKey OTP devices registered for a user. 2556 * The result returned should include an operation of type 2557 * {@link #OP_TYPE_GET_REGISTERED_YUBIKEY_PUBLIC_IDS} with an array of string 2558 * values that represent the public IDs of the registered YubiKey OTP devices. 2559 * 2560 * @return The created password policy state operation. 2561 */ 2562 public static PasswordPolicyStateOperation 2563 createClearRegisteredYubiKeyPublicIDsOperation() 2564 { 2565 return new PasswordPolicyStateOperation( 2566 OP_TYPE_CLEAR_REGISTERED_YUBIKEY_PUBLIC_IDS); 2567 } 2568 2569 2570 2571 /** 2572 * Retrieves the operation type for this password policy state operation. 2573 * 2574 * @return The operation type for this password policy state operation. 2575 */ 2576 public int getOperationType() 2577 { 2578 return opType; 2579 } 2580 2581 2582 2583 /** 2584 * Retrieves the set of raw values for this password policy state operation. 2585 * 2586 * @return The set of raw values for this password policy state operation. 2587 */ 2588 public ASN1OctetString[] getRawValues() 2589 { 2590 return values; 2591 } 2592 2593 2594 2595 /** 2596 * Retrieves the string representation of the value for this password policy 2597 * state operation. If there are multiple values, then the first will be 2598 * returned. 2599 * 2600 * @return The string representation of the value for this password policy 2601 * state operation, or {@code null} if there are no values. 2602 */ 2603 public String getStringValue() 2604 { 2605 if (values.length == 0) 2606 { 2607 return null; 2608 } 2609 else 2610 { 2611 return values[0].stringValue(); 2612 } 2613 } 2614 2615 2616 2617 /** 2618 * Retrieves the string representations of the values for this password policy 2619 * state operation. 2620 * 2621 * @return The string representations of the values for this password policy 2622 * state operation. 2623 */ 2624 public String[] getStringValues() 2625 { 2626 final String[] stringValues = new String[values.length]; 2627 for (int i=0; i < values.length; i++) 2628 { 2629 stringValues[i] = values[i].stringValue(); 2630 } 2631 2632 return stringValues; 2633 } 2634 2635 2636 2637 /** 2638 * Retrieves the boolean representation of the value for this password policy 2639 * state operation. 2640 * 2641 * @return The boolean representation of the value for this password policy 2642 * state operation. 2643 * 2644 * @throws IllegalStateException If this operation does not have exactly one 2645 * value, or if the value cannot be decoded as 2646 * a boolean value. 2647 */ 2648 public boolean getBooleanValue() 2649 throws IllegalStateException 2650 { 2651 if (values.length != 1) 2652 { 2653 throw new IllegalStateException( 2654 ERR_PWP_STATE_INVALID_BOOLEAN_VALUE_COUNT.get(values.length)); 2655 } 2656 2657 final String valueString = toLowerCase(values[0].stringValue()); 2658 if (valueString.equals("true")) 2659 { 2660 return true; 2661 } 2662 else if (valueString.equals("false")) 2663 { 2664 return false; 2665 } 2666 else 2667 { 2668 throw new IllegalStateException( 2669 ERR_PWP_STATE_VALUE_NOT_BOOLEAN.get(values[0].stringValue())); 2670 } 2671 } 2672 2673 2674 2675 /** 2676 * Retrieves the integer representation of the value for this password policy 2677 * state operation. If there are multiple values, then the first will be 2678 * returned. 2679 * 2680 * @return The integer representation of the value for this password policy 2681 * operation. 2682 * 2683 * @throws IllegalStateException If this operation does not have any values. 2684 * 2685 * @throws NumberFormatException If the value cannot be parsed as an 2686 * integer. 2687 */ 2688 public int getIntValue() 2689 throws IllegalStateException, NumberFormatException 2690 { 2691 if (values.length == 0) 2692 { 2693 throw new IllegalStateException(ERR_PWP_STATE_NO_VALUES.get()); 2694 } 2695 2696 return Integer.parseInt(values[0].stringValue()); 2697 } 2698 2699 2700 2701 /** 2702 * Retrieves the {@code Date} object represented by the value for this 2703 * password policy state operation treated as a timestamp in generalized time 2704 * form. If there are multiple values, then the first will be returned. 2705 * 2706 * @return The {@code Date} object represented by the value for this password 2707 * policy state operation treated as a timestamp in generalized time 2708 * form, or {@code null} if this operation does not have any values. 2709 * 2710 * @throws ParseException If the value cannot be decoded as a timestamp in 2711 * generalized time form. 2712 */ 2713 public Date getGeneralizedTimeValue() 2714 throws ParseException 2715 { 2716 if (values.length == 0) 2717 { 2718 return null; 2719 } 2720 2721 return decodeGeneralizedTime(values[0].stringValue()); 2722 } 2723 2724 2725 2726 /** 2727 * Retrieves the {@code Date} objects represented by the values for this 2728 * password policy state operation treated as timestamps in generalized time 2729 * form. 2730 * 2731 * @return The {@code Date} objects represented by the values for this 2732 * password policy state operation treated as timestamps in 2733 * generalized time form. 2734 * 2735 * @throws ParseException If any of the values cannot be decoded as a 2736 * timestamp in generalized time form. 2737 */ 2738 public Date[] getGeneralizedTimeValues() 2739 throws ParseException 2740 { 2741 final Date[] dateValues = new Date[values.length]; 2742 for (int i=0; i < values.length; i++) 2743 { 2744 dateValues[i] = decodeGeneralizedTime(values[i].stringValue()); 2745 } 2746 2747 return dateValues; 2748 } 2749 2750 2751 2752 /** 2753 * Creates an array of ASN.1 octet strings with the provided set of values. 2754 * 2755 * @param dates The dates from which to create the values. It may be 2756 * {@code null} or empty if there should be no values. 2757 * 2758 * @return The array of ASN.1 octet strings. 2759 */ 2760 private static ASN1OctetString[] createValues(final Date... dates) 2761 { 2762 if ((dates == null) || (dates.length == 0)) 2763 { 2764 return NO_VALUES; 2765 } 2766 2767 final ArrayList<ASN1OctetString> valueList = 2768 new ArrayList<ASN1OctetString>(dates.length); 2769 for (final Date d : dates) 2770 { 2771 if (d != null) 2772 { 2773 valueList.add(new ASN1OctetString(encodeGeneralizedTime(d))); 2774 } 2775 } 2776 2777 return valueList.toArray(NO_VALUES); 2778 } 2779 2780 2781 2782 /** 2783 * Encodes this password policy state operation for use in the extended 2784 * request or response. 2785 * 2786 * @return An ASN.1 element containing an encoded representation of this 2787 * password policy state operation. 2788 */ 2789 public ASN1Element encode() 2790 { 2791 final ASN1Element[] elements; 2792 if (values.length > 0) 2793 { 2794 elements = new ASN1Element[] 2795 { 2796 new ASN1Enumerated(opType), 2797 new ASN1Sequence(values) 2798 }; 2799 } 2800 else 2801 { 2802 elements = new ASN1Element[] 2803 { 2804 new ASN1Enumerated(opType), 2805 }; 2806 } 2807 2808 return new ASN1Sequence(elements); 2809 } 2810 2811 2812 2813 /** 2814 * Decodes the provided ASN.1 element as a password policy state operation. 2815 * 2816 * @param element The ASN.1 element to be decoded. 2817 * 2818 * @return The decoded password policy state operation. 2819 * 2820 * @throws LDAPException If a problem occurs while attempting to decode the 2821 * provided ASN.1 element as a password policy state 2822 * operation. 2823 */ 2824 public static PasswordPolicyStateOperation decode(final ASN1Element element) 2825 throws LDAPException 2826 { 2827 final ASN1Element[] elements; 2828 try 2829 { 2830 elements = ASN1Sequence.decodeAsSequence(element).elements(); 2831 } 2832 catch (final Exception e) 2833 { 2834 debugException(e); 2835 throw new LDAPException(ResultCode.DECODING_ERROR, 2836 ERR_PWP_STATE_ELEMENT_NOT_SEQUENCE.get(e), e); 2837 } 2838 2839 if ((elements.length < 1) || (elements.length > 2)) 2840 { 2841 throw new LDAPException(ResultCode.DECODING_ERROR, 2842 ERR_PWP_STATE_INVALID_ELEMENT_COUNT.get( 2843 elements.length)); 2844 } 2845 2846 final int opType; 2847 try 2848 { 2849 opType = ASN1Enumerated.decodeAsEnumerated(elements[0]).intValue(); 2850 } 2851 catch (final Exception e) 2852 { 2853 debugException(e); 2854 throw new LDAPException(ResultCode.DECODING_ERROR, 2855 ERR_PWP_STATE_OP_TYPE_NOT_INTEGER.get(e), e); 2856 } 2857 2858 final ASN1OctetString[] values; 2859 if (elements.length == 2) 2860 { 2861 try 2862 { 2863 final ASN1Element[] valueElements = 2864 ASN1Sequence.decodeAsSequence(elements[1]).elements(); 2865 values = new ASN1OctetString[valueElements.length]; 2866 for (int i=0; i < valueElements.length; i++) 2867 { 2868 values[i] = ASN1OctetString.decodeAsOctetString(valueElements[i]); 2869 } 2870 } 2871 catch (final Exception e) 2872 { 2873 debugException(e); 2874 throw new LDAPException(ResultCode.DECODING_ERROR, 2875 ERR_PWP_STATE_CANNOT_DECODE_VALUES.get(e), e); 2876 } 2877 } 2878 else 2879 { 2880 values = NO_VALUES; 2881 } 2882 2883 return new PasswordPolicyStateOperation(opType, values); 2884 } 2885 2886 2887 2888 /** 2889 * Retrieves a string representation of this password policy state operation. 2890 * 2891 * @return A string representation of this password policy state operation. 2892 */ 2893 @Override() 2894 public String toString() 2895 { 2896 final StringBuilder buffer = new StringBuilder(); 2897 toString(buffer); 2898 return buffer.toString(); 2899 } 2900 2901 2902 2903 /** 2904 * Appends a string representation of this password policy state operation to 2905 * the provided buffer. 2906 * 2907 * @param buffer The buffer to which the information should be appended. 2908 */ 2909 public void toString(final StringBuilder buffer) 2910 { 2911 buffer.append("PasswordPolicyStateOperation(opType="); 2912 buffer.append(opType); 2913 2914 if (values.length > 0) 2915 { 2916 buffer.append(", values={"); 2917 for (int i=0; i < values.length; i++) 2918 { 2919 if (i > 0) 2920 { 2921 buffer.append(", "); 2922 } 2923 2924 buffer.append('\''); 2925 buffer.append(values[i].stringValue()); 2926 buffer.append('\''); 2927 } 2928 buffer.append('}'); 2929 } 2930 2931 buffer.append(')'); 2932 } 2933}