/// <summary>
        /// create an app key given an AppHandle and a DeveloperId
        /// </summary>
        /// <param name="args">command line args</param>
        /// <returns>a task</returns>
        private async Task CreateAppKey(string[] args)
        {
            this.ParseAppKeyArgs(args);

            this.ValidateCreateAppKey();

            IAppProfileEntity appProfileEntity = await this.appsManager.ReadAppProfile(this.appHandle);

            if (appProfileEntity == null)
            {
                Console.WriteLine("Cannot find app with appHandle = {0}", this.appHandle);
                Environment.Exit(0);
            }

            if (appProfileEntity.DeveloperId == this.appDeveloperId)
            {
                // create an app key if the key isn't specified
                if (this.appKey == null)
                {
                    this.appKey = Guid.NewGuid().ToString();
                }

                await this.appsManager.CreateAppKey(ProcessType.Frontend, this.appHandle, this.appKey, DateTime.UtcNow);

                Console.WriteLine("AppKey = {0} created for appHandle = {1}", this.appKey, this.appHandle);
            }
            else
            {
                Console.WriteLine(
                    "Incorrect developerId: developerId is {0} for appHandle {1}",
                    appProfileEntity.DeveloperId,
                    this.appHandle);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Get details on a specific application
        /// </summary>
        /// <param name="args">command line args</param>
        /// <returns>a task</returns>
        private async Task GetApp(string[] args)
        {
            this.ParseLookupAppArgs(args);

            this.ValidateGetApp();

            IAppProfileEntity appProfileEntity = await this.appsManager.ReadAppProfile(this.appHandle);

            if (appProfileEntity == null)
            {
                Console.WriteLine($"Cannot find app with appHandle = {this.appHandle}");
                Environment.Exit(0);
            }

            Console.WriteLine($"App profile for appHandle {0}", this.appHandle);
            Console.WriteLine($"  Name = {appProfileEntity.Name}");
            Console.WriteLine($"  PlatformType = {appProfileEntity.PlatformType}");
            Console.WriteLine($"  DeveloperId = {appProfileEntity.DeveloperId}");
            Console.WriteLine($"  DeepLink = {appProfileEntity.DeepLink}");
            Console.WriteLine($"  StoreLink = {appProfileEntity.StoreLink}");
            Console.WriteLine($"  IconHandle = {appProfileEntity.IconHandle}");
            Console.WriteLine($"  AppStatus = {appProfileEntity.AppStatus}");
            Console.WriteLine($"  CreatedTime = {appProfileEntity.CreatedTime}");
            Console.WriteLine($"  LastUpdateTime = {appProfileEntity.LastUpdatedTime}");
        }
        /// <summary>
        /// get the list of app keys associated with an AppHandle
        /// </summary>
        /// <param name="args">command line args</param>
        /// <returns>a task</returns>
        private async Task GetAppKeys(string[] args)
        {
            this.ParseAppKeyArgs(args);

            this.ValidateGetAppKeys();

            IAppProfileEntity appProfileEntity = await this.appsManager.ReadAppProfile(this.appHandle);

            if (appProfileEntity == null)
            {
                Console.WriteLine("Cannot find app with appHandle = {0}", this.appHandle);
                Environment.Exit(0);
            }

            var entities = await this.appsManager.ReadAppKeys(this.appHandle);

            if (entities.Count == 0)
            {
                Console.WriteLine("No app keys found for appHandle {0}", this.appHandle);
            }
            else
            {
                Console.WriteLine("Keys for appHandle = {0}", this.appHandle);
                foreach (var entity in entities)
                {
                    Console.WriteLine("  Key = {0}", entity.AppKey);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// delete an app (using the specified developerId and appHandle)
        /// </summary>
        /// <param name="args">command line args</param>
        /// <returns>a task</returns>
        private async Task DeleteApp(string[] args)
        {
            this.ParseLookupAppArgs(args);

            this.ValidateDeleteApp();

            IAppProfileEntity appProfileEntity = await this.appsManager.ReadAppProfile(this.appHandle);

            if (appProfileEntity == null)
            {
                Console.WriteLine($"Cannot delete app for appHandle = {this.appHandle}");
                Environment.Exit(0);
            }

            if (appProfileEntity.DeveloperId == this.appDeveloperId)
            {
                await this.appsManager.DeleteApp(ProcessType.Frontend, this.appDeveloperId, this.appHandle);

                Console.WriteLine($"Application {appProfileEntity.Name} deleted, appHandle = {this.appHandle} developerId = {this.appDeveloperId}");
            }
            else
            {
                Console.WriteLine($"Incorrect developerId: developerId is {appProfileEntity.DeveloperId} for appHandle {this.appHandle}");
            }
        }
        /// <summary>
        /// delete an app key given an AppHandle, a DeveloperId, and the AppKey to delete
        /// </summary>
        /// <param name="args">command line args</param>
        /// <returns>a task</returns>
        private async Task DeleteAppKey(string[] args)
        {
            this.ParseAppKeyArgs(args);

            this.ValidateDeleteAppKey();

            IAppProfileEntity appProfileEntity = await this.appsManager.ReadAppProfile(this.appHandle);

            if (appProfileEntity == null)
            {
                Console.WriteLine("Cannot find app with appHandle = {0}", this.appHandle);
                Environment.Exit(0);
            }

            if (appProfileEntity.DeveloperId == this.appDeveloperId)
            {
                await this.appsManager.DeleteAppKey(ProcessType.Frontend, this.appHandle, this.appKey);

                Console.WriteLine("AppKey = {0} deleted for appHandle = {1}", this.appKey, this.appHandle);
            }
            else
            {
                Console.WriteLine(
                    "Incorrect developerId: developerId is {0} for appHandle {1}",
                    appProfileEntity.DeveloperId,
                    this.appHandle);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// gets the push configuration for an app
        /// </summary>
        /// <param name="args">command line args</param>
        /// <returns>a task</returns>
        private async Task GetPush(string[] args)
        {
            this.ParseLookupPushArgs(args);

            this.ValidateGetPush();

            IAppProfileEntity appProfileEntity = await this.appsManager.ReadAppProfile(this.appHandle);

            if (appProfileEntity == null)
            {
                Console.WriteLine("Cannot find app with appHandle = {0}", this.appHandle);
                Environment.Exit(0);
            }

            IPushNotificationsConfigurationEntity entity = await this.appsManager.ReadPushNotificationsConfiguration(this.appHandle, (PlatformType)this.appPlatformType);

            if (entity != null)
            {
                Console.WriteLine("Push notifications config for appHandle {0} on platform {1}", this.appHandle, (PlatformType)this.appPlatformType);
                Console.WriteLine("  Enabled = {0}", entity.Enabled);
                Console.WriteLine("  Key = {0}", entity.Key);
                Console.WriteLine("  Path = {0}", entity.Path);
            }
            else
            {
                Console.WriteLine("Cannot find push config for appHandle {0} on platform {1}", this.appHandle, (PlatformType)this.appPlatformType);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// create an app administrator given an AppHandle and a UserHandle
        /// </summary>
        /// <param name="args">command line args</param>
        /// <returns>a task</returns>
        private async Task CreateAppAdmin(string[] args)
        {
            this.ParseAppAdminArgs(args);

            this.ValidateAppAdmin();

            IAppProfileEntity appProfileEntity = await this.appsManager.ReadAppProfile(this.appHandle);

            if (appProfileEntity == null)
            {
                Console.WriteLine("Cannot find app with appHandle = {0}", this.appHandle);
                Environment.Exit(0);
            }

            IUserProfileEntity userProfileEntity = await this.usersManager.ReadUserProfile(this.userHandle, this.appHandle);

            if (userProfileEntity == null)
            {
                Console.WriteLine("Cannot find user with userHandle = {0} in app with appHandle = {1}", this.userHandle, this.appHandle);
                Environment.Exit(0);
            }

            bool isAdmin = await this.appsManager.IsAdminUser(this.appHandle, this.userHandle);

            if (isAdmin)
            {
                Console.WriteLine("Cannot create a new administrator: UserHandle = {0} is already an admin in app with appHandle = {1}", this.userHandle, this.appHandle);
            }
            else
            {
                await this.appsManager.InsertAdminUser(this.appHandle, this.userHandle);

                Console.WriteLine("UserHandle = {0} is now an admin for appHandle = {1}", this.userHandle, this.appHandle);
            }
        }
        /// <summary>
        /// Read the identity provider configuration for an app
        /// </summary>
        /// <param name="args">command line args</param>
        /// <returns>a task</returns>
        private async Task GetIdentityProvider(string[] args)
        {
            this.ParseIdentityLookupArgs(args);

            this.ValidateGetIdentityProvider();

            IAppProfileEntity appProfileEntity = await this.appsManager.ReadAppProfile(this.appHandle);

            if (appProfileEntity == null)
            {
                Console.WriteLine("Cannot find app with appHandle = {0}", this.appHandle);
                Environment.Exit(0);
            }

            IIdentityProviderCredentialsEntity credentialsEntity = await this.appsManager.ReadIdentityProviderCredentials(this.appHandle, (IdentityProviderType)this.identityProvider);

            if (credentialsEntity != null)
            {
                Console.WriteLine("Identity provider config for appHandle {0}, identity provider type {1}", this.appHandle, (IdentityProviderType)this.identityProvider);
                Console.WriteLine("  Client Id = {0}", credentialsEntity.ClientId);
                Console.WriteLine("  Client secret = {0}", credentialsEntity.ClientSecret);
                Console.WriteLine("  Redirect Uri = {0}", credentialsEntity.ClientRedirectUri);
            }
            else
            {
                Console.WriteLine(
                    "Cannot find identity provider config for appHandle {0}, identity provider type {1}",
                    this.appHandle,
                    (IdentityProviderType)this.identityProvider);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Update the application profile data
        /// </summary>
        /// <param name="args">command line args</param>
        /// <returns>a task</returns>
        private async Task UpdateAppProfile(string[] args)
        {
            this.ParseAppProfileArgs(args);

            this.ValidateUpdateAppProfile();

            IAppProfileEntity appProfileEntity = await this.appsManager.ReadAppProfile(this.appHandle);

            if (appProfileEntity == null)
            {
                Console.WriteLine($"Cannot find app with appHandle = {this.appHandle}");
                Environment.Exit(0);
            }

            if (appProfileEntity.DeveloperId == this.appDeveloperId)
            {
                await this.appsManager.UpdateAppProfileInfo(
                    ProcessType.Frontend,
                    this.appHandle,
                    this.appName,
                    this.appIconUrl,
                    (PlatformType)this.appPlatformType,
                    this.appDeepLink,
                    this.appStoreLink,
                    DateTime.UtcNow,
                    this.disableHandleValidation,
                    appProfileEntity);

                Console.WriteLine($"Updated app profile for appHandle {this.appHandle} platform type {(PlatformType)this.appPlatformType}");
            }
            else
            {
                Console.WriteLine($"Incorrect developerId: developerId is {appProfileEntity.DeveloperId} for appHandle {this.appHandle}");
            }
        }
        /// <summary>
        /// lookup the content validation configuration for an app
        /// </summary>
        /// <param name="args">command line args</param>
        /// <returns>a task</returns>
        private async Task GetValidation(string[] args)
        {
            this.ParseLookupValidationArgs(args);

            this.ValidateGetValidation();

            IAppProfileEntity appProfileEntity = await this.appsManager.ReadAppProfile(this.appHandle);

            if (appProfileEntity == null)
            {
                Console.WriteLine("Cannot find app with appHandle = {0}", this.appHandle);
                Environment.Exit(0);
            }

            IValidationConfigurationEntity validationEntity = await this.appsManager.ReadValidationConfiguration(this.appHandle);

            if (validationEntity != null)
            {
                Console.WriteLine("Content validation config for appHandle {0}", this.appHandle);
                Console.WriteLine("  Validation Enabled = {0}", validationEntity.Enabled);
                Console.WriteLine("  AllowMatureContent = {0}", validationEntity.AllowMatureContent);
                Console.WriteLine("  ContentReportThreshold = {0}", validationEntity.ContentReportThreshold);
                Console.WriteLine("  UserReportThreshold = {0}", validationEntity.UserReportThreshold);
                Console.WriteLine("  ValidateImages = {0}", validationEntity.ValidateImages);
                Console.WriteLine("  ValidateText = {0}", validationEntity.ValidateText);
            }
            else
            {
                Console.WriteLine("Cannot find validation config for appHandle {0}", this.appHandle);
            }
        }
 /// <summary>
 /// Update app profile icon
 /// </summary>
 /// <param name="processType">Process type</param>
 /// <param name="appHandle">App handle</param>
 /// <param name="iconHandle">Icon handle</param>
 /// <param name="appProfileEntity">App profile entity</param>
 /// <returns>Update app profile icon task</returns>
 public async Task UpdateAppProfileIcon(
     ProcessType processType,
     string appHandle,
     string iconHandle,
     IAppProfileEntity appProfileEntity)
 {
     appProfileEntity.IconHandle = iconHandle;
     await this.appsStore.UpdateAppProfile(StorageConsistencyMode.Strong, appHandle, appProfileEntity);
 }
        /// <summary>
        /// Update the content validation configuration for an app
        /// </summary>
        /// <param name="args">command line args</param>
        /// <returns>a task</returns>
        private async Task UpdateValidationConfig(string[] args)
        {
            this.ParseValidationArgs(args);

            this.ValidateUpdateValidationConfig();

            // if we are disabling content validation, supply default values for all the other fields
            if (this.validationEnable == false)
            {
                this.validateText           = false;
                this.validateImages         = false;
                this.userReportThreshold    = 0;
                this.contentReportThreshold = 0;
                this.allowMatureContent     = false;
            }

            IAppProfileEntity appProfileEntity = await this.appsManager.ReadAppProfile(this.appHandle);

            if (appProfileEntity == null)
            {
                Console.WriteLine("Cannot find app with appHandle = {0}", this.appHandle);
                Environment.Exit(0);
            }

            IValidationConfigurationEntity validationEntity = await this.appsManager.ReadValidationConfiguration(this.appHandle);

            if (validationEntity != null)
            {
                if (appProfileEntity.DeveloperId == this.appDeveloperId)
                {
                    await this.appsManager.UpdateValidationConfiguration(
                        ProcessType.Frontend,
                        this.appHandle,
                        (bool)this.validationEnable,
                        (bool)this.validateText,
                        (bool)this.validateImages,
                        (int)this.userReportThreshold,
                        (int)this.contentReportThreshold,
                        (bool)this.allowMatureContent,
                        validationEntity);

                    Console.WriteLine("Updated content validation configuration for appHandle = {0}, developerId = {1}", this.appHandle, this.appDeveloperId);
                }
                else
                {
                    Console.WriteLine(
                        "Incorrect developerId: developerId is {0} for appHandle {1}",
                        appProfileEntity.DeveloperId,
                        this.appHandle);
                }
            }
            else
            {
                Console.WriteLine("Cannot find validation config for appHandle {0}", this.appHandle);
            }
        }
        /// <summary>
        /// Update app profile
        /// </summary>
        /// <param name="storageConsistencyMode">Storage consistency mode</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="appProfileEntity">App profile entity</param>
        /// <returns>Update app profile task</returns>
        public async Task UpdateAppProfile(
            StorageConsistencyMode storageConsistencyMode,
            string appHandle,
            IAppProfileEntity appProfileEntity)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Apps);

            ObjectTable table     = this.tableStoreManager.GetTable(ContainerIdentifier.Apps, TableIdentifier.AppProfilesObject) as ObjectTable;
            Operation   operation = Operation.Replace(table, appHandle, appHandle, appProfileEntity as AppProfileEntity);
            await store.ExecuteOperationAsync(operation, storageConsistencyMode.ToConsistencyMode());
        }
Esempio n. 14
0
        /// <summary>
        /// create a new user and configure them to be an app administrator for the specified app
        /// </summary>
        /// <param name="args">command line args</param>
        /// <returns>a task</returns>
        private async Task CreateUserAsAppAdmin(string[] args)
        {
            this.ParseCreateUserAsAppAdminArgs(args);

            this.ValidateCreateUserAsAppAdmin();

            IAppProfileEntity appProfileEntity = await this.appsManager.ReadAppProfile(this.appHandle);

            if (appProfileEntity == null)
            {
                Console.WriteLine("Cannot find app with appHandle = {0}", this.appHandle);
                Environment.Exit(0);
            }

            // create a user handle
            this.userHandle = this.handleGenerator.GenerateShortHandle();

            // for AADS2S, the user handle is the account id
            if (this.identityProvider == IdentityProviderType.AADS2S)
            {
                this.identityProviderAccountId = this.userHandle;
            }

            await this.usersManager.CreateUserAndUserProfile(
                ProcessType.Frontend,
                this.userHandle,
                (IdentityProviderType)this.identityProvider,
                this.identityProviderAccountId,
                this.appHandle,
                this.firstName,
                this.lastName,
                this.userBio,
                null, // we currently don't allow user photo to be set here
                DateTime.UtcNow,
                null);

            Console.WriteLine("Created user with UserHandle = {0} for appHandle = {1}", this.userHandle, this.appHandle);

            bool isAdmin = await this.appsManager.IsAdminUser(this.appHandle, this.userHandle);

            if (isAdmin)
            {
                Console.WriteLine("Cannot create a new administrator: UserHandle = {0} is already an admin in app with appHandle = {1}", this.userHandle, this.appHandle);
            }
            else
            {
                await this.appsManager.InsertAdminUser(this.appHandle, this.userHandle);

                Console.WriteLine("UserHandle = {0} is now an admin for appHandle = {1}", this.userHandle, this.appHandle);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Gets the developer Id corresponding to this app handle
        /// </summary>
        /// <param name="args">command line args</param>
        /// <returns>a task</returns>
        private async Task GetAppDeveloperId(string[] args)
        {
            this.ParseLookupAppArgs(args);

            this.ValidateGetApp();

            IAppProfileEntity appProfileEntity = await this.appsManager.ReadAppProfile(this.appHandle);

            if (appProfileEntity == null)
            {
                Console.WriteLine($"Cannot find app with appHandle = {this.appHandle}");
                Environment.Exit(0);
            }

            Console.WriteLine($"DeveloperId = {appProfileEntity.DeveloperId} for appHandle = {this.appHandle}");
        }
        /// <summary>
        /// Update the identity provider configuration for an app
        /// </summary>
        /// <param name="args">command line args</param>
        /// <returns>a task</returns>
        private async Task UpdateIdentityProvider(string[] args)
        {
            this.ParseIdentityArgs(args);

            this.ValidateUpdateIdentityProvider();

            IAppProfileEntity appProfileEntity = await this.appsManager.ReadAppProfile(this.appHandle);

            if (appProfileEntity == null)
            {
                Console.WriteLine("Cannot find app with appHandle = {0}", this.appHandle);
                Environment.Exit(0);
            }

            IIdentityProviderCredentialsEntity credentialsEntity = await this.appsManager.ReadIdentityProviderCredentials(this.appHandle, (IdentityProviderType)this.identityProvider);

            if (credentialsEntity != null)
            {
                if (appProfileEntity.DeveloperId == this.appDeveloperId)
                {
                    await this.appsManager.UpdateIdentityProviderCredentials(
                        ProcessType.Frontend,
                        this.appHandle,
                        (IdentityProviderType)this.identityProvider,
                        this.clientId,
                        this.clientSecret,
                        this.redirectUri,
                        credentialsEntity);

                    Console.WriteLine("Updated identity provider config for appHandle {0}, identity provider type {1}", this.appHandle, (IdentityProviderType)this.identityProvider);
                }
                else
                {
                    Console.WriteLine(
                        "Incorrect developerId: developerId is {0} for appHandle {1}",
                        appProfileEntity.DeveloperId,
                        this.appHandle);
                }
            }
            else
            {
                Console.WriteLine(
                    "Cannot find identity provider config for appHandle {0}, identity provider type {1}",
                    this.appHandle,
                    (IdentityProviderType)this.identityProvider);
            }
        }
        /// <summary>
        /// Update app profile info
        /// </summary>
        /// <param name="processType">Process type</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="name">App name</param>
        /// <param name="iconHandle">Icon handle</param>
        /// <param name="platformType">Platform type</param>
        /// <param name="deepLink">Deep link</param>
        /// <param name="storeLink">Store link</param>
        /// <param name="lastUpdatedTime">Last updated time</param>
        /// <param name="disableHandleValidation">whether to disable validation of app-provided handles</param>
        /// <param name="appProfileEntity">App profile entity</param>
        /// <returns>Update app profile task</returns>
        public async Task UpdateAppProfileInfo(
            ProcessType processType,
            string appHandle,
            string name,
            string iconHandle,
            PlatformType platformType,
            string deepLink,
            string storeLink,
            DateTime lastUpdatedTime,
            bool disableHandleValidation,
            IAppProfileEntity appProfileEntity)
        {
            appProfileEntity.Name                    = name;
            appProfileEntity.IconHandle              = iconHandle;
            appProfileEntity.PlatformType            = platformType;
            appProfileEntity.DeepLink                = deepLink;
            appProfileEntity.StoreLink               = storeLink;
            appProfileEntity.LastUpdatedTime         = lastUpdatedTime;
            appProfileEntity.DisableHandleValidation = disableHandleValidation;

            await this.appsStore.UpdateAppProfile(StorageConsistencyMode.Strong, appHandle, appProfileEntity);
        }
Esempio n. 18
0
        /// <summary>
        /// update the push notifications configuration for an app
        /// </summary>
        /// <param name="args">command line args</param>
        /// <returns>a task</returns>
        private async Task UpdatePushConfig(string[] args)
        {
            this.ParsePushArgs(args);

            this.ValidateUpdatePushConfig();

            IAppProfileEntity appProfileEntity = await this.appsManager.ReadAppProfile(this.appHandle);

            if (appProfileEntity == null)
            {
                Console.WriteLine("Cannot find app with appHandle = {0}", this.appHandle);
                Environment.Exit(0);
            }

            IPushNotificationsConfigurationEntity entity = await this.appsManager.ReadPushNotificationsConfiguration(this.appHandle, (PlatformType)this.appPlatformType);

            if (entity != null)
            {
                string path = null;
                string key  = null;

                // Validate routine above ensures that appPlatformType is set to one of the three platforms listed below
                if (this.appPlatformType == PlatformType.Windows)
                {
                    path = this.windowsPackageSid;
                    key  = this.windowsSecretKey;
                }
                else if (this.appPlatformType == PlatformType.Android)
                {
                    key = this.googleApiKey;
                }
                else if (this.appPlatformType == PlatformType.IOS)
                {
                    path = this.appleCertPath;
                    key  = this.appleCertKey;
                }

                if (appProfileEntity.DeveloperId == this.appDeveloperId)
                {
                    await this.appsManager.UpdatePushNotificationsConfiguration(
                        ProcessType.Frontend,
                        this.appHandle,
                        (PlatformType)this.appPlatformType,
                        (bool)this.pushNotificationsEnable,
                        path,
                        key,
                        entity);

                    Console.WriteLine("Updated push notifications configuration for appHandle {0} on platform {1}", this.appHandle, this.appPlatformType);
                }
                else
                {
                    Console.WriteLine(
                        "Incorrect developerId: developerId is {0} for appHandle {1} on platform type {2}",
                        appProfileEntity.DeveloperId,
                        this.appHandle,
                        (PlatformType)this.appPlatformType);
                }
            }
            else
            {
                Console.WriteLine("Cannot find push config for appHandle {0} on platform {1}", this.appHandle, (PlatformType)this.appPlatformType);
            }
        }