Skip to content
Draft

Main #10

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions CompuMaster.Dms.BrowserUI/CompuMaster.Dms.BrowserUI.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
<Configurations>Debug;Release;CI_CD</Configurations>
<Authors>Jochen Wezel</Authors>
<Company>CompuMaster GmbH</Company>
<Copyright>2019-2025 CompuMaster GmbH</Copyright>
<Copyright>2019-2026 CompuMaster GmbH</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>logo_64x64.png</PackageIcon>
<PackageIconUrl />
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>DmsBrowser NextCloud OwnCloud CenterDevice Scopevisio Teamwork WebDAV API</PackageTags>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
Expand Down Expand Up @@ -48,14 +49,18 @@
</PropertyGroup>

<ItemGroup>
<None Include="..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="logo_64x64.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="CompuMaster.IO.TemporaryFile" Version="2024.12.24.100" />
<PackageReference Include="CompuMaster.IO.TemporaryFile" Version="2025.10.16" />
<PackageReference Include="CompuMaster.VisualBasicCompatibility" Version="1.0.6" />
<PackageReference Include="InformationBox" Version="1.3.0.162" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
Expand Down
11 changes: 8 additions & 3 deletions CompuMaster.Dms.Providers/CompuMaster.Dms.Providers.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFrameworks>netstandard2.0;net48;net6.0</TargetFrameworks>
<PackageIcon>logo_64x64.png</PackageIcon>
<PackageIconUrl />
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>DmsBrowser NextCloud OwnCloud CenterDevice Scopevisio Teamwork WebDAV API</PackageTags>
<IncludeSymbols>true</IncludeSymbols>
Expand All @@ -17,7 +18,7 @@
<AssemblyName>CompuMaster.Dms.Providers</AssemblyName>
<OptionStrict>On</OptionStrict>
<Configurations>Debug;Release;CI_CD</Configurations>
<Copyright>2019-2025 CompuMaster GmbH</Copyright>
<Copyright>2019-2026 CompuMaster GmbH</Copyright>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down Expand Up @@ -51,15 +52,19 @@
</PropertyGroup>

<ItemGroup>
<None Include="..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="logo_64x64.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="CompuMaster.CenterDevice.Rest" Version="2024.11.5.100" />
<PackageReference Include="CompuMaster.Scopevisio.OpenApi" Version="2024.11.5.100" />
<PackageReference Include="CompuMaster.CenterDevice.Rest" Version="2026.1.2.100" />
<PackageReference Include="CompuMaster.Scopevisio.OpenApi" Version="2026.1.2.1" />
<PackageReference Include="CompuMaster.Scopevisio.Teamwork" Version="2022.4.14.100" />
<PackageReference Include="RestSharp" Version="112.1.0" />
<PackageReference Include="WebDav.Client" Version="2.9.0" />
Expand Down
15 changes: 15 additions & 0 deletions CompuMaster.Dms.Providers/Data/BaseDmsLoginCredentials.vb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,28 @@ Namespace Data
Implements IDmsLoginProfile

Public Property DmsProvider As BaseDmsProvider.DmsProviders

''' <summary>
''' An optional server address
''' </summary>
''' <returns></returns>
Public Overridable Property BaseUrl As String

''' <summary>
''' An optional customer reference
''' </summary>
''' <returns></returns>
Public Overridable Property CustomerInstance As String

Public Property Username As String
Public Property Password As String

''' <summary>
''' Ignore SSL handshake errors for this DMS server
''' </summary>
''' <returns></returns>
Public Property IgnoreSslErrors As Boolean

Public Property EncryptionProvider As Byte

Protected Overridable ReadOnly Property IDmsLoginProfile_ProfileName As String Implements IDmsLoginProfile.ProfileName
Expand Down Expand Up @@ -60,6 +69,12 @@ Namespace Data
End Get
End Property

Private ReadOnly Property IDmsLoginProfile_IgnoreSslErrors As Boolean Implements IDmsLoginProfile.IgnoreSslErrors
Get
Return Me.IgnoreSslErrors
End Get
End Property

