0N/A/*
2362N/A * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.security.jgss.krb5;
0N/A
0N/Aimport java.io.IOException;
0N/Aimport sun.security.util.*;
0N/Aimport sun.security.jgss.*;
0N/A
0N/A/**
0N/A * This class represents a base class for all Kerberos v5 GSS-API
0N/A * tokens. It contains commonly used definitions and utilities.
0N/A *
0N/A * @author Mayank Upadhyay
0N/A */
0N/A
0N/Aabstract class Krb5Token extends GSSToken {
0N/A
0N/A /**
0N/A * The token id defined for the token emitted by the initSecContext call
0N/A * carrying the AP_REQ .
0N/A */
0N/A public static final int AP_REQ_ID = 0x0100;
0N/A
0N/A /**
0N/A * The token id defined for the token emitted by the acceptSecContext call
0N/A * carrying the AP_REP .
0N/A */
0N/A public static final int AP_REP_ID = 0x0200;
0N/A
0N/A /**
0N/A * The token id defined for any token carrying a KRB-ERR message.
0N/A */
0N/A public static final int ERR_ID = 0x0300;
0N/A
0N/A /**
0N/A * The token id defined for the token emitted by the getMIC call.
0N/A */
0N/A public static final int MIC_ID = 0x0101;
0N/A
0N/A /**
0N/A * The token id defined for the token emitted by the wrap call.
0N/A */
0N/A public static final int WRAP_ID = 0x0201;
0N/A
0N/A // new token ID draft-ietf-krb-wg-gssapi-cfx-07.txt
0N/A public static final int MIC_ID_v2 = 0x0404;
0N/A public static final int WRAP_ID_v2 = 0x0504;
0N/A
0N/A /**
0N/A * The object identifier corresponding to the Kerberos v5 GSS-API
0N/A * mechanism.
0N/A */
0N/A public static ObjectIdentifier OID;
0N/A
0N/A static {
0N/A try {
0N/A OID = new ObjectIdentifier(Krb5MechFactory.
0N/A GSS_KRB5_MECH_OID.toString());
0N/A } catch (IOException ioe) {
0N/A // should not happen
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Returns a strign representing the token type.
0N/A *
0N/A * @param tokenId the token id for which a string name is desired
0N/A * @return the String name of this token type
0N/A */
0N/A public static String getTokenName(int tokenId) {
0N/A String retVal = null;
0N/A switch (tokenId) {
0N/A case AP_REQ_ID:
0N/A case AP_REP_ID:
0N/A retVal = "Context Establishment Token";
0N/A break;
0N/A case MIC_ID:
0N/A retVal = "MIC Token";
0N/A break;
0N/A case MIC_ID_v2:
0N/A retVal = "MIC Token (new format)";
0N/A break;
0N/A case WRAP_ID:
0N/A retVal = "Wrap Token";
0N/A break;
0N/A case WRAP_ID_v2:
0N/A retVal = "Wrap Token (new format)";
0N/A break;
0N/A default:
0N/A retVal = "Kerberos GSS-API Mechanism Token";
0N/A break;
0N/A }
0N/A return retVal;
0N/A }
0N/A}