Policy.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright (c) 1999-2000 by Sun Microsystems, Inc.
* All rights reserved.
*/
/**
* Class representing a Kerberos V5 policy
* Class data items correspond to fields in struct _kadm5_policy_ent_t
*/
class Policy {
boolean isNew;
boolean dummy;
// For I18N
private static ResourceBundle rb =
/**
* Initialize new policy to defaults - this one is for new creations
*/
public Policy() {
dummy = true;
isNew = true;
}
/*
* This is used for loading an existing principal
*/
/* Get some specific data from somewhere */
this();
dummy = true;
isNew = false;
PolicyName = Pname;
}
/*
* This is used for duplicating a new principal from an old one
*/
/* Copy old principal to new one */
this();
dummy = true;
copyPolicy(old, this);
}
/*
* For real data, use Kadmin as a first argument
*/
this();
dummy = false;
}
this();
isNew = false;
dummy = false;
PolicyName = Pname;
}
this(old);
dummy = false;
}
/**
* Copy relevant fields from old policy, overriding as necessary
*/
}
if (dummy)
return true;
// System.out.println(this.toString());
return b;
}
public boolean savePolicy() {
// System.out.println(this.toString());
if (dummy)
return true;
if (this.isNew)
return Kadmin.createPolicy(this);
else
return Kadmin.savePolicy(this);
}
// xxx: see where this gets called from to determine if a new Policy
// just added can have a duplicate name or whether that would have
// been screened out earlier.
PolicyName = name;
return true;
}
/**
* @param val Contains one number representing the length.
*/
try {
} catch (ParseException e) {
return false;
}
return true;
}
/**
* @param val Contains one number representing the number of classes
*/
try {
} catch (ParseException e) {
return false;
}
return true;
}
/**
* @param val Contains one number representing the save count.
*/
// xxx: Is pwHistory the same as pwSaveCount?
try {
} catch (ParseException e) {
return false;
}
return true;
}
/**
* @param val Contains one number representing the lifetime in seconds.
*/
try {
} catch (ParseException e) {
return false;
}
return true;
}
/**
* @param val Contains one number representing the lifetime in seconds.
*/
try {
} catch (ParseException e) {
return false;
}
return true;
}
/*
* Obtain a string representation of this policy.
* @return a String containing the following information about this policy:
* <br><ul>
* <li>policy name
* <li>password minimum life
* <li>password maximum life
* <li>password minimum length
* <li>password minimum classes
* <li>password save count
* <li>reference count
*</ul>
*/
}
/**
* Call rb.getString(), but catch exception and return English
* key so that small spelling errors don't cripple the GUI
*
*/
try {
return res;
} catch (MissingResourceException e) {
return key;
}
}
}