Exemple #1
0
        /// <summary>
        /// Constructor for Action class. Pass in AppInfo to simplify passing settings to AuthDelegate.
        /// </summary>
        /// <param name="appInfo"></param>
        public Action(ApplicationInfo appInfo)
        {
            this.appInfo = appInfo;

            // Initialize AuthDelegateImplementation using AppInfo.
            authDelegate = new AuthDelegateImplementation(this.appInfo);

            // Initialize SDK DLLs. If DLLs are missing or wrong type, this will throw an exception
            try
            {
                MIP.Initialize(MipComponent.File);

                // This method in AuthDelegateImplementation triggers auth against Graph so that we can get the user ID.
                var id = authDelegate.GetUserIdentity();

                // Create profile.
                profile = CreateFileProfile(appInfo, ref authDelegate);

                // Create engine providing Identity from authDelegate to assist with service discovery.
                engine = CreateFileEngine(id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        /// <summary>
        /// Constructor for Action class. Pass in AppInfo to simplify passing settings to AuthDelegate.
        /// </summary>
        /// <param name="appInfo"></param>
        public Action(ApplicationInfo appInfo)
        {
            this.appInfo = appInfo;

            // Initialize AuthDelegateImplementation using AppInfo.
            authDelegate = new AuthDelegateImplementation(this.appInfo);

            // Initialize SDK DLLs. If DLLs are missing or wrong type, this will throw an exception

            MIP.Initialize(MipComponent.File);

            // We must construct a service principal identity mail address as it can't be fetched from the token.
            // Here, we set it to be [email protected], but the SDK will accept any properly formatted email address.
            Identity id = new Identity(String.Format("{0}@{1}", appInfo.ApplicationId, tenant))
            {
                // DelegatedEmail = "*****@*****.**"
                // Use this if you want the app to protect on behalf of a user.
                // That user owns the protected content.
            };

            // Create profile.
            profile = CreateFileProfile(appInfo, ref authDelegate);

            // Create engine providing Identity from authDelegate to assist with service discovery.
            engine = CreateFileEngine(id);
        }
        /// <summary>
        /// Constructor for Action class. Pass in AppInfo to simplify passing settings to AuthDelegate.
        /// </summary>
        /// <param name="appInfo"></param>
        public Action(ApplicationInfo appInfo)
        {
            this.appInfo = appInfo;

            // Initialize AuthDelegateImplementation using AppInfo.
            authDelegate = new AuthDelegateImplementation(this.appInfo);

            // Initialize SDK DLLs. If DLLs are missing or wrong type, this will throw an exception

            MIP.Initialize(MipComponent.File);

            // This method in AuthDelegateImplementation triggers auth against Graph so that we can get the user ID.
            //var id = authDelegate.GetUserIdentity();

            // Prompt one time for a user identity.
            // This identity is used for service discovery. If MDE SRV record isn't registered properly, we will default to AIP service.
            Console.WriteLine("The Identity object provides hints on service discovery.");
            Console.WriteLine("If MDE is properly configured, the mail suffix of the user will be used for discovery.");
            Console.WriteLine("It will find the MDE record and use the on-prem AD RMS and ADFS for auth.");
            Console.Write("Enter a user name, either email or UPN: ");
            identity = new Identity(Console.ReadLine());

            // Create profile.
            profile = CreateFileProfile(appInfo, ref authDelegate);

            // Create engine providing Identity from authDelegate to assist with service discovery.
            engine = CreateFileEngine(identity);
        }
Exemple #4
0
        public EventType(IFileEngine fileEngine, IMissionEngine missionEngine, ISeriesEngine seriesEngine)
        {
            Name        = "Event";
            Description = "Major events that occurred during the mission";

            Field(e => e.Id);
            Field(e => e.Text);
            Field(e => e.Timestamp);
            Field <FileType>("file", "Image associated with the series.", resolve: c => fileEngine.GetById(c.Source.FileId));
            Field <MissionType>("mission", "Mission the event occurred on.", resolve: c => missionEngine.GetMission(c.Source.MissionId));
            Field <SeriesType>("series", "Series of missions associated with the event.", resolve: c => seriesEngine.GetSeries(c.Source.SeriesId));
        }
        /// <summary>
        /// Initializes a new IFileEngine using the provided username, custom client data string, and locale.
        /// Stores result in _fileEngine.
        /// </summary>
        /// <param name="username"></param>
        /// <param name="clientData"></param>
        /// <param name="locale"></param>
        private void CreateFileEngine(string username, string clientData, string locale)
        {
            try
            {
                var engineSettings = new FileEngineSettings(username, clientData, locale);
                engineSettings.ProtectionCloudEndpointBaseUrl = "https://api.aadrm.com";
                _fileEngine = Task.Run(async() => await _fileProfile.AddEngineAsync(engineSettings)).Result;
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #6
0
        public SeriesType(IMissionEngine missionEngine, IFileEngine fileEngine)
        {
            Name        = "Series";
            Description = "A set of missions that contributed to a larger objective";

            // Auto-mapped properties
            Field(s => s.Id);
            Field(s => s.SeriesName).Description("The name of the series.");

            // Custom-mapped properties
            Field <FileType>("file", "Image associated with the series.", resolve: c => fileEngine.GetById(c.Source.FileId));
            Field <ListGraphType <MissionType> >("missions", "Which missions are part of this series.", resolve: c => missionEngine.GetMissionsBySeriesId(c.Source.Id));
            Field <LongGraphType>("missionCount", "Number of missions that are part of this series.", resolve: c => missionEngine.GetMissionCountBySeriesId(c.Source.Id));
        }
Exemple #7
0
        public MissionType(ISeriesEngine seriesEngine, IFileEngine fileEngine, ILogEngine logEngine)
        {
            Name        = "Mission";
            Description = "A set of missions that contributed to a larger objective";

            // Auto-mapped properties
            Field(s => s.Id);
            Field(s => s.MissionName).Description("The name of the mission.");

            // Custom-mapped properties
            Field <ListGraphType <SpeakerType> >("speakers", "Speakers whose voice was recorded in logs during this mission.", resolve: c => c.Source.Speakers);
            Field <FileType>("file", "Image associated with the mission.", resolve: c => fileEngine.GetById(c.Source.FileId));
            Field <SeriesType>("series", "The series this mission was a part of.", resolve: c => seriesEngine.GetSeries(c.Source.SeriesId));
            Field <ListGraphType <LogType> >("log", "Logs that were captured as part of this mission.", resolve: c => logEngine.GetLogsByMissionId(c.Source.Id));
            Field <LongGraphType>("logCount", "Number of logs that were captured as part of this mission.", resolve: c => logEngine.GetLogCountByMissionId(c.Source.Id));
        }
        /// <summary>
        /// Initializes a new IFileEngine using the provided username, custom client data string, and locale.
        /// Stores result in _fileEngine.
        /// </summary>
        /// <param name="username"></param>
        /// <param name="clientData"></param>
        /// <param name="locale"></param>
        private void CreateFileEngine(string username, string clientData, string locale)
        {
            try
            {
                Identity id             = new Identity(username);
                var      engineSettings = new FileEngineSettings(username, _authDelegate, clientData, locale)
                {
                    Identity = id
                };

                fileEngine = Task.Run(async() => await fileProfile.AddEngineAsync(engineSettings)).Result;
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #9
0
 public FileController(IFileEngine fileEngine)
 {
     _fileEngine = fileEngine;
 }
 public FileManager(IFileEngine fileEngine)
 {
     this._fileEngine = fileEngine;
 }