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
90 * i32 strlen(string) + 1
91 * octets of string, with the \0x00 ending
92 *
93 * The old style block is always created by MIT krb5 used even if a new style
94 * is available, which means there can be 2 entries for a single Authenticator.
95 * Java also does this way.
96 *
97 * See src/lib/krb5/rcache/rc_io.c and src/lib/krb5/rcache/rc_dfl.c.
98 *
99 * Update: New version can use other hash algorithms.
100 */
101 public class DflCache extends ReplayCache {
102
103 private static final int KRB5_RV_VNO = 0x501;
104 private static final int EXCESSREPS = 30; // if missed-hit>this, recreate
105
106 private final String source;
107
108 private static long uid;
109 static {
110 // Available on Solaris, Linux and Mac. Otherwise, -1 and no _euid suffix
111 uid = jdk.internal.misc.VM.geteuid();
112 }
113
114 public DflCache (String source) {
115 this.source = source;
116 }
117
118 private static String defaultPath() {
119 return GetPropertyAction.privilegedGetProperty("java.io.tmpdir");
120 }
121
122 private static String defaultFile(String server) {
123 // service/host@REALM -> service
124 int slash = server.indexOf('/');
125 if (slash == -1) {
126 // A normal principal? say, dummy@REALM
127 slash = server.indexOf('@');
128 }
129 if (slash != -1) {
130 // Should not happen, but be careful
|
1 /*
2 * Copyright (c) 2013, 2020, 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
90 * i32 strlen(string) + 1
91 * octets of string, with the \0x00 ending
92 *
93 * The old style block is always created by MIT krb5 used even if a new style
94 * is available, which means there can be 2 entries for a single Authenticator.
95 * Java also does this way.
96 *
97 * See src/lib/krb5/rcache/rc_io.c and src/lib/krb5/rcache/rc_dfl.c.
98 *
99 * Update: New version can use other hash algorithms.
100 */
101 public class DflCache extends ReplayCache {
102
103 private static final int KRB5_RV_VNO = 0x501;
104 private static final int EXCESSREPS = 30; // if missed-hit>this, recreate
105
106 private final String source;
107
108 private static long uid;
109 static {
110 // Available on Linux and Mac. Otherwise, -1 and no _euid suffix
111 uid = jdk.internal.misc.VM.geteuid();
112 }
113
114 public DflCache (String source) {
115 this.source = source;
116 }
117
118 private static String defaultPath() {
119 return GetPropertyAction.privilegedGetProperty("java.io.tmpdir");
120 }
121
122 private static String defaultFile(String server) {
123 // service/host@REALM -> service
124 int slash = server.indexOf('/');
125 if (slash == -1) {
126 // A normal principal? say, dummy@REALM
127 slash = server.indexOf('@');
128 }
129 if (slash != -1) {
130 // Should not happen, but be careful
|