Path: blob/master/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5Token.java
41161 views
/*1* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.security.jgss.krb5;2627import java.io.IOException;28import sun.security.util.*;29import sun.security.jgss.*;3031/**32* This class represents a base class for all Kerberos v5 GSS-API33* tokens. It contains commonly used definitions and utilities.34*35* @author Mayank Upadhyay36*/3738abstract class Krb5Token extends GSSToken {3940/**41* The token id defined for the token emitted by the initSecContext call42* carrying the AP_REQ .43*/44public static final int AP_REQ_ID = 0x0100;4546/**47* The token id defined for the token emitted by the acceptSecContext call48* carrying the AP_REP .49*/50public static final int AP_REP_ID = 0x0200;5152/**53* The token id defined for any token carrying a KRB-ERR message.54*/55public static final int ERR_ID = 0x0300;5657/**58* The token id defined for the token emitted by the getMIC call.59*/60public static final int MIC_ID = 0x0101;6162/**63* The token id defined for the token emitted by the wrap call.64*/65public static final int WRAP_ID = 0x0201;6667// new token ID draft-ietf-krb-wg-gssapi-cfx-07.txt68public static final int MIC_ID_v2 = 0x0404;69public static final int WRAP_ID_v2 = 0x0504;7071/**72* The object identifier corresponding to the Kerberos v5 GSS-API73* mechanism.74*/75public static ObjectIdentifier OID;7677static {78try {79OID = ObjectIdentifier.of(Krb5MechFactory.80GSS_KRB5_MECH_OID.toString());81} catch (IOException ioe) {82// should not happen83}84}8586/**87* Returns a strign representing the token type.88*89* @param tokenId the token id for which a string name is desired90* @return the String name of this token type91*/92public static String getTokenName(int tokenId) {93String retVal = null;94switch (tokenId) {95case AP_REQ_ID:96case AP_REP_ID:97retVal = "Context Establishment Token";98break;99case MIC_ID:100retVal = "MIC Token";101break;102case MIC_ID_v2:103retVal = "MIC Token (new format)";104break;105case WRAP_ID:106retVal = "Wrap Token";107break;108case WRAP_ID_v2:109retVal = "Wrap Token (new format)";110break;111default:112retVal = "Kerberos GSS-API Mechanism Token";113break;114}115return retVal;116}117}118119120