internal bool isValidWSShareKey(WSJson shareKeys, Type eType) { bool _isValid = false; try { _isValid = generateWSShareKeyByType(eType).Match(shareKeys); } catch (Exception e) { CFunc.RegError(GetType(), e, ref status); } return(_isValid); }
internal bool IsValidUser(WSJson jUser) { bool _isValid = false; try { _isValid = AuthToken.User.Match(jUser); } catch (Exception e) { CFunc.RegError(GetType(), e, ref status); } return(_isValid); }
internal bool Match(WSJson jUserData, string _key = null) { try { if (jUserData != null && jUserData.IsValid) { if (jUserData is WSJObject) { return(MatchObject((WSJObject)jUserData, _key)); } else if (jUserData is WSJArray) { return(MatchArray((WSJArray)jUserData, _key)); } } } catch (Exception) { /*CFunc.RegError(GetType(), e);*/ return(false); } return(true); }
internal bool Match(WSJson jData, string _key = null) { try { if (jData != null && jData.IsValid) { if (jData is WSJObject) { return(MatchObject((WSJObject)jData, _key)); } else if (jData is WSJArray) { return(MatchArray((WSJArray)jData, _key)); } } } catch (Exception) { return(false); } return(true); }
internal bool validateWSAccessKey(string hostKey, WSJson accessKey, out WSAccessKey key) { key = null; try { string _MD5Key = null; DateTime?_startDate = null; DateTime?_endDate = null; #region read 'accessKey' if (accessKey is WSJValue) { _MD5Key = ((WSJValue)accessKey).Value; } else if (accessKey is WSJObject) { List <WSJProperty> props = ((WSJObject)accessKey).Value; foreach (WSJProperty prop in props) { string val = ((WSJValue)prop.Value).Value; DateTime tempDate = DateTime.MinValue; switch (prop.Key) { case "MD5Key": _MD5Key = val; break; case "startDate": tempDate = DateTime.MinValue; if (new WSConverter().ToDate(val, out tempDate)) { _startDate = tempDate; } else { _MD5Key = null; } break; case "endDate": tempDate = DateTime.MaxValue; if (new WSConverter().ToDate(val, out tempDate)) { _endDate = tempDate; } else { _MD5Key = null; } break; } } } #endregion if (!string.IsNullOrEmpty(_MD5Key)) { #region validate 'accessKey' key = new WSAccessKey(this, hostKey, _MD5Key, _startDate, _endDate); WSAccessKey tempKey = new WSAccessKey( this, hostKey, generateKey( hostKey, _startDate == null ? null : ((DateTime)_startDate).ToString(WSConstants.DATE_FORMAT_MIN), _endDate == null ? null : ((DateTime)_endDate).ToString(WSConstants.DATE_FORMAT_MIN) ), _startDate, _endDate ); if (key.Match(tempKey)) { return(true); } else { key = null; } #endregion } } catch (Exception e) { key = null; CFunc.RegError(GetType(), e, ref status); } return(false); }