//Method to Authenticate the credentials and obtain token
        public void Authenticate()
        {
            try
            {
                //Creating an instance of CloudIdentityProvider providing the CloudIdentity object and urls in the constructor
                provider = new CloudIdentityProvider(identity, "https://identity.api.rackspacecloud.com/v1.0", "https://lon.identity.api.rackspacecloud.com/v1.0");
                //Calling the authenticate method which returns an UserAccess object containing token and user details
                UserAccess access = provider.Authenticate(identity);

                token = access.Token;

                userdetails = access.User;
                //Set the TokenId property
                TokenId = token.Id;
                //Verify with other programmers to make this method void
                cloudFiles = new CloudFilesProvider(identity);
                //return token.Id;
            }

            catch (UserAuthenticationException ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
            catch (UserAuthorizationException ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
            catch (UserNotAuthorizedException ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UserAccess"/> class
 /// with the specified token, user, and service catalog.
 /// </summary>
 /// <param name="token">The <see cref="IdentityToken "/>.</param>
 /// <param name="user">The <see cref="UserDetails"/>.</param>
 /// <param name="serviceCatalog">List of <see cref="ServiceCatalog"/>s.</param>
 public UserAccess(IdentityToken token, UserDetails user, ServiceCatalog[] serviceCatalog)
 {
     Token = token;
     User = user;
     ServiceCatalog = serviceCatalog;
 }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserAccess"/> class
 /// with the specified token, user, and service catalog.
 /// </summary>
 /// <param name="token">The <see cref="IdentityToken "/>.</param>
 /// <param name="user">The <see cref="UserDetails"/>.</param>
 /// <param name="serviceCatalog">List of <see cref="ServiceCatalog"/>s.</param>
 public UserAccess(IdentityToken token, UserDetails user, ServiceCatalog[] serviceCatalog)
 {
     Token          = token;
     User           = user;
     ServiceCatalog = serviceCatalog;
 }