// Copyright 1997 The Open Group Research Institute.  All rights reserved.
// Copyright 1999 Memesoft.  All rights reserved.

package krb5.lib.rcache;

import krb5.lib.*;

/**
 * Replay cache entry
 */
public class ReplayCacheEntry {

	/**
	 * Server name
	 */
    PrincipalName sname;

	/**
	 * Server realm
	 */
    Realm srealm;

	/**
	 * Authenticator
	 */
    Authenticator authenticator;

	/**
	 * Class constructor
	 *
	 * @param _sname is of type PrincipalName
	 * @param _srealm is of type Realm
	 * @param _authenticator is of type Authenticator
	 * @see krb5.lib.PrincipalName
	 * @see krb5.lib.Realm
	 * @see krb5.lib.Authenticator
	 */
    public ReplayCacheEntry(PrincipalName _sname, Realm _srealm, Authenticator _authenticator) {
        sname = _sname;
        srealm = _srealm;
        authenticator = _authenticator;
    }

	/**
	 * Checks whether 2 ReplayCacheEntry are equal
	 *
	 * @return boolean is a result
	 * @param other is of type ReplayCacheEntry
	 * @see krb5.lib.rcache.ReplayCacheEntry
	 */
    public boolean equals(ReplayCacheEntry other) {
        return  srealm.equals(other.srealm) && sname.equals(other.sname) &&
            authenticator.replayEquals(other.authenticator);
    }

	/**
	 * Checks to whether it is expired
	 *
	 * @return boolean is a result
	 * @param time is of type KerberosTime
	 * @see krb5.lib.KerberosTime
	 */
    public boolean expired(KerberosTime time) {
        return authenticator.ctime.equals(time);
    }
}