Skip to content

Commit

Permalink
Merge pull request #2 from sipgate/2022-fixes
Browse files Browse the repository at this point in the history
2022 fixes
  • Loading branch information
LemonaOna authored Jan 28, 2022
2 parents dc66511 + 09468f6 commit c8eaf67
Show file tree
Hide file tree
Showing 37 changed files with 494 additions and 295 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ mono_crash.*
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
Expand Down
6 changes: 3 additions & 3 deletions Lib/SCPDFPRN.ppd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*% PCFileName should be of the form XXNNNNNN.PPD where XX is an assigned
*% manufacturer code.
*PCFileName: "SCPDFPRN.PPD"
*Product: "(PDF Scribe)"
*Product: "(sipgate Faxdrucker)"
*PSVersion: "(3010) 815"

*% *DefaultImageableArea:
Expand All @@ -24,7 +24,7 @@

*% == Above are required

*% This file was adapted from GHOSTPDF.PPD for PDF Scribe
*% This file was adapted from GHOSTPDF.PPD for sipgate Faxdrucker

*Copyright: "2004-2006 Ghostgum Software Pty Ltd"
*%
Expand Down Expand Up @@ -55,7 +55,7 @@

*% == Basic Capabilities
*LanguageLevel: "3"
*ColorDevice: True
*ColorDevice: False
*DefaultColorSpace: RGB
*FileSystem: True
*Extensions: CMYK FileSystem Composite
Expand Down
Binary file removed Lib/redmon64pdfscribe.dll
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file renamed Lib/gsdll32.dll → Lib/x64/gsdll64.dll
Binary file not shown.
Binary file added Lib/x64/redmon64pdfscribe.dll
Binary file not shown.
Binary file added Lib/x86/PS5UI.DLL
Binary file not shown.
Binary file added Lib/x86/PSCRIPT.HLP
Binary file not shown.
Binary file added Lib/x86/PSCRIPT.NTF
Binary file not shown.
Binary file added Lib/x86/PSCRIPT5.DLL
Binary file not shown.
Binary file renamed Lib/gsdll64.dll → Lib/x86/gsdll32.dll
Binary file not shown.
File renamed without changes.
9 changes: 4 additions & 5 deletions SipgateFaxdrucker.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30907.101
# Visual Studio Version 17
VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SipgateFaxdruckerCore", "SipgateFaxdruckerCore\SipgateFaxdruckerCore.csproj", "{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}"
EndProject
Expand Down Expand Up @@ -79,8 +79,8 @@ Global
{3C255536-A7F1-4913-9C7F-966DFFEE01BC}.Debug|x64.ActiveCfg = Debug|x64
{3C255536-A7F1-4913-9C7F-966DFFEE01BC}.Debug|x86.ActiveCfg = Debug|x86
{3C255536-A7F1-4913-9C7F-966DFFEE01BC}.Debug|x86.Build.0 = Debug|x86
{3C255536-A7F1-4913-9C7F-966DFFEE01BC}.Release|Any CPU.ActiveCfg = Release|x64
{3C255536-A7F1-4913-9C7F-966DFFEE01BC}.Release|Any CPU.Build.0 = Release|x64
{3C255536-A7F1-4913-9C7F-966DFFEE01BC}.Release|Any CPU.ActiveCfg = Release|x86
{3C255536-A7F1-4913-9C7F-966DFFEE01BC}.Release|Any CPU.Build.0 = Release|x86
{3C255536-A7F1-4913-9C7F-966DFFEE01BC}.Release|ia64.ActiveCfg = Release|x64
{3C255536-A7F1-4913-9C7F-966DFFEE01BC}.Release|ia64.Build.0 = Release|x64
{3C255536-A7F1-4913-9C7F-966DFFEE01BC}.Release|x64.ActiveCfg = Release|x64
Expand All @@ -100,7 +100,6 @@ Global
{8562A5BC-A70E-40DD-A7E7-5611D332A983}.Release|ia64.Build.0 = Release|Any CPU
{8562A5BC-A70E-40DD-A7E7-5611D332A983}.Release|x64.ActiveCfg = Release|Any CPU
{8562A5BC-A70E-40DD-A7E7-5611D332A983}.Release|x86.ActiveCfg = Release|Any CPU
{8562A5BC-A70E-40DD-A7E7-5611D332A983}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
33 changes: 18 additions & 15 deletions SipgateFaxdrucker/App.config
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="SipgateFaxdrucker.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="SipgateFaxdrucker.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="SipgateFaxdrucker.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="SipgateFaxdrucker.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
</startup>

