Beispiel #1
0
 public OnCommandArgs(AuthLevel authLevel, string source, string host, string ident, string message, string nick)
 {
     AuthLevel = authLevel;
     Source = source;
     Host = host;
     Ident = ident;
     Message = message;
     Nick = nick;
 }
        public string AuthCalcUrl(string frob, AuthLevel authLevel)
        {
            if (sharedSecret == null) throw new SignatureRequiredException();

            string hash = sharedSecret + "api_key" + apiKey + "frob" + frob + "perms" + UtilityMethods.AuthLevelToString(authLevel);
            hash = UtilityMethods.MD5Hash(hash);
            string url = AuthUrl + "?api_key=" + apiKey + "&perms=" + UtilityMethods.AuthLevelToString(authLevel) + "&frob=" + frob;
            url += "&api_sig=" + hash;

            return url;
        }
Beispiel #3
0
 public static string AuthLevelToString(AuthLevel level)
 {
     switch (level)
       {
     case AuthLevel.None:
       return "none";
     case AuthLevel.Read:
       return "read";
     case AuthLevel.Write:
       return "write";
     case AuthLevel.Delete:
       return "delete";
     default:
       return string.Empty;
       }
 }
Beispiel #4
0
        /// <summary>
        /// Calculates the URL to redirect the user to Flickr web site for
        /// authentication. Used by Web applications. 
        /// See <see cref="AuthGetFrob"/> for example code.
        /// </summary>
        /// <param name="authLevel">The <see cref="AuthLevel"/> stating the maximum authentication level your application requires.</param>
        /// <param name="extra">An extra string value which Flickr will return to the callback URL along with the frob.</param>
        /// <returns>The url to redirect the user to.</returns>
        public string AuthCalcWebUrl(AuthLevel authLevel, string extra)
        {
            CheckApiKey();

            CheckSigned();

            string hash = sharedSecret + "api_key" + apiKey + "perms" + UtilityMethods.AuthLevelToString(authLevel);
            string url = AuthUrl + "?api_key=" + apiKey + "&perms=" + UtilityMethods.AuthLevelToString(authLevel);

            if (!String.IsNullOrEmpty(extra))
            {
                hash += "extra" + extra;
                url += "&extra=" + Uri.EscapeDataString(extra);
            }

            hash = UtilityMethods.MD5Hash(hash);
            url += "&api_sig=" + hash;

            return url;
        }
        /// <summary>
        /// Returns the authorization URL for OAuth authorization, based off the request token and permissions provided.
        /// </summary>
        /// <param name="requestToken">The request token to include in the authorization url.</param>
        /// <param name="perms">The permissions being requested.</param>
        /// <param name="mobile">Should the url be generated be the mobile one or not.</param>
        /// <returns></returns>
        public string OAuthCalculateAuthorizationUrl(string requestToken, AuthLevel perms, bool mobile)
        {
            string permsString = (perms == AuthLevel.None) ? "" : "&perms=" + Helper.AuthLevelToString(perms);

            return("http://" + (mobile ? "m" : "www") + ".flickr.com/services/oauth/authorize?oauth_token=" + requestToken + permsString);
        }
 public UserInfo(string cookie,
     string username,
     string state,
     bool admin,
     string organization,
     string email)
 {
     _cookie = cookie.TrimEnd();
     _username = username.TrimEnd();
     _state = state.TrimEnd();
     _authLevel = admin ? AuthLevel.Admin : AuthLevel.User;
     _organization = organization;
     _email = email;
 }
Beispiel #7
0
        /// <summary>
        /// Calculates the URL to redirect the user to Flickr web site for
        /// auehtntication. Used by Web applications. 
        /// See <see cref="AuthGetFrob"/> for example code.
        /// </summary>
        /// <remarks>
        /// The Flickr web site provides 'tiny urls' that can be used in place
        /// of this URL when you specify your return url in the API key page.
        /// It is recommended that you use these instead as they do not include
        /// your API or shared secret.
        /// </remarks>
        /// <param name="authLevel">The <see cref="AuthLevel"/> stating the maximum authentication level your application requires.</param>
        /// <returns>The url to redirect the user to.</returns>
        public string AuthCalcWebUrl(AuthLevel authLevel)
        {
            if( _sharedSecret == null ) throw new FlickrException(0, "AuthGetToken requires signing. Please supply api key and secret.");

            string hash = _sharedSecret + "api_key" + _apiKey + "perms" + authLevel.ToString().ToLower();
            hash = Md5Hash(hash);
            string url = AuthUrl + "?api_key=" + _apiKey + "&perms=" + authLevel.ToString().ToLower();
            url += "&api_sig=" + hash;

            return url;
        }
