View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.server.kerberos.shared.replay;
21  
22  
23  import javax.security.auth.kerberos.KerberosPrincipal;
24  
25  import org.apache.directory.shared.kerberos.KerberosTime;
26  
27  
28  /**
29   * "The replay cache will store at least the server name, along with the client name,
30   * time, and microsecond fields from the recently-seen authenticators, and if a
31   * matching tuple is found, the KRB_AP_ERR_REPEAT error is returned."
32   * 
33   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
34   */
35  public interface ReplayCache
36  {
37      /**
38       * Returns whether a request is a replay, based on the server principal, client
39       * principal, time, and microseconds.
40       * 
41       * @param serverPrincipal The server principal 
42       * @param clientPrincipal The client principal
43       * @param clientTime The client time
44       * @param clientMicroSeconds The client microsecond
45       * @return true if the request is a replay.
46       */
47      boolean isReplay( KerberosPrincipal serverPrincipal, KerberosPrincipal clientPrincipal, KerberosTime clientTime,
48          int clientMicroSeconds );
49  
50  
51      /**
52       * Saves the server principal, client principal, time, and microseconds to
53       * the replay cache.
54       *
55       * @param serverPrincipal The server principal 
56       * @param clientPrincipal The client principal
57       * @param clientTime The client time
58       * @param clientMicroSeconds The client microsecond
59       */
60      void save( KerberosPrincipal serverPrincipal, KerberosPrincipal clientPrincipal, KerberosTime clientTime,
61          int clientMicroSeconds );
62      
63      /**
64       * removes all the elements present in the cache
65       */
66      void clear();
67  }