Skip to content

Commit

Permalink
chore: wip wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Xlin123 committed Sep 26, 2024
1 parent e1bb9ef commit 587ee43
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 29 deletions.
23 changes: 9 additions & 14 deletions tools/windows-installer/NoPortsInstaller/AccessRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace NoPortsInstaller
{
public class AccessEntry : IAccessEntry
{
public String atSign { get; set; }
public string atSign { get; set; }
public AccessType type { get; set; }

AccessEntry()
Expand All @@ -14,16 +14,16 @@ public class AccessEntry : IAccessEntry

public class AccessRules : IAccessRules
{
public List<AccessEntry> Entries { get; set; }
public List<IAccessEntry> Entries { get; set; }

public List<AccessEntry> Managers
public List<IAccessEntry> Managers
{
get { return Entries.FindAll(IsManager); }
get { return Entries.FindAll(entry => IsManager((AccessEntry)entry)); }
}

public AccessRules Policy
public IAccessEntry? Policy
{
get { return Entries.Find(IsPolicy); }
get { return Entries.Find(entry => IsPolicy((AccessEntry)entry)); }
}

public bool IsValid
Expand All @@ -33,10 +33,10 @@ public bool IsValid

AccessRules()
{
Entries = List<AccessEntry>();
Entries = new();
}

public void SetEntryType(String atSign, AccessType type)
public void SetEntryType(string atSign, AccessType type)
{
// Unset the current policy atSign if it exists (there can only be one)
if (type == AccessType.Policy && Policy != null)
Expand All @@ -45,19 +45,14 @@ public void SetEntryType(String atSign, AccessType type)
Policy.type = AccessType.Manager;
}
InstallLogger.Log($"Setting policy atSign: {atSign}");
Entries.Find(IsAtsign).type = type;
Entries.Find(entry => entry.atSign == atSign).type = type;
}

private static bool IsManager(AccessEntry entry)
{
return entry.type == AccessType.Manager;
}

private static bool IsAtsign(String atSign)
{
return entry.atSign == atSign;
}

private static bool IsPolicy(AccessEntry entry)
{
return entry.type == AccessType.Policy;
Expand Down
14 changes: 7 additions & 7 deletions tools/windows-installer/NoPortsInstaller/IAccessRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ public enum AccessType
Policy,
}

public class IAccessEntry
public interface IAccessEntry
{
String atSign { get; set; }
string atSign { get; set; }
AccessType type { get; set; }
}

public class IAccessRules
public interface IAccessRules
{
List<IAccessEntry> entries { get; set; }
List<IAccessEntry> managers { get; }
IAccessEntry policy { get; }
List<IAccessEntry> Entries { get; set; }
List<IAccessEntry> Managers { get; }
IAccessEntry? Policy { get; }

bool IsValid { get; }

void SetEntryType(String atSign, AccessType type);
void SetEntryType(string atSign, AccessType type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private void RefreshButton_Click(object sender, RoutedEventArgs e)

private void FillEnrollmentRequest()
{
id = _controller.GetPendingRequests();
id = "_controller.GetPendingRequests()";
if (!string.IsNullOrEmpty(id))
{
DeviceNameLabel.Content = _controller.DeviceName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</Image.OpacityMask>
</Image>
<Label Content="NoPorts Installation" HorizontalAlignment="Left" Height="28" VerticalAlignment="Top" Width="194" Margin="168,10,0,0" FontSize="16" FontWeight="Bold"/>
<Label x:Name="Header" Content="Generate atKeys" HorizontalAlignment="Left" Height="27" VerticalAlignment="Top" Width="199" Margin="168,45,0,0"/>
<Label x:Name="Header" Content="Enroll Instructions" HorizontalAlignment="Left" Height="27" VerticalAlignment="Top" Width="199" Margin="168,45,0,0"/>
<Button x:Name="BackPageButton" Content="&lt; Back" HorizontalAlignment="Left" Height="24" Margin="168,295,0,0" VerticalAlignment="Top" Width="52" Click="BackPageButton_Click"/>
<Rectangle HorizontalAlignment="Left" Height="2" Margin="168,71,0,0" Stroke="Black" VerticalAlignment="Top" Width="220" Fill="Black" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
Expand All @@ -45,12 +45,12 @@

</Rectangle>
<Button x:Name="Generate" Content="Generate" HorizontalAlignment="Left" Height="24" Margin="415,295,0,0" VerticalAlignment="Top" Width="57" IsEnabled="False" Click="Generate_Click"/>
<Grid x:Name="ActivateResponse" Margin="168,71,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Height="94" Width="322">
<Grid x:Name="ActivateResponse" Margin="178,138,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Height="94" Width="322">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="61*"/>
<ColumnDefinition Width="261*"/>
</Grid.ColumnDefinitions>
<Label x:Name="ActivateResponseText" Content="One TIme Password (at-activate \ from installer)" HorizontalAlignment="Left" Height="30" VerticalAlignment="Top" Width="267" FontSize="11" Margin="0,10,0,0" Grid.ColumnSpan="2"/>
<Label x:Name="ActivateResponseText" Content="Step 2: One TIme Password (at-activate \ from installer)" HorizontalAlignment="Left" Height="30" VerticalAlignment="Top" Width="312" Margin="0,10,0,0" Grid.ColumnSpan="2"/>
<Grid x:Name="OtpInput" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="-22,25,0,0" Width="289" Grid.ColumnSpan="2" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="131*"/>
Expand Down Expand Up @@ -83,5 +83,9 @@
</Canvas>
<Label x:Name="EnrollResponse" Content="" HorizontalAlignment="Left" Height="30" VerticalAlignment="Top" Width="322" FontSize="11" Margin="0,54,0,0" Grid.ColumnSpan="2"/>
</Grid>
<Label Content="Step 1: Generate OTP's" HorizontalAlignment="Left" Height="28" VerticalAlignment="Top" Width="200" Margin="178,86,0,0"/>
<Label Content="Step 3: Approve Enrollment" HorizontalAlignment="Left" Height="28" VerticalAlignment="Top" Width="200" Margin="178,227,0,0"/>
<Label Content="via Generate On Another Device or CLI" HorizontalAlignment="Left" Height="28" VerticalAlignment="Top" Width="226" Margin="194,110,0,0"/>
<Label Content="via Generate On Another Device or CLI" HorizontalAlignment="Left" Height="28" VerticalAlignment="Top" Width="226" Margin="194,251,0,0"/>
</Grid>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ private void OtpBox_TextChanged(object sender, TextChangedEventArgs e)

}

private void BackPageButton_Click(object sender, System.Windows.RoutedEventArgs e)
private void BackPageButton_Click(object sender, RoutedEventArgs e)
{
_controller.PreviousPage();
}

private async void Generate_Click(object sender, System.Windows.RoutedEventArgs e)
private async void Generate_Click(object sender, RoutedEventArgs e)
{
string otp = $"{OtpBox1.Text}{OtpBox2.Text}{OtpBox3.Text}{OtpBox4.Text}{OtpBox5.Text}{OtpBox6.Text}".ToUpper();
at_activate.StartInfo.Arguments = $@"enroll -a ""{_controller.DeviceAtsign}"" -s {otp} -d {_controller.DeviceName} -p noports -n ""sshnp:rw,sshrvd:rw"" -k {Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), @".atsign\keys", _controller.DeviceAtsign + "_key.atKeys")}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<Label Content="NoPorts Installation" HorizontalAlignment="Left" Height="28" VerticalAlignment="Top" Width="194" Margin="168,10,0,0" FontSize="16" FontWeight="Bold"/>
<Label Content="Additional Configuration" HorizontalAlignment="Left" Height="27" VerticalAlignment="Top" Width="199" Margin="168,45,0,0"/>
<Button x:Name="BackPageButton" Content="&lt; Back" HorizontalAlignment="Left" Height="24" Margin="360,297,0,0" VerticalAlignment="Top" Width="52" Click="BackPageButton_Click"/>
<Button x:Name="NextPageButton" Content="Install" HorizontalAlignment="Left" Height="24" Margin="427,297,0,0" VerticalAlignment="Top" Width="52" RenderTransformOrigin="0.536,-0.009" Click="NextPageButton_Click"/>
<Button x:Name="NextPageButton" Content="Next" HorizontalAlignment="Left" Height="24" Margin="427,297,0,0" VerticalAlignment="Top" Width="52" RenderTransformOrigin="0.536,-0.009" Click="NextPageButton_Click"/>
<Rectangle HorizontalAlignment="Left" Height="2" Margin="168,71,0,0" Stroke="Black" VerticalAlignment="Top" Width="220" Fill="Black" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<TransformGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ private void BackPageButton_Click(object sender, System.Windows.RoutedEventArgs
private void NextPageButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
_controller.AdditionalArgs = _controller.NormalizeArgs(AdditionalArgs.Text);
_controller.Pages.Add(new Download());
_controller.NextPage();
}
}
Expand Down

0 comments on commit 587ee43

Please sign in to comment.