Beispiel #8
0
 /// <summary>
 /// Calculates the URL to redirect the user to Flickr mobile web site for
 /// authentication. Used by Web based authentication flow (with callback) on smart phone devices.
 /// See <see cref="AuthGetFrob"/> for example code.
 /// </summary>
 /// <param name="authLevel">The <see cref="AuthLevel"/> stating the maximum authentication level your application requires.</param>
 /// <returns>The url to redirect the user to.</returns>
 public string AuthCalcWebUrlMobile(AuthLevel authLevel)
 {
     return(AuthCalcWebUrl(authLevel).Replace("www.flickr.com", "m.flickr.com"));
 }
		internal PromptAuthEventArgs(AuthLevel authLevel, nsIAuthInformation authInformation, String checkMsg, Boolean checkState)
			: base(false)
		{
			m_AuthLevel = authLevel;
			m_AuthFlags = (AuthFlags)authInformation.Flags;
			m_Realm = XpcomStringHelper.Get(authInformation.GetRealm);
			m_AuthScheme = XpcomStringHelper.Get(authInformation.GetAuthenticationScheme);
			Username = XpcomStringHelper.Get(authInformation.GetUsername);
			Password = XpcomStringHelper.Get(authInformation.GetPassword);
			Domain = XpcomStringHelper.Get(authInformation.GetDomain);
			m_CheckMsg = checkMsg;
			CheckState = checkState;
		}
		internal AsyncPromptAuthEventArgs(nsIAuthPromptCallback callback, Object context, AuthLevel authLevel, nsIAuthInformation authInformation, String checkMsg, Boolean checkState)
			: base(authLevel, authInformation, checkMsg, checkState)
		{
			m_AuthCallback = callback;
			m_Context = context;
			m_AuthInformation = authInformation;
		}
Beispiel #11
0
 public string AuthCalcUrlMobile(string frob, AuthLevel authLevel)
 {
     return AuthCalcUrl(frob, authLevel).Replace("www.flickr.com", "m.flickr.com");
 }
 /// <summary>
 /// Returns the authorization URL for OAuth authorization, based off the request token and permissions provided.
 /// </summary>
 /// <param name="requestToken">The request token to include in the authorization url.</param>
 /// <param name="perms">The permissions being requested.</param>
 /// <returns></returns>
 public string OAuthCalculateAuthorizationUrl(string requestToken, AuthLevel perms)
 {
     return(OAuthCalculateAuthorizationUrl(requestToken, perms, false));
 }
Beispiel #13
0
 /// <summary>
 /// Returns the authorization URL for OAuth authorization, based off the request token and permissions provided.
 /// </summary>
 /// <param name="requestToken">The request token to include in the authorization url.</param>
 /// <param name="perms">The permissions being requested.</param>
 /// <returns></returns>
 public string OAuthCalculateAuthorizationUrl(string requestToken, AuthLevel perms)
 {
     return OAuthCalculateAuthorizationUrl(requestToken, perms, false);
 }
Beispiel #14
0
 public string AuthCalcWebUrlMobile(AuthLevel authLevel)
 {
     return AuthCalcWebUrl(authLevel).Replace("www.flickr.com", "m.flickr.com");
 }
 public string AuthCalcMobileUrl(AuthLevel authLevel);
 public string AuthCalcWebUrl(AuthLevel authLevel);
 public string AuthCalcUrl(string frob, AuthLevel authLevel);
