Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.security.jgss/share/classes/sun/security/krb5/internal/ReplayCache.java
41161 views
1
/*
2
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package sun.security.krb5.internal;
27
28
import sun.security.action.GetPropertyAction;
29
import sun.security.krb5.internal.rcache.AuthTimeWithHash;
30
import sun.security.krb5.internal.rcache.MemoryCache;
31
import sun.security.krb5.internal.rcache.DflCache;
32
33
/**
34
* Models the replay cache of an acceptor as described in
35
* RFC 4120 3.2.3.
36
* @since 1.8
37
*/
38
public abstract class ReplayCache {
39
public static ReplayCache getInstance(String type) {
40
if (type == null) {
41
return new MemoryCache();
42
} else if (type.equals("dfl") || type.startsWith("dfl:")) {
43
return new DflCache(type);
44
} else if (type.equals("none")) {
45
return new ReplayCache() {
46
@Override
47
public void checkAndStore(KerberosTime currTime, AuthTimeWithHash time)
48
throws KrbApErrException {
49
// no check at all
50
}
51
};
52
} else {
53
throw new IllegalArgumentException("Unknown type: " + type);
54
}
55
}
56
public static ReplayCache getInstance() {
57
String type = GetPropertyAction
58
.privilegedGetProperty("sun.security.krb5.rcache");
59
return getInstance(type);
60
}
61
62
/**
63
* Accepts or rejects an AuthTime.
64
* @param currTime the current time
65
* @param time AuthTimeWithHash object calculated from authenticator
66
* @throws KrbApErrException if the authenticator is a replay
67
*/
68
public abstract void checkAndStore(KerberosTime currTime, AuthTimeWithHash time)
69
throws KrbApErrException;
70
}
71
72