blob: 6e61dc1c2a26fccf3fe5b56002b2bd120a53c41c [file] [log] [blame]
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.codec.spnego;
import java.io.IOException;
public abstract class SpnegoToken {
// Default max size as 65K
public static int TOKEN_MAX_SIZE = 66560;
protected byte[] mechanismToken;
protected byte[] mechanismList;
protected String mechanism;
public static SpnegoToken parse(byte[] token) throws IOException {
SpnegoToken spnegoToken = null;
if (token.length <= 0) {
throw new IOException("spnego.token.empty");
}
switch (token[0]) {
case (byte)0x60:
spnegoToken = new SpnegoInitToken(token);
break;
case (byte)0xa1:
spnegoToken = new SpnegoTargToken(token);
break;
default:
spnegoToken = null;
throw new IOException("spnego.token.invalid");
}
return spnegoToken;
}
public byte[] getMechanismToken() {
return mechanismToken;
}
public byte[] getMechanismList() {
return mechanismList;
}
public String getMechanism() {
return mechanism;
}
}