<system.diagnostics>
<sources>
<source name="sipgateFaxdrucker" switchName="sourceSwitch" switchType="System.Diagnostics.SourceSwitch" />
<source name="sipgateFaxdrucker" switchName="sourceSwitch" switchType="System.Diagnostics.SourceSwitch"/>
</sources>
<switches>
<add name="sourceSwitch" value="Warning" />
<add name="sourceSwitch" value="Warning"/>
</switches>
</system.diagnostics>
<applicationSettings>
Expand All @@ -39,20 +39,20 @@
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.3" newVersion="4.1.1.3" />
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.1.3" newVersion="4.1.1.3"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.9.0.0" newVersion="6.9.0.0" />
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.9.0.0" newVersion="6.9.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand All @@ -70,6 +70,9 @@
<setting name="MixpanelTokenDebug" serializeAs="String">
<value>5e2eedfb2db9a53766edab1380f6017e</value>
</setting>
<setting name="UpdateCheckUrl32" serializeAs="String">
<value>https://sipgate-faxdrucker.s3.eu-central-1.amazonaws.com/version32.xml</value>
</setting>
</SipgateFaxdrucker.Properties.Settings>
</userSettings>
</configuration>
</configuration>
46 changes: 36 additions & 10 deletions SipgateFaxdrucker/Authentication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ public class Authentication
private readonly string _clientId = Settings.Default.ClientId;
#if DEBUG
private static string _keycloakBaseUrl = "https://login.dev.sipgate.com";
private static string _appWebBaseUrl = "https://app.dev.sipgate.com";
#else
private static string _keycloakBaseUrl = Settings.Default.LoginBaseUrl;
private static string _appWebBaseUrl = "https://app.sipgate.com";
#endif

private readonly string _tokenUrl = _keycloakBaseUrl +
Expand All @@ -33,10 +35,10 @@ public class Authentication
@"/auth/realms/sipgate-apps/protocol/openid-connect/logout";

private const string GrantType = "authorization_code";
private readonly string _state = RandomDataBase64Url(32);
private const string ResponseType = "code";
public readonly string redirectUri;
private const string Scope = "faxlines:read sessions:fax:write history:read groups:faxlines:read offline_access contacts:read balance:read";
private readonly string _state = RandomDataBase64Url(32);
private string redirectUri;

private static int GetRandomUnusedPort()
{
Expand All @@ -52,12 +54,32 @@ public Authentication()
redirectUri = $"http://{IPAddress.Loopback}:{GetRandomUnusedPort()}/";
}

public HttpListener CreateLoginBrowserWindow()
public void enableRedirectFallback()
{
redirectUri = $"{_appWebBaseUrl}/faxdrucker-login";
}

public HttpListener CreateHttpCallbackListener()
{
// Creates an HttpListener to listen for requests on that redirect URI.
var http = new HttpListener();
http.Prefixes.Add(redirectUri);
http.Start();
HttpListener http = null;
try
{
http = new HttpListener();
http.Prefixes.Add(redirectUri);
http.Start();
}
catch (HttpListenerException e)
{
return null;
}

return http;
}

public void CreateLoginBrowserWindow()
{
Utils.LogInformation($"Redirect uri: {redirectUri}");

// Creates the OAuth 2.0 authorization request.
NameValueCollection queryString = System.Web.HttpUtility.ParseQueryString(string.Empty);
Expand All @@ -68,8 +90,6 @@ public HttpListener CreateLoginBrowserWindow()
queryString.Add("scope", Scope);

System.Diagnostics.Process.Start(_loginUrl + "?" + queryString);

return http;
}

