コード例 #1
0
 /**
  * Modify the principal with KOptions.
  *
  * @param identity The identity to be modified
  * @param kOptions The KOptions with changed principal info
  * @throws KrbException
  */
 static void updateIdentity(KrbIdentity identity, KOptions kOptions) {
   if (kOptions.contains(KadminOption.EXPIRE)) {
     Date date = kOptions.getDateOption(KadminOption.EXPIRE);
     identity.setExpireTime(new KerberosTime(date.getTime()));
   }
   if (kOptions.contains(KadminOption.DISABLED)) {
     identity.setDisabled(kOptions.getBooleanOption(KadminOption.DISABLED, false));
   }
   if (kOptions.contains(KadminOption.LOCKED)) {
     identity.setLocked(kOptions.getBooleanOption(KadminOption.LOCKED, false));
   }
 }
コード例 #2
0
  /**
   * Create principal.
   *
   * @param principal The principal name to be created
   * @param kOptions The KOptions with principal info
   */
  static KrbIdentity createIdentity(String principal, KOptions kOptions) throws KrbException {
    KrbIdentity kid = new KrbIdentity(principal);
    kid.setCreatedTime(KerberosTime.now());
    if (kOptions.contains(KadminOption.EXPIRE)) {
      Date date = kOptions.getDateOption(KadminOption.EXPIRE);
      kid.setExpireTime(new KerberosTime(date.getTime()));
    } else {
      kid.setExpireTime(new KerberosTime(253402300799900L));
    }
    if (kOptions.contains(KadminOption.KVNO)) {
      kid.setKeyVersion(kOptions.getIntegerOption(KadminOption.KVNO));
    } else {
      kid.setKeyVersion(1);
    }
    kid.setDisabled(false);
    kid.setLocked(false);

    return kid;
  }