1 2 /* Web Polygraph http://www.web-polygraph.org/ 3 * Copyright 2003-2011 The Measurement Factory 4 * Licensed under the Apache License, Version 2.0 */ 5 6 #ifndef POLYGRAPH__RUNTIME_USERCRED_H 7 #define POLYGRAPH__RUNTIME_USERCRED_H 8 9 #include "xstd/String.h" 10 11 class Connection; 12 class NetAddr; 13 class ObjId; 14 15 // maintains information about user credentials 16 class UserCred { 17 public: UserCred()18 UserCred(): isValid(true) {} UserCred(const String & anImage)19 UserCred(const String &anImage): theImage(anImage), isValid(true) {} 20 21 void finalize(const ObjId &oid); 22 void finalize(const Connection &conn); 23 reset()24 void reset() { theImage = String(); isValid = true; } 25 valid()26 bool valid() const { return isValid; } hasMacros()27 bool hasMacros() const { return theImage.str(TheTargetIpMacro); } image()28 const String &image() const { return theImage; } 29 Area name(bool &hasRealm) const; name()30 Area name() const { bool hasRealm; return name(hasRealm); } 31 Area password() const; 32 33 void invalidate(); 34 35 protected: 36 void finalize(const NetAddr &addr); 37 Area takeUntil(const char *const c) const; 38 39 static const String TheTargetIpMacro; 40 41 String theImage; // NAME @ REALM : PASSWORD 42 bool isValid; 43 }; 44 45 #endif 46