Protected Function EncryptText(value As String) As String
Return value
End Function
Expand Down
11 changes: 11 additions & 0 deletions CompuMaster.Dms.Providers/Data/IDmsLoginProfile.vb
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,42 @@ Namespace Data
''' </summary>
''' <returns></returns>
ReadOnly Property ProfileName As String

''' <summary>
''' A provider ID
''' </summary>
ReadOnly Property ProviderID As BaseDmsProvider.DmsProviders

''' <summary>
''' The username for login
''' </summary>
''' <returns></returns>
ReadOnly Property UserName As String

''' <summary>
''' The password for login
''' </summary>
''' <returns></returns>
ReadOnly Property Password As String

''' <summary>
''' An optional reference to the customer instance, e.g. a client number
''' </summary>
''' <returns></returns>
ReadOnly Property CustomerInstance As String

''' <summary>
''' An optional reference to a server
''' </summary>
''' <returns></returns>
ReadOnly Property ServerAddress As String

''' <summary>
''' Ignore SSL handshake errors for this DMS server
''' </summary>
''' <returns></returns>
ReadOnly Property IgnoreSslErrors As Boolean

End Interface

End Namespace
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Namespace Providers
Return Me.WebApiDefaultUrl
End Function

Public Overloads Sub Authorize(loginCredentials As CenterDeviceLoginCredentials)
Public Overloads Sub Authorize(loginCredentials As CenterDeviceLoginCredentials, ignoreSslErrors As Boolean)
'Dim Url As String = Me.CustomizedWebApiUrl(loginCredentials)
'Dim OpenScopeConfig As New Global.CompuMaster.Scopevisio.OpenApi.Client.Configuration()
'OpenScopeConfig.Username = loginCredentials.Username
Expand All @@ -77,7 +77,7 @@ Namespace Providers
Credentials.Username = dmsProfile.UserName
Credentials.ClientNumber = dmsProfile.CustomerInstance
Credentials.Password = dmsProfile.Password
Me.Authorize(Credentials)
Me.Authorize(Credentials, dmsProfile.IgnoreSslErrors)
End Sub

End Class
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Option Explicit On
Option Strict On

Imports System.Net.Http
Imports CompuMaster.Dms.Data
Imports CompuMaster.Dms.Providers
Imports CompuMaster.Scopevisio.OpenApi
Expand Down Expand Up @@ -55,13 +56,22 @@ Namespace Providers
End Function

Public Overloads Sub Authorize(loginCredentials As ScopevisioLoginCredentials)
Me.Authorize(loginCredentials, False)
End Sub
Public Overloads Sub Authorize(loginCredentials As ScopevisioLoginCredentials, ignoreSslErrors As Boolean)
Try
Dim OpenScopeConfig As New Global.CompuMaster.Scopevisio.OpenApi.Client.Configuration With {
.Username = loginCredentials.Username,
.Password = loginCredentials.Password,
.ClientNumber = loginCredentials.ClientNumber,
.OrganisationName = loginCredentials.OrganisationName
}
.Username = loginCredentials.Username,
.Password = loginCredentials.Password,
.ClientNumber = loginCredentials.ClientNumber,
.OrganisationName = loginCredentials.OrganisationName
}
If ignoreSslErrors Then
Dim Handler As New System.Net.Http.HttpClientHandler() With {
.ServerCertificateCustomValidationCallback = Function(sender, certificate, chain, sslPolicyErrors) True
}
OpenScopeConfig.HttpClient = New System.Net.Http.HttpClient(Handler)
End If
Dim OpenScopeClient As New CompuMaster.Scopevisio.OpenApi.OpenScopeApiClient(OpenScopeConfig)
OpenScopeClient.AuthorizeWithUserCredentials()
Me.IOClient = New CompuMaster.Scopevisio.Teamwork.TeamworkIOClient(OpenScopeClient)
Expand Down Expand Up @@ -93,7 +103,7 @@ Namespace Providers
Credentials.Username = dmsProfile.UserName
Credentials.ClientNumber = dmsProfile.CustomerInstance
Credentials.Password = dmsProfile.Password
Me.Authorize(Credentials)
Me.Authorize(Credentials, dmsProfile.IgnoreSslErrors)
End Sub

End Class
Expand Down
59 changes: 57 additions & 2 deletions CompuMaster.Dms.Providers/Providers/WebDavDmsProvider.vb
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
Option Explicit On
Option Strict On

Imports System.Net
Imports System.Net.Http
Imports System.Runtime.ConstrainedExecution
Imports System.Security.Claims
Imports CompuMaster.Dms.Data
Imports CompuMaster.Dms.Providers
Imports WebDav

Namespace Providers

Expand Down Expand Up @@ -56,14 +61,64 @@ Namespace Providers
''' <returns></returns>
Public Property CustomWebApiUrl As String