public void SendHttpResponse(HttpListenerContext context, bool success)
Expand Down Expand Up @@ -229,7 +249,9 @@ public async Task<bool> PerformLogout(SipgateCredentials credentials)
public async Task<SipgateCredentials> PerformCodeExchange(string code)
{
HttpWebRequest tokenRequest = (HttpWebRequest)WebRequest.Create(_tokenUrl);

#if DEBUG
tokenRequest.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
#endif
try
{
SipgateCredentials sipgateCredentials = await ProcessCodeResponse(await PrepareCodeExchangeRequest(tokenRequest, code));
Expand All @@ -256,7 +278,7 @@ public async Task<SipgateCredentials> PerformCodeExchange(string code)
using (StreamReader reader = new StreamReader(responseStream))
{
string responseText = await reader.ReadToEndAsync();
throw new Exception(responseText);
throw new AuthorizationException(responseText);
}
}
}
Expand All @@ -275,6 +297,8 @@ public async Task<SipgateCredentials> PerformCodeExchange(string code)

private async Task<HttpWebRequest> PrepareCodeExchangeRequest(HttpWebRequest tokenRequest, string code)
{


NameValueCollection tokenRequestBody = System.Web.HttpUtility.ParseQueryString(string.Empty);
tokenRequestBody.Add("code", code);
tokenRequestBody.Add("client_id", _clientId);
Expand All @@ -284,7 +308,9 @@ private async Task<HttpWebRequest> PrepareCodeExchangeRequest(HttpWebRequest tok

byte[] byteVersion = Encoding.ASCII.GetBytes($"{tokenRequestBody}");

#if DEBUG
tokenRequest.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
#endif
tokenRequest.Method = "POST";
tokenRequest.ContentType = "application/x-www-form-urlencoded";
tokenRequest.Accept = "application/json";
Expand Down
11 changes: 4 additions & 7 deletions SipgateFaxdrucker/CredentialManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,8 @@ private SipgateCredentials LoadCredentials()

public void RemoveCredentials()
{
string directory = GetConfigPath();
if (File.Exists(directory))
{
File.Delete(directory);
}
_credentials = null;
_credentials = new SipgateCredentials("", "");
SaveCredentials();
}

public SipgateCredentials GetCredentials()
Expand Down Expand Up @@ -133,7 +129,8 @@ public void SaveCredentials(SipgateCredentials newCredentials)

public bool IsLoggedIn()
{
return GetCredentials() != null && GetCredentials().AccessToken != "";
var creds = GetCredentials();
return creds != null && creds.AccessToken != "" && creds.RefreshToken != "";
}
}
}
2 changes: 1 addition & 1 deletion SipgateFaxdrucker/GhostScript/GhostScriptRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private String GetOutputFilename()
{
var currentDateTimeString = DateTime.Now.ToString("dd-MM-yyyy HH-mm");
var settingsPathPart = Path.GetTempPath();
var completePath = settingsPathPart + currentDateTimeString + ".pdf";
var completePath = $"{settingsPathPart}SipgateFaxdrucker_{currentDateTimeString}.pdf";

String defaultOutputFilename =
Path.GetFullPath(completePath);
Expand Down
Binary file removed SipgateFaxdrucker/GhostScript/gsdll32.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion SipgateFaxdrucker/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("4.3.2.0")]
[assembly: AssemblyVersion("4.3.3.0")]

//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
Expand Down
2 changes: 1 addition & 1 deletion SipgateFaxdrucker/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion SipgateFaxdrucker/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions SipgateFaxdrucker/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@
<Setting Name="MixpanelTokenDebug" Type="System.String" Scope="User">
<Value Profile="(Default)">5e2eedfb2db9a53766edab1380f6017e</Value>
</Setting>
<Setting Name="UpdateCheckUrl32" Type="System.String" Scope="User">
<Value Profile="(Default)">https://sipgate-faxdrucker.s3.eu-central-1.amazonaws.com/version32.xml</Value>
</Setting>
</Settings>
</SettingsFile>
Loading

0 comments on commit c8eaf67

Please sign in to comment.