|
|
|
|
| 8 |
|
8 |
|
| 9 |
#include "nsAutoPtr.h" |
9 |
#include "nsAutoPtr.h" |
| 10 |
#include "nsCOMPtr.h" |
10 |
#include "nsCOMPtr.h" |
| 11 |
#include "nsVoidArray.h" |
11 |
#include "nsVoidArray.h" |
| 12 |
#include "nsHashtable.h" |
12 |
#include "nsHashtable.h" |
| 13 |
#include "nsJSPrincipals.h" |
13 |
#include "nsJSPrincipals.h" |
| 14 |
#include "nsTArray.h" |
14 |
#include "nsTArray.h" |
| 15 |
#include "nsAutoPtr.h" |
15 |
#include "nsAutoPtr.h" |
|
|
16 |
#include "nsIProtocolHandler.h" |
| 17 |
#include "nsNetUtil.h" |
| 18 |
#include "nsScriptSecurityManager.h" |
| 16 |
|
19 |
|
| 17 |
class nsIObjectInputStream; |
20 |
class nsIObjectInputStream; |
| 18 |
class nsIObjectOutputStream; |
21 |
class nsIObjectOutputStream; |
| 19 |
class DomainPolicy; |
22 |
class DomainPolicy; |
| 20 |
|
23 |
|
| 21 |
class nsBasePrincipal : public nsJSPrincipals |
24 |
class nsBasePrincipal : public nsJSPrincipals |
| 22 |
{ |
25 |
{ |
| 23 |
public: |
26 |
public: |
|
|
| 124 |
NS_IMETHOD EqualsIgnoringDomain(nsIPrincipal* other, bool* _retval NS_OUTPARAM); |
127 |
NS_IMETHOD EqualsIgnoringDomain(nsIPrincipal* other, bool* _retval NS_OUTPARAM); |
| 125 |
NS_IMETHOD GetHashValue(PRUint32* aHashValue); |
128 |
NS_IMETHOD GetHashValue(PRUint32* aHashValue); |
| 126 |
NS_IMETHOD GetURI(nsIURI** aURI); |
129 |
NS_IMETHOD GetURI(nsIURI** aURI); |
| 127 |
NS_IMETHOD GetDomain(nsIURI** aDomain); |
130 |
NS_IMETHOD GetDomain(nsIURI** aDomain); |
| 128 |
NS_IMETHOD SetDomain(nsIURI* aDomain); |
131 |
NS_IMETHOD SetDomain(nsIURI* aDomain); |
| 129 |
NS_IMETHOD GetOrigin(char** aOrigin); |
132 |
NS_IMETHOD GetOrigin(char** aOrigin); |
| 130 |
NS_IMETHOD Subsumes(nsIPrincipal* other, bool* _retval NS_OUTPARAM); |
133 |
NS_IMETHOD Subsumes(nsIPrincipal* other, bool* _retval NS_OUTPARAM); |
| 131 |
NS_IMETHOD SubsumesIgnoringDomain(nsIPrincipal* other, bool* _retval NS_OUTPARAM); |
134 |
NS_IMETHOD SubsumesIgnoringDomain(nsIPrincipal* other, bool* _retval NS_OUTPARAM); |
| 132 |
NS_IMETHOD CheckMayLoad(nsIURI* uri, bool report); |
135 |
NS_IMETHOD CheckMayLoad(nsIURI* uri, bool report, bool allowIfInheritsPrincipal); |
| 133 |
#ifdef DEBUG |
136 |
#ifdef DEBUG |
| 134 |
virtual void dumpImpl(); |
137 |
virtual void dumpImpl(); |
| 135 |
#endif |
138 |
#endif |
| 136 |
// Either Init() or InitFromPersistent() must be called before |
139 |
// Either Init() or InitFromPersistent() must be called before |
| 137 |
// the principal is in a usable state. |
140 |
// the principal is in a usable state. |
| 138 |
nsresult Init(const nsACString& aCertFingerprint, |
141 |
nsresult Init(const nsACString& aCertFingerprint, |
| 139 |
const nsACString& aSubjectName, |
142 |
const nsACString& aSubjectName, |
| 140 |
const nsACString& aPrettyName, |
143 |
const nsACString& aPrettyName, |
|
|
| 148 |
const char* aDeniedList, |
151 |
const char* aDeniedList, |
| 149 |
nsISupports* aCert, |
152 |
nsISupports* aCert, |
| 150 |
bool aIsCert, |
153 |
bool aIsCert, |
| 151 |
bool aTrusted); |
154 |
bool aTrusted); |
| 152 |
|
155 |
|
| 153 |
virtual void GetScriptLocation(nsACString& aStr) MOZ_OVERRIDE; |
156 |
virtual void GetScriptLocation(nsACString& aStr) MOZ_OVERRIDE; |
| 154 |
void SetURI(nsIURI* aURI); |
157 |
void SetURI(nsIURI* aURI); |
| 155 |
|
158 |
|
|
|
159 |
static bool IsPrincipalInherited(nsIURI* aURI) { |
| 160 |
// return true if the loadee URI has |
| 161 |
// the URI_INHERITS_SECURITY_CONTEXT flag set. |
| 162 |
bool doesInheritSecurityContext; |
| 163 |
nsresult rv = |
| 164 |
NS_URIChainHasFlags(aURI, |
| 165 |
nsIProtocolHandler::URI_INHERITS_SECURITY_CONTEXT, |
| 166 |
&doesInheritSecurityContext); |
| 167 |
|
| 168 |
if (NS_SUCCEEDED(rv) && doesInheritSecurityContext) { |
| 169 |
return true; |
| 170 |
} |
| 171 |
|
| 172 |
return false; |
| 173 |
} |
| 174 |
|
| 156 |
nsCOMPtr<nsIURI> mDomain; |
175 |
nsCOMPtr<nsIURI> mDomain; |
| 157 |
nsCOMPtr<nsIURI> mCodebase; |
176 |
nsCOMPtr<nsIURI> mCodebase; |
| 158 |
// If mCodebaseImmutable is true, mCodebase is non-null and immutable |
177 |
// If mCodebaseImmutable is true, mCodebase is non-null and immutable |
| 159 |
bool mCodebaseImmutable; |
178 |
bool mCodebaseImmutable; |
| 160 |
bool mDomainImmutable; |
179 |
bool mDomainImmutable; |
| 161 |
bool mInitialized; |
180 |
bool mInitialized; |
| 162 |
}; |
181 |
}; |
| 163 |
|
182 |
|
|
|
| 177 |
NS_IMETHOD EqualsIgnoringDomain(nsIPrincipal* other, bool* _retval NS_OUTPARAM); |
196 |
NS_IMETHOD EqualsIgnoringDomain(nsIPrincipal* other, bool* _retval NS_OUTPARAM); |
| 178 |
NS_IMETHOD GetHashValue(PRUint32* aHashValue); |
197 |
NS_IMETHOD GetHashValue(PRUint32* aHashValue); |
| 179 |
NS_IMETHOD GetURI(nsIURI** aURI); |
198 |
NS_IMETHOD GetURI(nsIURI** aURI); |
| 180 |
NS_IMETHOD GetDomain(nsIURI** aDomain); |
199 |
NS_IMETHOD GetDomain(nsIURI** aDomain); |
| 181 |
NS_IMETHOD SetDomain(nsIURI* aDomain); |
200 |
NS_IMETHOD SetDomain(nsIURI* aDomain); |
| 182 |
NS_IMETHOD GetOrigin(char** aOrigin); |
201 |
NS_IMETHOD GetOrigin(char** aOrigin); |
| 183 |
NS_IMETHOD Subsumes(nsIPrincipal* other, bool* _retval NS_OUTPARAM); |
202 |
NS_IMETHOD Subsumes(nsIPrincipal* other, bool* _retval NS_OUTPARAM); |
| 184 |
NS_IMETHOD SubsumesIgnoringDomain(nsIPrincipal* other, bool* _retval NS_OUTPARAM); |
203 |
NS_IMETHOD SubsumesIgnoringDomain(nsIPrincipal* other, bool* _retval NS_OUTPARAM); |
| 185 |
NS_IMETHOD CheckMayLoad(nsIURI* uri, bool report); |
204 |
NS_IMETHOD CheckMayLoad(nsIURI* uri, bool report, bool allowIfInheritsPrincipal); |
| 186 |
#ifdef DEBUG |
205 |
#ifdef DEBUG |
| 187 |
virtual void dumpImpl(); |
206 |
virtual void dumpImpl(); |
| 188 |
#endif |
207 |
#endif |
| 189 |
|
208 |
|
| 190 |
virtual void GetScriptLocation(nsACString &aStr) MOZ_OVERRIDE; |
209 |
virtual void GetScriptLocation(nsACString &aStr) MOZ_OVERRIDE; |
| 191 |
|
210 |
|
| 192 |
private: |
211 |
private: |
| 193 |
nsTArray< nsCOMPtr<nsIPrincipal> > mPrincipals; |
212 |
nsTArray< nsCOMPtr<nsIPrincipal> > mPrincipals; |