public ApiContext GetAuthorizedContext(PelicanContext pelicanContext,
                                               Guid companyFileId)
        {
            var keyService = new OAuthKeyService(this);

            var configuration = new ApiConfiguration(pelicanContext.ClientKey,
                                                     pelicanContext.ClientSecret,
                                                     pelicanContext.RedirectUrl);

            // get companyfiles
            var cfService = new CompanyFileService(configuration,
                                                   null,
                                                   keyService);
            var companyFiles = cfService.GetRange();

            // select
            var companyFile = companyFiles.FirstOrDefault(_ => _.Id == companyFileId);

            // fetch accounts
            var credentials = new CompanyFileCredentials("Administrator",
                                                         "");

            return new ApiContext
                   {
                       ApiConfiguration = configuration,
                       CompanyFileCredentials = credentials,
                       KeyService = keyService,
                       CompanyFile = companyFile,
                   };
        }
        public AuthorizationService()
        {
            _pelicanContext = PelicanContext.CreateFromApplicationSettings();

            var cloudStorageAccount = new CloudStorageAccount(new StorageCredentials(_pelicanContext.StorageAccount,
                                                                                     _pelicanContext.StorageAccountKey),
                                                              true);

            var configuration = new ApiConfiguration(_pelicanContext.ClientKey,
                                                     _pelicanContext.ClientSecret,
                                                     _pelicanContext.RedirectUrl);

            _oauthService = new OAuthService(configuration);

            _authorizedUserAndFileTable = new AuthorizedUserAndFileTable(cloudStorageAccount,
                                                                         "PelicanConfiguration");

            _authorizedUserAndCompanyFile = _authorizedUserAndFileTable.RetrieveInstanceByRowKey("John Azariah");
        }
Esempio n. 3
0
 public PelicanService(PelicanContext context)
 {
     _context = context;
 }
Esempio n. 4
0
 public WorkerRole()
 {
     _context = PelicanContext.CreateFromCloudConfiguration();
 }