Beispiel #1
0
 public AdapterPresentation(AuthView currentState, AdfsConfig adfsConfig, string param)
 {
     viewId          = currentState;
     this.adfsConfig = adfsConfig;
     this.param      = param;
     rspDto          = null;
 }
Beispiel #2
0
 public AdapterPresentation(AuthView currentState, AdfsConfig adfsConfig)
 {
     viewId          = currentState;
     this.adfsConfig = adfsConfig;
     param           = null;
     rspDto          = null;
 }
Beispiel #3
0
        //public AdapterPresentation(AuthView currentState, AdfsConfig adfsConfig, ServiceStatus svcStatus, string svcDetail)
        //{
        //    viewId = currentState;
        //    this.adfsConfig = adfsConfig;
        //    rspStatus = svcStatus;
        //    param = svcDetail;
        //    rspDto = null;
        //}

        public AdapterPresentation(AuthView currentState, AdfsConfig adfsConfig, AuthResponseDto rspDto)
        {
            viewId          = currentState;
            this.adfsConfig = adfsConfig;
//            rspStatus = rspDto.Status;
            this.rspDto = rspDto;
            param       = (string)rspDto.Detail;
        }
Beispiel #4
0
        // Called when the authentication provider is loaded by AD FS into it's pipeline.
        // This is where AD FS passes us the config data as a Stream, if such data was supplied at registration of the adapter
        public void OnAuthenticationPipelineLoad(IAuthenticationMethodConfigData configData)
        {
            int id = System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(this);

            logger.TraceEvent(TraceEventType.Verbose, 0, "OnAuthenticationPipelineLoad(verAdapter={0}, obj={1})",
                              AuthenticationAdapterMetadata.VERSION, id);
            Logging.Log.LoadAuthProviderStart(id, AuthenticationAdapterMetadata.VERSION);

            if (configData.Data != null)
            {
                try
                {
                    string cfgStr = (new System.IO.StreamReader(configData.Data)).ReadToEnd();
                    // logger.TraceEvent(TraceEventType.Verbose, 0, "Cfg:\n========\n" + cfgStr + "\n========\n");
                    configData.Data.Position = 0;
                    cfgMid = WebClientConfig.CreateConfig(cfgStr);
                    logger.TraceEvent(TraceEventType.Verbose, 0, "Config.Mid: " + cfgMid);
                    MobileId.Logging.Log.ConfigInfo(getWebClient().GetClientVersion(), cfgMid.ToString());
                    configData.Data.Position = 0;
                    cfgAdfs = AdfsConfig.CreateConfig(cfgStr);
                    logger.TraceEvent(TraceEventType.Verbose, 0, "Config.Adfs: " + cfgAdfs);
                    Logging.Log.ConfigInfo(AuthenticationAdapterMetadata.VERSION, cfgAdfs.ToString());
                }
                catch (Exception ex)
                {
                    logger.TraceData(TraceEventType.Error, 0, ex);
                    Logging.Log.ConfigError(ex.Message);
                    throw ex;
                }
            }
            else
            {
                Logging.Log.ConfigError("config is null");
                throw new ArgumentNullException("configData is null");
            }

            // Verify EventLog Source
            //if (!EventLog.SourceExists(EVENTLOGSource))
            //    EventLog.CreateEventSource(EVENTLOGSource, EVENTLOGGroup);
            //EventLog.WriteEntry(EVENTLOGSource, "Adapter loaded", EventLogEntryType.Information, 900);

            // The EventSources are created by the installer normally. If Mobile ID for ADFS was installed manually and
            // EventSource were not created, we will repair it here. It requires administrative privileges though.
            if (!EventLog.SourceExists("MobileId.Client"))
            {
                EventLog.CreateEventSource("MobileId.Client", "Application");
            }

            if (!EventLog.SourceExists("MobileId.Adfs"))
            {
                EventLog.CreateEventSource("MobileId.Adfs", "Application");
            }
        }
Beispiel #5
0
        public static AdfsConfig CreateConfig(TextReader cfgStream)
        {
            if (cfgStream == null)
            {
                throw new ArgumentNullException("input stream is null");
            }

            AdfsConfig        cfg        = new AdfsConfig();
            XmlReaderSettings xmlSetting = new XmlReaderSettings();

            xmlSetting.CloseInput = true;
            xmlSetting.IgnoreProcessingInstructions = true;
            xmlSetting.IgnoreWhitespace             = true;
            using (XmlReader xml = XmlReader.Create(cfgStream, xmlSetting))
            {
                String s;
                while (xml.Read())
                {
                    // we process only attributes of the <mobileIdAdfs .../> element and ignore everything else
                    if (xml.Name == "mobileIdAdfs")
                    {
                        if (!String.IsNullOrWhiteSpace(s = xml["AdAttrMobile"]))
                        {
                            cfg.AdAttrMobile = s;
                        }
                        if (!String.IsNullOrWhiteSpace(s = xml["WebClientMaxRequest"]))
                        {
                            cfg.WebClientMaxRequest = ulong.Parse(s);
                        }
                        if (!String.IsNullOrWhiteSpace(s = xml["AdAttrMidSerialNumber"]))
                        {
                            cfg.AdAttrMidSerialNumber = s;
                        }
                        // cfg.DefaultLoginPrompt = xml["DefaultLoginPrompt"]; // TODO: deprecated
                        if (!String.IsNullOrWhiteSpace(s = xml["SsoOnCancel"]))
                        {
                            cfg.SsoOnCancel = bool.Parse(s);
                        }
                        if (!String.IsNullOrWhiteSpace(s = xml["SessionTimeoutSeconds"]))
                        {
                            cfg.SessionTimeoutSeconds = int.Parse(s);
                        }
                        if (!String.IsNullOrWhiteSpace(s = xml["SessionMaxTries"]))
                        {
                            cfg.SessionMaxTries = int.Parse(s);
                        }
                        if (!String.IsNullOrWhiteSpace(s = xml["ShowDebugMsg"]))
                        {
                            cfg.ShowDebugMsg = bool.Parse(s);
                        }
                        if (!String.IsNullOrWhiteSpace(s = xml["ExpShowWSignout"]))
                        {
                            cfg.ExpShowWSignOut = bool.Parse(s);
                        }
                        if (!String.IsNullOrWhiteSpace(s = xml["LoginNonceLength"]))
                        {
                            cfg.LoginNonceLength = int.Parse(s);
                        }
                        foreach (UserLanguage lang in new UserLanguage[] { UserLanguage.en,
                                                                           UserLanguage.de, UserLanguage.fr, UserLanguage.it })
                        {
                            cfg.SetLoginPrompt(lang, xml["LoginPrompt." + lang]);
                        }
                        ;
                        // TODO: update on change
                        break;
                    }
                }
                xml.Close();
            }
            return(cfg);
        }