auth_client_plugin.h 2.97 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2005 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

#ifndef AUTH_CLIENT_PLUGIN_H
/** Defined when <sofia-sip/auth_client_plugin.h> has been included. */
27
#define AUTH_CLIENT_PLUGIN_H
28 29 30

/**@file sofia-sip/auth_client_plugin.h
 * @brief Client-side plugin interface for authentication
31 32
 *
 * @note For extensions in 1.12.6 or later,
33 34
 * you have to define SOFIA_EXTEND_AUTH_CLIENT to 1
 * before including this file.
35
 *
36
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>
37
 *
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
 * @date Created: Fri May 19 16:18:21 EEST 2006
 */

#ifndef AUTH_CLIENT_H
#include "sofia-sip/auth_client.h"
#endif

#ifndef MSG_HEADER_H
#include <sofia-sip/msg_header.h>
#endif

SOFIA_BEGIN_DECLS

/* ====================================================================== */

struct auth_client_s {
  su_home_t     ca_home[1];
  auth_client_plugin_t const *ca_auc;

  auth_client_t *ca_next;

  char const   *ca_scheme;
  char const   *ca_realm;
  char         *ca_user;
  char         *ca_pass;

  msg_hclass_t *ca_credential_class;
65 66 67 68

#if SOFIA_EXTEND_AUTH_CLIENT
  int           ca_clear;
#endif
69 70 71 72
};

struct auth_client_plugin
{
73 74 75 76
  int auc_plugin_size;		/* Size of this structure */
  int auc_size;			/* Size of the client structure */

  char const *auc_name;		/* Name of the autentication scheme */
77

78
  /** Store challenge */
79
  int (*auc_challenge)(auth_client_t *ca,
80 81 82
		       msg_auth_t const *ch);

  /** Authorize request. */
83
  int (*auc_authorize)(auth_client_t *ca,
84
		       su_home_t *h,
85 86
		       char const *method,
		       url_t const *url,
87 88 89
		       msg_payload_t const *body,
		       msg_header_t **return_headers);

90 91
  /** Store nextnonce from Authentication-Info or Proxy-Authentication-Info. */
  int (*auc_info)(auth_client_t *ca, msg_auth_info_t const *ai);
92 93

#if SOFIA_EXTEND_AUTH_CLIENT
94
  /** Clear credentials (user/pass). @NEW_1_12_6. */
95 96
  int (*auc_clear)(auth_client_t *ca);
#endif
97 98
};

99
/** Check if authentication client has been extended. @NEW_1_12_6. */
100
#define AUTH_CLIENT_IS_EXTENDED(ca)					\
101 102
  ((ca)->ca_auc &&							\
   (ca)->ca_auc->auc_plugin_size >					\
103
   (int)offsetof(auth_client_plugin_t, auc_clear)			\
104 105
   && (ca)->ca_auc->auc_clear != NULL)

106 107 108
SOFIA_END_DECLS

#endif /* !defined AUTH_CLIENT_PLUGIN_H */