2N/A/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2N/A/*
2N/A * Copyright 1993 by OpenVision Technologies, Inc.
2N/A *
2N/A * Permission to use, copy, modify, distribute, and sell this software
2N/A * and its documentation for any purpose is hereby granted without fee,
2N/A * provided that the above copyright notice appears in all copies and
2N/A * that both that copyright notice and this permission notice appear in
2N/A * supporting documentation, and that the name of OpenVision not be used
2N/A * in advertising or publicity pertaining to distribution of the software
2N/A * without specific, written prior permission. OpenVision makes no
2N/A * representations about the suitability of this software for any
2N/A * purpose. It is provided "as is" without express or implied warranty.
2N/A *
2N/A * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
2N/A * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
2N/A * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
2N/A * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
2N/A * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2N/A * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2N/A * PERFORMANCE OF THIS SOFTWARE.
2N/A */
2N/A
2N/A#include "gssapiP_krb5.h"
2N/A
2N/A/*
2N/A * $Id: context_time.c 23457 2009-12-08 00:04:48Z tlyu $
2N/A */
2N/A
2N/AOM_uint32
2N/Akrb5_gss_context_time(minor_status, context_handle, time_rec)
2N/A OM_uint32 *minor_status;
2N/A gss_ctx_id_t context_handle;
2N/A OM_uint32 *time_rec;
2N/A{
2N/A krb5_error_code code;
2N/A krb5_gss_ctx_id_rec *ctx;
2N/A krb5_timestamp now;
2N/A krb5_deltat lifetime;
2N/A
2N/A /* validate the context handle */
2N/A if (! kg_validate_ctx_id(context_handle)) {
2N/A *minor_status = (OM_uint32) G_VALIDATE_FAILED;
2N/A return(GSS_S_NO_CONTEXT);
2N/A }
2N/A
2N/A ctx = (krb5_gss_ctx_id_rec *) context_handle;
2N/A
2N/A if (! ctx->established) {
2N/A *minor_status = KG_CTX_INCOMPLETE;
2N/A return(GSS_S_NO_CONTEXT);
2N/A }
2N/A
2N/A if ((code = krb5_timeofday(ctx->k5_context, &now))) {
2N/A *minor_status = code;
2N/A save_error_info(*minor_status, ctx->k5_context);
2N/A return(GSS_S_FAILURE);
2N/A }
2N/A
2N/A if ((lifetime = ctx->krb_times.endtime - now) <= 0) {
2N/A *time_rec = 0;
2N/A *minor_status = 0;
2N/A return(GSS_S_CONTEXT_EXPIRED);
2N/A } else {
2N/A *time_rec = lifetime;
2N/A *minor_status = 0;
2N/A return(GSS_S_COMPLETE);
2N/A }
2N/A}