public static bool CheckAuthorization(PeerCastStation.HTTP.HTTPRequest request, PeerCastStation.Core.AuthenticationKey key) { if (key==null) return true; if (!request.Headers.ContainsKey("AUTHORIZATION")) { return false; } else { var authorized = false; var md = System.Text.RegularExpressions.Regex.Match( request.Headers["AUTHORIZATION"], @"\s*BASIC (\S+)", System.Text.RegularExpressions.RegexOptions.IgnoreCase); if (md.Success) { try { var authorization = System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(md.Groups[1].Value)).Split(':'); if (authorization.Length>=2) { var user = authorization[0]; var pass = String.Join(":", authorization.Skip(1).ToArray()); if (key.Id==user && key.Password==pass) { authorized = true; } } } catch (FormatException) { } catch (ArgumentException) { } } return authorized; } }
public VersionInfoDialog(PeerCastStation.Core.PeerCastApplication app) { InitializeComponent(); foreach (var asm in app.Plugins.Select(type => type.Assembly).Distinct()) { var info = FileVersionInfo.GetVersionInfo(asm.Location); versionsList.Items.Add( new ListViewItem( new string[] { Path.GetFileName(info.FileName), info.FileVersion, asm.FullName, info.LegalCopyright})); } }
public UISettingsViewModel(PeerCastStation.Core.PecaSettings settings) { this.settings = settings; var wpf = settings.Get<WPFSettings>(); var ui = settings.Get<PeerCastStation.UI.UISettings>(); if (ui.BroadcastHistory.Length>0) { BroadcastHistory = new ObservableCollection<BroadcastInfoViewModel>( ui.BroadcastHistory.Select(info => new BroadcastInfoViewModel(info))); } else { BroadcastHistory = new ObservableCollection<BroadcastInfoViewModel>( wpf.BroadcastHistory.Select(info => new BroadcastInfoViewModel(info))); } }
private static string GetAuthorizationToken(PeerCastStation.HTTP.HTTPRequest request) { String result = null; if (request.Headers.ContainsKey("AUTHORIZATION")) { var md = System.Text.RegularExpressions.Regex.Match( request.Headers["AUTHORIZATION"], @"\s*BASIC (\S+)", System.Text.RegularExpressions.RegexOptions.IgnoreCase); if (md.Success) { result = md.Groups[1].Value; } } if (result==null) { request.Parameters.TryGetValue("auth", out result); } if (result==null) { request.Cookies.TryGetValue("auth", out result); } return result; }
public static bool CheckAuthorization(string authorization_token, PeerCastStation.Core.AccessControlInfo acinfo) { if (!acinfo.AuthorizationRequired || acinfo.AuthenticationKey==null) return true; if (authorization_token==null) return false; var authorized = false; try { var authorization = System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(authorization_token)).Split(':'); if (authorization.Length>=2) { var user = authorization[0]; var pass = String.Join(":", authorization.Skip(1).ToArray()); authorized = acinfo.CheckAuthorization(user, pass); } } catch (FormatException) { } catch (ArgumentException) { } return authorized; }
public VersionInfoDialog(PeerCastStation.Core.PeerCastApplication app) { InitializeComponent(); foreach (var plugin in app.Plugins) { var info = plugin.GetVersionInfo(); versionsList.Items.Add( new ListViewItem( new string[] { plugin.Name, plugin.IsUsable.ToString(), info.FileName, info.Version, info.AssemblyName, info.Copyright, } ) ); } }
public BroadcastInfoViewModel(PeerCastStation.UI.BroadcastInfo model) { streamType = model.StreamType; streamUrl = model.StreamUrl; bitrate = model.Bitrate; contentType = model.ContentType; yellowPage = model.YellowPage; channelName = model.ChannelName; genre = model.Genre; description = model.Description; comment = model.Comment; contactUrl = model.ContactUrl; trackTitle = model.TrackTitle; trackAlbum = model.TrackAlbum; trackArtist = model.TrackArtist; trackGenre = model.TrackGenre; trackUrl = model.TrackUrl; favorite = model.Favorite; }
internal void Import(PeerCastStation.Properties.Settings settings) { if (settings==null) return; try { if (settings.BroadcastID!=Guid.Empty) { this.BroadcastID = settings.BroadcastID; } settings.BroadcastID = Guid.NewGuid(); if (settings.AccessController!=null) { this.AccessController = new AccessControllerSettings(settings.AccessController); } if (settings.Listeners!=null) { this.Listeners = settings.Listeners.Where(s => s!=null).Select(s => new ListenerSettings(s)).ToArray(); } if (settings.YellowPages!=null) { this.YellowPages = settings.YellowPages.Where(s => s!=null).Select(s => new YellowPageSettings(s)).ToArray(); } } catch (System.Configuration.ConfigurationErrorsException) { } }
public static bool CheckAuthorization(PeerCastStation.HTTP.HTTPRequest request, PeerCastStation.Core.AuthenticationKey key) { if (key==null) return true; var token = GetAuthorizationToken(request); if (token==null) return false; var authorized = false; try { var authorization = System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(token)).Split(':'); if (authorization.Length>=2) { var user = authorization[0]; var pass = String.Join(":", authorization.Skip(1).ToArray()); if (key.Id==user && key.Password==pass) { authorized = true; } } } catch (FormatException) { } catch (ArgumentException) { } return authorized; }
public static string CreateAuthorizationToken(PeerCastStation.Core.AuthenticationKey key) { return Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(key.Id + ":" + key.Password)); }
private void ChannelRemoved(object sender, PeerCastStation.Core.ChannelChangedEventArgs e) { this.BeginInvoke(new Action(() => { UpdateChannelList(); })); }
public static bool CheckAuthorization(PeerCastStation.HTTP.HTTPRequest request, PeerCastStation.Core.AccessControlInfo acinfo) { return CheckAuthorization(GetAuthorizationToken(request), acinfo); }
internal AccessControllerSettings(PeerCastStation.Properties.AccessControllerSettings settings) { this.MaxRelays = settings.MaxRelays; this.MaxDirects = settings.MaxDirects; this.MaxRelaysPerChannel = settings.MaxRelaysPerChannel; this.MaxDirectsPerChannel = settings.MaxDirectsPerChannel; this.MaxUpstreamRate = settings.MaxUpstreamRate; }
internal ListenerSettings(PeerCastStation.Properties.ListenerSettings settings) { this.EndPoint = settings.EndPoint; this.LocalAccepts = settings.LocalAccepts; this.GlobalAccepts = settings.GlobalAccepts; }
public RelayTreeNodeViewModel(PeerCastStation.Core.Utils.HostTreeNode node) { this.Node = node; this.Children = node.Children.Select(c => new RelayTreeNodeViewModel(c)).ToArray(); }
internal void Update(PeerCastStation.Core.Channel channel) { if (channel!=null) { this.RelayTree = channel.CreateHostTree() .Where(node => node.Host.SessionID==peerCast.SessionID) .Select(node => new RelayTreeNodeViewModel(node)).ToArray(); } else { this.RelayTree = new RelayTreeNodeViewModel[0]; } OnPropertyChanged("RelayTree"); if (this.channel!=channel) { this.channel = channel; this.refresh.OnCanExecuteChanged(); } }
internal YellowPageSettings(PeerCastStation.Properties.YellowPageSettings settings) { this.Protocol = settings.Protocol; this.Name = settings.Name; this.Uri = settings.Uri; }