]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/auth/digest/User.cc
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
10 #include "auth/digest/Config.h"
11 #include "auth/digest/User.h"
14 #include "SquidConfig.h"
15 #include "SquidTime.h"
17 Auth::Digest::User::User(Auth::Config
*aConfig
, const char *aRequestRealm
) :
18 Auth::User(aConfig
, aRequestRealm
),
21 memset(HA1
, 0, sizeof(HA1
));
24 Auth::Digest::User::~User()
26 dlink_node
*link
, *tmplink
;
32 dlinkDelete(tmplink
, &nonces
);
33 authDigestNoncePurge(static_cast < digest_nonce_h
* >(tmplink
->data
));
34 authDigestNonceUnlink(static_cast < digest_nonce_h
* >(tmplink
->data
));
35 dlinkNodeDelete(tmplink
);
40 Auth::Digest::User::ttl() const
42 int32_t global_ttl
= static_cast<int32_t>(expiretime
- squid_curtime
+ ::Config
.authenticateTTL
);
44 /* find the longest lasting nonce. */
45 int32_t latest_nonce
= -1;
46 dlink_node
*link
= nonces
.head
;
48 digest_nonce_h
*nonce
= static_cast<digest_nonce_h
*>(link
->data
);
49 if (nonce
->flags
.valid
&& nonce
->noncedata
.creationtime
> latest_nonce
)
50 latest_nonce
= nonce
->noncedata
.creationtime
;
54 if (latest_nonce
== -1)
55 return min(-1, global_ttl
);
57 int32_t nonce_ttl
= latest_nonce
- current_time
.tv_sec
+ static_cast<Config
*>(Auth::Config::Find("digest"))->noncemaxduration
;
59 return min(nonce_ttl
, global_ttl
);
63 Auth::Digest::User::currentNonce()
65 digest_nonce_h
*nonce
= NULL
;
66 dlink_node
*link
= nonces
.tail
;
68 nonce
= static_cast<digest_nonce_h
*>(link
->data
);
69 if (authDigestNonceIsStale(nonce
))