Principal.java revision 45526e9775395f5d44bad3f5430041f32c84ce1e
/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/**
* Class representing a Kerberos V5 principal
* Class data items correspond to fields in struct _kadm5_principal_ent_t_v2
*/
class Principal {
private static DateFormat df;
private static NumberFormat nf;
private static String neverString;
// For I18N
private static ResourceBundle rb;
boolean isNew; // newly created principal?
boolean dummy; // use dummy data?
boolean newComments; // are comments new or changed?
/**
* Initialize new principal to defaults - this one is for new creations
*/
public Principal() {
isNew = true;
dummy = true;
newComments = false;
}
/*
* This is used for loading an existing principal
*/
/* Get some specific data from somewhere */
this();
isNew = false;
}
/*
* This is used for duplicating a new principal from an old one
*/
/* Copy old principal to new one */
this();
copyPrincipal(old, this);
}
/*
* For real data, use Kadmin as a first argument
*/
this();
dummy = false;
}
this();
isNew = false;
dummy = false;
}
this(old);
dummy = false;
}
if (!defaults.getServerSide()) {
}
}
/**
* Copy relevant fields from old principal, overriding as necessary
*/
else
}
if (dummy)
return true;
// System.out.println(this.toString());
return b;
}
public boolean savePrincipal() {
// System.out.println(this.toString());
if (dummy)
return true;
if (this.isNew)
return Kadmin.createPrincipal(this);
else
return Kadmin.savePrincipal(this);
}
// xxx: see where this gets called from to determine if a new Principal
// just added can have a duplicate name or whether that would have been
// screened out earlier.
return true;
}
// xxx: check to see if all characters are in the allowable list of
// characters. The list needs to be I18N. No length restrictions on
// Java side but what about the c side?
newComments = true;
return true;
}
// xxx: is this a valid policy name? Should we assume that error is
// already trapped before this point?
return true;
}
// xxx: check to see if the passwd follows the rules laid down by
// the policy
return true;
}
// Don't have to check enc type list provided given that list was
// populated from the checkbox list
return true;
}
/**
* @param exp Contains a date formatted by the default locale,
* representing the expiry time for the principal's expiration.
*/
else {
try {
} catch (ParseException e) {
return false;
} catch (NullPointerException e) {
// gets thrown when parse string begins with text
// probable JDK bug
return false;
} catch (StringIndexOutOfBoundsException e) {
// gets thrown when parse string contains only one number
// probable JDK bug
return false;
}
}
return true;
}
/**
* @param exp Contains a date formatted by the default locale,
* representing the expiry time for the password expiration.
*/
PwExpireTime = null;
else {
try {
} catch (ParseException e) {
return false;
} catch (NullPointerException e) {
// gets thrown when parse string begins with text
// probable JDK bug
return false;
} catch (StringIndexOutOfBoundsException e) {
// gets thrown when parse string contains only one number
// probable JDK bug
return false;
}
}
return true;
}
public String getModTime() {
return neverString;
else
}
public String getEncType() {
return EncTypes;
}
return neverString;
else
}
public String getLastSuccess() {
return neverString;
else
}
public String getLastFailure() {
return neverString;
else
}
public String getLastPwChange() {
return neverString;
else
}
public String getPwExpireTime() {
if (PwExpireTime == null)
return new String("");
return neverString;
else
}
public String getMaxLife() {
else
return "";
}
public String getMaxRenew() {
else
return "";
}
/**
* @param vers Contains a number representing the key version.
*/
try {
}catch (ParseException e) {
return false;
}
return true;
}
/**
* @param val Contains a number representing the maximum lifetime, in
* seconds, of a ticket for this principal.
*/
try {
return true;
}catch (ParseException e) {
return false;
}
return true;
}
/**
* @param val Contains a number representing the maximum renewable lifetime,
* in seconds, of a ticket for this principal.
*/
try {
return true;
}catch (ParseException e) {
return false;
}
return true;
}
/**
* Toggles a particular flag.
* @param mask one of the statically defined masks indicating which flag to
* toggle.
*/
return true;
}
/**
* Obtain a string representation of this principal.
* @return a String containing the following information about this
* principal:<br>
* <ul>
* <li>principal name
*<li>policy being applied
*<li>expiry date
*<li>comments
*<li>key version number
*<li>password expire time
*<li>maximum lifetime
*<li>maximum renewable lifetime
* <li> flags
*</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;
}
}
static {
}
}