Private Shared Function CreateHttpClient(ignoreSslErrors As Boolean, ByVal params As WebDavClientParams) As System.Net.Http.HttpClient
Dim Handler As HttpClientHandler
If ignoreSslErrors = True Then
Handler = New HttpClientHandler() With {
.ServerCertificateCustomValidationCallback = Function(message, cert, chain, errors) True
}
Else
Handler = New HttpClientHandler()
End If
Return CreateConfiguredHttpClient(Handler, params)
End Function

Private Shared Function CreateConfiguredHttpClient(httpHandler As HttpClientHandler, ByVal params As WebDavClientParams) As System.Net.Http.HttpClient
With httpHandler
.AutomaticDecompression = DecompressionMethods.Deflate Or DecompressionMethods.GZip
.PreAuthenticate = params.PreAuthenticate
.UseDefaultCredentials = params.UseDefaultCredentials
.UseProxy = params.UseProxy
End With

If params.Credentials IsNot Nothing Then
httpHandler.Credentials = params.Credentials
httpHandler.UseDefaultCredentials = False
End If

If params.Proxy IsNot Nothing Then
httpHandler.Proxy = params.Proxy
End If

Dim httpClient = New HttpClient(httpHandler, True) With {
.BaseAddress = params.BaseAddress
}

If params.Timeout.HasValue Then
httpClient.Timeout = params.Timeout.Value
End If

For Each header In params.DefaultRequestHeaders
httpClient.DefaultRequestHeaders.Add(header.Key, header.Value)
Next

Return httpClient
End Function

Public Overloads Sub Authorize(loginCredentials As WebDavLoginCredentials)
Me.Authorize(loginCredentials, False)
End Sub

Public Overloads Sub Authorize(loginCredentials As WebDavLoginCredentials, ignoreSslErrors As Boolean)
Dim Url As String = Me.CustomizedWebApiUrl(loginCredentials)
Dim ClientParams As New Global.WebDav.WebDavClientParams() With
{
.BaseAddress = New System.Uri(Url),
.Credentials = New System.Net.NetworkCredential(loginCredentials.Username, loginCredentials.Password)
}
Me.WebDavClient = New Global.WebDav.WebDavClient(ClientParams)
Dim HttpClient = CreateHttpClient(True, ClientParams)
Me.WebDavClient = New Global.WebDav.WebDavClient(HttpClient) 'uses copy of method ConfiguredHttpClient from WebDavClient
'Me.WebDavClient = New Global.WebDav.WebDavClient(ClientParams) 'uses internal method ConfiguredHttpClient from WebDavClient
Me._AuthorizedUser = loginCredentials.Username
If Url.EndsWith("/") Then
Me.CustomWebApiUrl = Url
Expand Down Expand Up @@ -468,7 +523,7 @@ Namespace Providers
Credentials.BaseUrl = dmsProfile.ServerAddress
Credentials.Username = dmsProfile.UserName
Credentials.Password = dmsProfile.Password
Me.Authorize(Credentials)
Me.Authorize(Credentials, dmsProfile.IgnoreSslErrors)
End Sub

Public Overrides ReadOnly Property SupportsCollections As Boolean
Expand Down
Loading
Loading