0N/A/*
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/A/*
0N/A *
0N/A * (C) Copyright IBM Corp. 1999 All Rights Reserved.
0N/A * Copyright 1997 The Open Group Research Institute. All rights reserved.
0N/A */
0N/A
0N/Apackage sun.security.krb5;
0N/A
0N/Aimport sun.security.krb5.internal.*;
0N/A
0N/Aabstract class KrbKdcRep {
0N/A
0N/A static void check(
0N/A KDCReq req,
0N/A KDCRep rep
0N/A ) throws KrbApErrException {
0N/A
0N/A if (!req.reqBody.cname.equalsWithoutRealm(rep.cname)) {
0N/A rep.encKDCRepPart.key.destroy();
0N/A throw new KrbApErrException(Krb5.KRB_AP_ERR_MODIFIED);
0N/A }
0N/A
0N/A /**** XXX
0N/A if (!req.reqBody.crealm.equals(rep.crealm)) {
0N/A rep.encKDCRepPart.key.destroy();
0N/A throw new KrbApErrException(Krb5.KRB_AP_ERR_MODIFIED);
0N/A }
0N/A *****/
0N/A
0N/A if (!req.reqBody.sname.equalsWithoutRealm(rep.encKDCRepPart.sname)) {
0N/A rep.encKDCRepPart.key.destroy();
0N/A throw new KrbApErrException(Krb5.KRB_AP_ERR_MODIFIED);
0N/A }
0N/A
0N/A if (!req.reqBody.crealm.equals(rep.encKDCRepPart.srealm)) {
0N/A rep.encKDCRepPart.key.destroy();
0N/A throw new KrbApErrException(Krb5.KRB_AP_ERR_MODIFIED);
0N/A }
0N/A
0N/A if (req.reqBody.getNonce() != rep.encKDCRepPart.nonce) {
0N/A rep.encKDCRepPart.key.destroy();
0N/A throw new KrbApErrException(Krb5.KRB_AP_ERR_MODIFIED);
0N/A }
0N/A
0N/A if (
0N/A ((req.reqBody.addresses != null && rep.encKDCRepPart.caddr != null) &&
0N/A !req.reqBody.addresses.equals(rep.encKDCRepPart.caddr))) {
0N/A rep.encKDCRepPart.key.destroy();
0N/A throw new KrbApErrException(Krb5.KRB_AP_ERR_MODIFIED);
0N/A }
0N/A
0N/A
0N/A for (int i = 1; i < 6; i++) {
0N/A if (req.reqBody.kdcOptions.get(i) !=
0N/A rep.encKDCRepPart.flags.get(i)) {
0N/A throw new KrbApErrException(Krb5.KRB_AP_ERR_MODIFIED);
0N/A }
0N/A }
0N/A
0N/A // XXX Can renew a ticket but not ask for a renewable renewed ticket
0N/A // See impl of Credentials.renew().
0N/A if (req.reqBody.kdcOptions.get(KDCOptions.RENEWABLE) !=
0N/A rep.encKDCRepPart.flags.get(KDCOptions.RENEWABLE)) {
0N/A throw new KrbApErrException(Krb5.KRB_AP_ERR_MODIFIED);
0N/A }
0N/A if ((req.reqBody.from == null) || req.reqBody.from.isZero())
0N/A // verify this is allowed
0N/A if ((rep.encKDCRepPart.starttime != null) &&
0N/A !rep.encKDCRepPart.starttime.inClockSkew()) {
0N/A rep.encKDCRepPart.key.destroy();
0N/A throw new KrbApErrException(Krb5.KRB_AP_ERR_SKEW);
0N/A }
0N/A
0N/A if ((req.reqBody.from != null) && !req.reqBody.from.isZero())
0N/A // verify this is allowed
0N/A if ((rep.encKDCRepPart.starttime != null) &&
0N/A !req.reqBody.from.equals(rep.encKDCRepPart.starttime)) {
0N/A rep.encKDCRepPart.key.destroy();
0N/A throw new KrbApErrException(Krb5.KRB_AP_ERR_MODIFIED);
0N/A }
0N/A
0N/A if (!req.reqBody.till.isZero() &&
0N/A rep.encKDCRepPart.endtime.greaterThan(req.reqBody.till)) {
0N/A rep.encKDCRepPart.key.destroy();
0N/A throw new KrbApErrException(Krb5.KRB_AP_ERR_MODIFIED);
0N/A }
0N/A
0N/A if (req.reqBody.kdcOptions.get(KDCOptions.RENEWABLE))
0N/A if (req.reqBody.rtime != null && !req.reqBody.rtime.isZero())
0N/A // verify this is required
0N/A if ((rep.encKDCRepPart.renewTill == null) ||
0N/A rep.encKDCRepPart.renewTill.greaterThan(req.reqBody.rtime)
0N/A ) {
0N/A rep.encKDCRepPart.key.destroy();
0N/A throw new KrbApErrException(Krb5.KRB_AP_ERR_MODIFIED);
0N/A }
0N/A
0N/A if (req.reqBody.kdcOptions.get(KDCOptions.RENEWABLE_OK) &&
0N/A rep.encKDCRepPart.flags.get(KDCOptions.RENEWABLE))
0N/A if (!req.reqBody.till.isZero())
0N/A // verify this is required
0N/A if ((rep.encKDCRepPart.renewTill == null) ||
0N/A rep.encKDCRepPart.renewTill.greaterThan(req.reqBody.till)
0N/A ) {
0N/A rep.encKDCRepPart.key.destroy();
0N/A throw new KrbApErrException(Krb5.KRB_AP_ERR_MODIFIED);
0N/A }
0N/A }
0N/A
0N/A
0N/A}