001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *  
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *  
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License. 
018 *  
019 */
020package org.apache.directory.server.kerberos.shared.replay;
021
022
023import javax.security.auth.kerberos.KerberosPrincipal;
024
025import org.apache.directory.shared.kerberos.KerberosTime;
026
027
028/**
029 * "The replay cache will store at least the server name, along with the client name,
030 * time, and microsecond fields from the recently-seen authenticators, and if a
031 * matching tuple is found, the KRB_AP_ERR_REPEAT error is returned."
032 * 
033 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
034 */
035public interface ReplayCache
036{
037    /**
038     * Returns whether a request is a replay, based on the server principal, client
039     * principal, time, and microseconds.
040     * 
041     * @param serverPrincipal The server principal 
042     * @param clientPrincipal The client principal
043     * @param clientTime The client time
044     * @param clientMicroSeconds The client microsecond
045     * @return true if the request is a replay.
046     */
047    boolean isReplay( KerberosPrincipal serverPrincipal, KerberosPrincipal clientPrincipal, KerberosTime clientTime,
048        int clientMicroSeconds );
049
050
051    /**
052     * Saves the server principal, client principal, time, and microseconds to
053     * the replay cache.
054     *
055     * @param serverPrincipal The server principal 
056     * @param clientPrincipal The client principal
057     * @param clientTime The client time
058     * @param clientMicroSeconds The client microsecond
059     */
060    void save( KerberosPrincipal serverPrincipal, KerberosPrincipal clientPrincipal, KerberosTime clientTime,
061        int clientMicroSeconds );
062    
063    /**
064     * removes all the elements present in the cache
065     */
066    void clear();
067}