Beispiel #18
0
 /// <summary>
 /// Calculates the URL to redirect the user to Flickr web site for
 /// authentication. Used by Web applications.
 /// See <see cref="AuthGetFrob"/> for example code.
 /// </summary>
 /// <param name="authLevel">The <see cref="AuthLevel"/> stating the maximum authentication level your application requires.</param>
 /// <returns>The url to redirect the user to.</returns>
 public string AuthCalcWebUrl(AuthLevel authLevel)
 {
     return(AuthCalcWebUrl(authLevel, null));
 }
Beispiel #19
0
 /// <summary>
 /// Calculates the URL to redirect the user to Flickr mobile web site for
 /// authentication. Used by desktop based authentication flow on smart phone devices.
 /// See <see cref="AuthGetFrob"/> for example code.
 /// </summary>
 /// <param name="frob">The FROB to be used for authentication.</param>
 /// <param name="authLevel">The <see cref="AuthLevel"/> stating the maximum authentication level your application requires.</param>
 /// <returns>The url to redirect the user to.</returns>
 public string AuthCalcUrlMobile(string frob, AuthLevel authLevel)
 {
     return(AuthCalcUrl(frob, authLevel).Replace("www.flickr.com", "m.flickr.com"));
 }
Beispiel #20
0
        /// <summary>
        /// Returns the authorization URL for OAuth authorization, based off the request token and permissions provided.
        /// </summary>
        /// <param name="requestToken">The request token to include in the authorization url.</param>
        /// <param name="perms">The permissions being requested.</param>
        /// <param name="mobile">Should the url be generated be the mobile one or not.</param>
        /// <returns></returns>
        public string OAuthCalculateAuthorizationUrl(string requestToken, AuthLevel perms, bool mobile)
        {
            string permsString = (perms == AuthLevel.None) ? "" : "&perms=" + UtilityMethods.AuthLevelToString(perms);

            return "https://" + (mobile?"m":"www") + ".flickr.com/services/oauth/authorize?oauth_token=" + requestToken + permsString;
        }
Beispiel #21
0
 private UserInfo()
 {
     _cookie = "0";
     _username = "******";
     _state = "";
     _authLevel = AuthLevel.Guest;
     _organization = "";
     _email = "";
 }
		/// <summary>
		/// Calculates the URL to redirect the user to Flickr web site for
		/// auehtntication. Used by Web applications.
		/// See <see cref="AuthGetFrob"/> for example code.
		/// </summary>
		/// <remarks>
		/// The Flickr web site provides 'tiny urls' that can be used in place
		/// of this URL when you specify your return url in the API key page.
		/// It is recommended that you use these instead as they do not include
		/// your API or shared secret.
		/// </remarks>
		/// <param name="authLevel">The <see cref="AuthLevel"/> stating the maximum authentication level your application requires.</param>
		/// <returns>The url to redirect the user to.</returns>
		public string AuthCalcWebUrl(AuthLevel authLevel)
		{
			if( _sharedSecret == null ) throw new SignatureRequiredException();

			string hash = _sharedSecret + "api_key" + _apiKey + "perms" + authLevel.ToString().ToLower();
			hash = Md5Hash(hash);
			string url = AuthUrl + "?api_key=" + _apiKey + "&perms=" + authLevel.ToString().ToLower();
			url += "&api_sig=" + hash;

			return url;
		}
Beispiel #23
0
        /// <summary>
        /// Returns the authorization URL for OAuth authorization, based off the request token and permissions provided.
        /// </summary>
        /// <param name="requestToken">The request token to include in the authorization url.</param>
        /// <param name="perms">The permissions being requested.</param>
        /// <returns></returns>
        public string OAuthCalculateAuthorizationUrl(string requestToken, AuthLevel perms)
        {
            string permsString = (perms == AuthLevel.None) ? "" : "&perms=" + UtilityMethods.AuthLevelToString(perms);

            return AuthUrl + "?oauth_token=" + requestToken + permsString;
            //return AuthUrl + "http://www.flickr.com/services/oauth/authorize?oauth_token=" + requestToken + permsString;
        }
Beispiel #24
0
 public string AuthCalcWebUrl(AuthLevel authLevel)
 {
     return AuthCalcWebUrl(authLevel, null);
 }
Beispiel #25
0
 public override string ToString()
 {
     return($"Auth({Name}, {AuthLevel.ToString()}, {Style.ToString()})[{TotalActionsPerformed}]");
 }