1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * HTTP authentication 3cabdff1aSopenharmony_ci * Copyright (c) 2010 Martin Storsjo 4cabdff1aSopenharmony_ci * 5cabdff1aSopenharmony_ci * This file is part of FFmpeg. 6cabdff1aSopenharmony_ci * 7cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or 8cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 9cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either 10cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 11cabdff1aSopenharmony_ci * 12cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful, 13cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 14cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15cabdff1aSopenharmony_ci * Lesser General Public License for more details. 16cabdff1aSopenharmony_ci * 17cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 18cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software 19cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20cabdff1aSopenharmony_ci */ 21cabdff1aSopenharmony_ci 22cabdff1aSopenharmony_ci#ifndef AVFORMAT_HTTPAUTH_H 23cabdff1aSopenharmony_ci#define AVFORMAT_HTTPAUTH_H 24cabdff1aSopenharmony_ci 25cabdff1aSopenharmony_ci/** 26cabdff1aSopenharmony_ci * Authentication types, ordered from weakest to strongest. 27cabdff1aSopenharmony_ci */ 28cabdff1aSopenharmony_citypedef enum HTTPAuthType { 29cabdff1aSopenharmony_ci HTTP_AUTH_NONE = 0, /**< No authentication specified */ 30cabdff1aSopenharmony_ci HTTP_AUTH_BASIC, /**< HTTP 1.0 Basic auth from RFC 1945 31cabdff1aSopenharmony_ci * (also in RFC 2617) */ 32cabdff1aSopenharmony_ci HTTP_AUTH_DIGEST, /**< HTTP 1.1 Digest auth from RFC 2617 */ 33cabdff1aSopenharmony_ci} HTTPAuthType; 34cabdff1aSopenharmony_ci 35cabdff1aSopenharmony_citypedef struct DigestParams { 36cabdff1aSopenharmony_ci char nonce[300]; /**< Server specified nonce */ 37cabdff1aSopenharmony_ci char algorithm[10]; /**< Server specified digest algorithm */ 38cabdff1aSopenharmony_ci char qop[30]; /**< Quality of protection, containing the one 39cabdff1aSopenharmony_ci * that we've chosen to use, from the 40cabdff1aSopenharmony_ci * alternatives that the server offered. */ 41cabdff1aSopenharmony_ci char opaque[300]; /**< A server-specified string that should be 42cabdff1aSopenharmony_ci * included in authentication responses, not 43cabdff1aSopenharmony_ci * included in the actual digest calculation. */ 44cabdff1aSopenharmony_ci char stale[10]; /**< The server indicated that the auth was ok, 45cabdff1aSopenharmony_ci * but needs to be redone with a new, non-stale 46cabdff1aSopenharmony_ci * nonce. */ 47cabdff1aSopenharmony_ci int nc; /**< Nonce count, the number of earlier replies 48cabdff1aSopenharmony_ci * where this particular nonce has been used. */ 49cabdff1aSopenharmony_ci} DigestParams; 50cabdff1aSopenharmony_ci 51cabdff1aSopenharmony_ci/** 52cabdff1aSopenharmony_ci * HTTP Authentication state structure. Must be zero-initialized 53cabdff1aSopenharmony_ci * before used with the functions below. 54cabdff1aSopenharmony_ci */ 55cabdff1aSopenharmony_citypedef struct HTTPAuthState { 56cabdff1aSopenharmony_ci /** 57cabdff1aSopenharmony_ci * The currently chosen auth type. 58cabdff1aSopenharmony_ci */ 59cabdff1aSopenharmony_ci int auth_type; 60cabdff1aSopenharmony_ci /** 61cabdff1aSopenharmony_ci * Authentication realm 62cabdff1aSopenharmony_ci */ 63cabdff1aSopenharmony_ci char realm[200]; 64cabdff1aSopenharmony_ci /** 65cabdff1aSopenharmony_ci * The parameters specific to digest authentication. 66cabdff1aSopenharmony_ci */ 67cabdff1aSopenharmony_ci DigestParams digest_params; 68cabdff1aSopenharmony_ci /** 69cabdff1aSopenharmony_ci * Auth ok, but needs to be resent with a new nonce. 70cabdff1aSopenharmony_ci */ 71cabdff1aSopenharmony_ci int stale; 72cabdff1aSopenharmony_ci} HTTPAuthState; 73cabdff1aSopenharmony_ci 74cabdff1aSopenharmony_civoid ff_http_auth_handle_header(HTTPAuthState *state, const char *key, 75cabdff1aSopenharmony_ci const char *value); 76cabdff1aSopenharmony_cichar *ff_http_auth_create_response(HTTPAuthState *state, const char *auth, 77cabdff1aSopenharmony_ci const char *path, const char *method); 78cabdff1aSopenharmony_ci 79cabdff1aSopenharmony_ci#endif /* AVFORMAT_HTTPAUTH_H */ 80