Digital Authentication Framework 6.0.1.33
|
00001 /* 00002 * (c) 2014 Good Technology Corporation. All rights reserved. 00003 */ 00004 00010 #ifndef DAF_AUTH_STATE_H 00011 #define DAF_AUTH_STATE_H 00012 00013 #include "daf_auth_identify.h" 00014 00015 struct json_object; 00016 00026 class DAAuthState 00027 { 00028 public: 00030 DAAuthState(); 00031 00033 DAAuthState(const DAAuthState &other); 00034 00036 void operator=(const DAAuthState &other); 00037 00039 ~DAAuthState(); 00040 00042 std::string marshal() const; 00043 00046 bool unmarshal(const std::string &str); 00047 00048 /* --- Auth class --- */ 00052 bool getAuthClass(DAAuthClass &cls); 00053 00055 void setAuthClass(DAAuthClass cls); 00056 00057 /* --- Key serial --- */ 00059 void setKeySerial(const std::string &ks); 00060 00062 bool hasKeySerial(); 00063 00066 bool getKeySerial(std::string &ks_out); 00067 00068 /* --- User string --- */ 00069 00071 void setUserString(const std::string &us); 00072 00074 bool getUserString(std::string &us_out); 00075 00076 /* --- DAMessage --- */ 00078 void setDAMessage(const DAMessage &msg); 00079 00082 bool getDAMessage(DAMessage &msg); 00083 00084 private: 00085 /* The underlying object. Never NULL. */ 00086 struct json_object *m_json; 00087 00088 /* Take the given DAData contents, and make a json_object 00089 * which expresses it (as a base64 encoded string) */ 00090 struct json_object * encodeBytes(const DAData &bytes); 00091 00092 /* Take the given base64 encoded c-string, and fill in 00093 * \p out with the raw string. Returns false if base64 00094 * encoding is broken. */ 00095 bool decodeBytes(const char *b64_cstr, DAData &out); 00096 00097 /* Set a simple string value in object. */ 00098 void setString(const char *key, const char *val); 00099 00100 /* Return true if there is a mapping of \p key to anything. */ 00101 bool hasValue(const char *key); 00102 00103 /* Retreive the string value of the mapping of \p key. 00104 * Returns false if there is no mapping, or it isn't 00105 * to a string. */ 00106 bool getString(const char *key, std::string &out); 00107 }; 00108 00109 #endif