// Copyright 1998 The Open Group Research Institute.  All rights reserved.
// Copyright 1999 Memesoft.  All rights reserved.

package krb5.lib.ccache;

import krb5.lib.*;

/**
 * The CCache Info class captures attributes that are
 * common across implementations of a credential cache.
 * The CCache factory newInstance() method takes an object of type
 * CCache info, but the actual object passed to that method will
 * be a subclass of the CCacheInfo method that provides whatever
 * info is required to create an instance of the specific type of
 * ccache being created.
 */
public abstract class CCacheInfo implements Cloneable {

	/**
	 * Principal name
	 */
    PrincipalName principalName;

	/**
	 * Class constructor
	 *
	 * @param name is of type PrincipalName
	 * @see krb5.lib.PrincipalName
	 */
    public CCacheInfo(PrincipalName name) {
        principalName = (PrincipalName) name.clone();
    }

	/**
	 * Class constructor
	 */
    public CCacheInfo() {
        principalName = null;
    }

    // Other classes in the package can get at the protected fields
    // directly. The following methods allow outsiders to see get at them.
	/**
	 * Returns principal name
	 *
	 * @return PrincipalName is a result
	 */
    public PrincipalName getPrincipalName() {
        return (PrincipalName)principalName.clone();
    }

	/**
	 * Clones a copy of the object
	 *
	 * @return Object is a result
	 */
    public Object clone() {
        CCacheInfo myClone = null;
        try {
            myClone = (CCacheInfo)super.clone();
            if (principalName != null)
                myClone.principalName = (PrincipalName)principalName.clone();
        } catch (CloneNotSupportedException e) {
            myClone = null;
        }
        return myClone;
    }
}