]>
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"
12 #include "auth/UserNameCache.h"
15 #include "SquidConfig.h"
16 #include "SquidTime.h"
18 Auth::Digest::User::User(Auth::Config
*aConfig
, const char *aRequestRealm
) :
19 Auth::User(aConfig
, aRequestRealm
),
22 memset(HA1
, 0, sizeof(HA1
));
25 Auth::Digest::User::~User()
27 dlink_node
*link
, *tmplink
;
33 dlinkDelete(tmplink
, &nonces
);
34 authDigestNoncePurge(static_cast < digest_nonce_h
* >(tmplink
->data
));
35 authDigestNonceUnlink(static_cast < digest_nonce_h
* >(tmplink
->data
));
36 dlinkNodeDelete(tmplink
);
41 Auth::Digest::User::ttl() const
43 int32_t global_ttl
= static_cast<int32_t>(expiretime
- squid_curtime
+ ::Config
.authenticateTTL
);
45 /* find the longest lasting nonce. */
46 int32_t latest_nonce
= -1;
47 dlink_node
*link
= nonces
.head
;
49 digest_nonce_h
*nonce
= static_cast<digest_nonce_h
*>(link
->data
);
50 if (nonce
->flags
.valid
&& nonce
->noncedata
.creationtime
> latest_nonce
)
51 latest_nonce
= nonce
->noncedata
.creationtime
;
55 if (latest_nonce
== -1)
56 return min(-1, global_ttl
);
58 int32_t nonce_ttl
= latest_nonce
- current_time
.tv_sec
+ static_cast<Config
*>(Auth::Config::Find("digest"))->noncemaxduration
;
60 return min(nonce_ttl
, global_ttl
);
64 Auth::Digest::User::currentNonce()
66 digest_nonce_h
*nonce
= NULL
;
67 dlink_node
*link
= nonces
.tail
;
69 nonce
= static_cast<digest_nonce_h
*>(link
->data
);
70 if (authDigestNonceIsStale(nonce
))
76 CbcPointer
<Auth::UserNameCache
>
77 Auth::Digest::User::Cache()
79 static CbcPointer
<Auth::UserNameCache
> p(new Auth::UserNameCache("digest"));
84 Auth::Digest::User::addToNameCache()
86 Cache()->insert(this);