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/jgss/krb5/Krb5Token.java
41161 views
1
/*
2
* Copyright (c) 2000, 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
23
* questions.
24
*/
25
26
package sun.security.jgss.krb5;
27
28
import java.io.IOException;
29
import sun.security.util.*;
30
import sun.security.jgss.*;
31
32
/**
33
* This class represents a base class for all Kerberos v5 GSS-API
34
* tokens. It contains commonly used definitions and utilities.
35
*
36
* @author Mayank Upadhyay
37
*/
38
39
abstract class Krb5Token extends GSSToken {
40
41
/**
42
* The token id defined for the token emitted by the initSecContext call
43
* carrying the AP_REQ .
44
*/
45
public static final int AP_REQ_ID = 0x0100;
46
47
/**
48
* The token id defined for the token emitted by the acceptSecContext call
49
* carrying the AP_REP .
50
*/
51
public static final int AP_REP_ID = 0x0200;
52
53
/**
54
* The token id defined for any token carrying a KRB-ERR message.
55
*/
56
public static final int ERR_ID = 0x0300;
57
58
/**
59
* The token id defined for the token emitted by the getMIC call.
60
*/
61
public static final int MIC_ID = 0x0101;
62
63
/**
64
* The token id defined for the token emitted by the wrap call.
65
*/
66
public static final int WRAP_ID = 0x0201;
67
68
// new token ID draft-ietf-krb-wg-gssapi-cfx-07.txt
69
public static final int MIC_ID_v2 = 0x0404;
70
public static final int WRAP_ID_v2 = 0x0504;
71
72
/**
73
* The object identifier corresponding to the Kerberos v5 GSS-API
74
* mechanism.
75
*/
76
public static ObjectIdentifier OID;
77
78
static {
79
try {
80
OID = ObjectIdentifier.of(Krb5MechFactory.
81
GSS_KRB5_MECH_OID.toString());
82
} catch (IOException ioe) {
83
// should not happen
84
}
85
}
86
87
/**
88
* Returns a strign representing the token type.
89
*
90
* @param tokenId the token id for which a string name is desired
91
* @return the String name of this token type
92
*/
93
public static String getTokenName(int tokenId) {
94
String retVal = null;
95
switch (tokenId) {
96
case AP_REQ_ID:
97
case AP_REP_ID:
98
retVal = "Context Establishment Token";
99
break;
100
case MIC_ID:
101
retVal = "MIC Token";
102
break;
103
case MIC_ID_v2:
104
retVal = "MIC Token (new format)";
105
break;
106
case WRAP_ID:
107
retVal = "Wrap Token";
108
break;
109
case WRAP_ID_v2:
110
retVal = "Wrap Token (new format)";
111
break;
112
default:
113
retVal = "Kerberos GSS-API Mechanism Token";
114
break;
115
}
116
return retVal;
117
}
118
}
119
120