Merge branch 'newMaster2024' of https://git.it.verag.ag/edv/SDL into newMaster2024

This commit is contained in:
2025-11-05 11:50:58 +01:00
2 changed files with 38 additions and 18 deletions

View File

@@ -44,7 +44,7 @@ Public Class cRelayHub
Public Class cRelayHubHeaderData Public Class cRelayHubHeaderData
Public Property agentContact As cRelayHubAgentContact Public Property agentContact As cRelayHubAgentContact
Public Property declarantIsConsignee As Boolean Public Property declarantIsConsignee As Boolean
Public Property representationRelationshipCode As Integer ' <- war String Public Property representationRelationshipCode As String ' <- war String
Public Property inputTaxDeduction As Boolean ' <- war String Public Property inputTaxDeduction As Boolean ' <- war String
Public Property procedureCodeRequested As String Public Property procedureCodeRequested As String
' Entfernt: goodsStatus, costs (nicht im Schema an dieser Stelle) ' Entfernt: goodsStatus, costs (nicht im Schema an dieser Stelle)
@@ -62,7 +62,7 @@ Public Class cRelayHub
Public Class cRelayHubAddress Public Class cRelayHubAddress
Public Property addressType As String Public Property addressType As String
Public Property participantEORI As String Public Property participantEORI As String
Public Property participantSubsidiaryNumber As Integer Public Property participantSubsidiaryNumber As String
Public Property companyName As String Public Property companyName As String
Public Property streetAndNumber As String Public Property streetAndNumber As String
Public Property countryCode As String Public Property countryCode As String
@@ -111,7 +111,7 @@ Public Class cRelayHub
Public Class cRelayHub_sendToRelayHub_JobOrderRequest Public Class cRelayHub_sendToRelayHub_JobOrderRequest
Shared API_URL As String = "https://dev-relayhub.singlewindow.io/api/v1-0" Shared API_URL As String = "https://declaranthub.singlewindow.io/api/v1-0"
' Low-level Sender: holt Access-Token aus cRelayHubToken und sendet JSON ' Low-level Sender: holt Access-Token aus cRelayHubToken und sendet JSON
Private Shared Function SendJobOrder(jsonPayload As String) As Chilkat.HttpResponse Private Shared Function SendJobOrder(jsonPayload As String) As Chilkat.HttpResponse
@@ -120,8 +120,10 @@ Public Class cRelayHub
' *** Token aus der separaten Token-Klasse beziehen *** ' *** Token aus der separaten Token-Klasse beziehen ***
Dim token As String = cRelayHubToken.GetAccessToken() Dim token As String = cRelayHubToken.GetAccessToken()
http.AuthToken = token ' -> setzt Authorization: Bearer <token> http.AuthToken = token
Console.WriteLine("Using Token: " & token) 'http.AuthToken = "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJqdkkzQ3BfbTVTb3JpdUFmSEZkZzJWUGgxcDFNWHA3ZnpjNFhyVHpGWVc4In0.eyJleHAiOjE3NjEzMDE4NTQsImlhdCI6MTc2MTIxNTQ1NCwianRpIjoiNWY3MjdkZTUtMmQ2MS00MThkLWJhYWQtNmY5ODM0NDk2NjY2IiwiaXNzIjoiaHR0cHM6Ly9sb2dpbi5zaW5nbGV3aW5kb3cuaW8vYXV0aC9yZWFsbXMvYWdzdyIsImF1ZCI6ImFjY291bnQiLCJzdWIiOiI5OWMwOTFmMy01Mjg1LTRhNzUtODdjNC0zODJlNThlNTBmNGMiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJhZ3N3LWFkbWluIiwic2lkIjoiMzRjMDY4ZGMtNjY3My00NDk5LTgzODAtMjVkOGYyNjI1NGY4IiwiYWxsb3dlZC1vcmlnaW5zIjpbImh0dHBzOi8vc2luZ2xld2luZG93LmlvIiwiaHR0cHM6Ly9hZ3N3LnNpbmdsZXdpbmRvdy5pbyIsImh0dHA6Ly9sb2NhbGhvc3Q6MzAwMSJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsiZGVmYXVsdC1yb2xlcy1hZ3N3Iiwib2ZmbGluZV9hY2Nlc3MiLCJ1bWFfYXV0aG9yaXphdGlvbiJdfSwicmVzb3VyY2VfYWNjZXNzIjp7ImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX0sInNjb3BlIjoicHJvZHVjdC1jYXRhbG9nLXNjcCBwcm9maWxlIGVtYWlsIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsIm5hbWUiOiJEaHViLVByb2QgVXNlciIsInByZWZlcnJlZF91c2VybmFtZSI6ImRodWJAdmVyYWcuYWciLCJnaXZlbl9uYW1lIjoiRGh1Yi1Qcm9kIiwiZmFtaWx5X25hbWUiOiJVc2VyIiwiZW1haWwiOiJkaHViQHZlcmFnLmFnIn0.TZ8GkXrL7SSz1CEOnLB2eAAuVcYu3wlNtnAF6Y3wt0lnMGyse5tsI0YYSfGZG_Ae8zVcPqHqVT4rhDOgIPooBkq71z35ppd6b-FUaS6hSy4cMWQaidsHZr3hkID8amVQcB2vz9Yg985h3MOCSIn86d0x9i0euew3wEpF8eEHSfk_Wqf8jeJbiXAPHfy92K4Xh8IIuh-GXUTyN-NmGM94_NhcQwb4e7YMXjPPuslUsjABEfOvT7v4-AnO5B3ZczX0h0UgafmfiIyXSaL4IzYZojoMJ0CRsHdAK-j4gzXqz4lW0A9KMmHGHn01Oftt9mXfrEmCj0XGWF9xvBuYhxMUAQ"
Console.WriteLine("Using Token =: " & http.AuthToken)
Console.WriteLine("API_URL =: " & API_URL)
Return http.PostJson2(API_URL & "/job-orders/init", "application/json", jsonPayload) Return http.PostJson2(API_URL & "/job-orders/init", "application/json", jsonPayload)
End Function End Function
@@ -182,6 +184,7 @@ Public Class cRelayHub
' Auswertung ' Auswertung
result.StatusCode = response.StatusCode result.StatusCode = response.StatusCode
Console.WriteLine("result.StatusCode → " & result.StatusCode)
Select Case response.StatusCode Select Case response.StatusCode
Case 201 Case 201
Try Try
@@ -230,15 +233,8 @@ Public Class cRelayHub
' lokale Fail-fast Checks ' lokale Fail-fast Checks
If req.dispatchCountry.Length <> 2 Then Throw New ApplicationException("dispatchCountry ISO-2 erforderlich.") If req.dispatchCountry.Length <> 2 Then Throw New ApplicationException("dispatchCountry ISO-2 erforderlich.")
If req.destinationCountry.Length <> 2 Then Throw New ApplicationException("destinationCountry ISO-2 erforderlich.") If req.destinationCountry.Length <> 2 Then Throw New ApplicationException("destinationCountry ISO-2 erforderlich.")
Dim allowed = New HashSet(Of String)(StringComparer.Ordinal) From {
"test", "dakosy/sftp/vera", "evrim/excel", "sec/import/integration"
}
If Not allowed.Contains(req.outputApplication) Then
Throw New ApplicationException("outputApplication muss 'test' | 'dakosy/sftp/vera' | 'evrim/excel' | 'sec/import/integration' sein.")
End If
If req.regimeType <> "IMPORT" AndAlso req.regimeType <> "EXPORT" Then
Throw New ApplicationException("regimeType muss 'IMPORT' oder 'EXPORT' sein.")
End If
Return req Return req
End Function End Function

View File

@@ -10,14 +10,27 @@ Imports Newtonsoft.Json
Public Class cRelayHubToken Public Class cRelayHubToken
' ======= KONFIG ======= ' ======= KONFIG =======
Private Shared ReadOnly TOKEN_ENDPOINT As String = Private Shared ReadOnly TOKEN_ENDPOINT As String = "https://login.singlewindow.io/auth/realms/agsw/protocol/openid-connect/token"
"https://dev-kc.singlewindow.io/auth/realms/agsw/protocol/openid-connect/token"
' Private Shared ReadOnly TOKEN_ENDPOINT As String = "https://dev-kc.singlewindow.io/auth/realms/agsw/protocol/openid-connect/token"
' curl --location 'https://login.singlewindow.io/auth/realms/agsw/protocol/openid-connect/token' \
'--header 'Content-Type: application/x-www-form-urlencoded' \
'--data-urlencode 'grant_type=password' \
'--data-urlencode 'password=Dhub1234*' \
'--data-urlencode 'username=dhub@verag.ag' \
'--data-urlencode 'client_id=agsw-admin'
Private Shared ReadOnly CLIENT_ID As String = "agsw-admin" Private Shared ReadOnly CLIENT_ID As String = "agsw-admin"
' Gewünscht: Zugangsdaten in der Klasse definieren ' Gewünscht: Zugangsdaten in der Klasse definieren
Private Shared ReadOnly USERNAME As String = "andreas.test@test.com" Private Shared ReadOnly USERNAME As String = "dhub@verag.ag" '"andreas.test@test.com"
Private Shared ReadOnly PASSWORD As String = "Password.123" Private Shared ReadOnly PASSWORD As String = "Dhub1234*" '"Password.123"
' Token-File pro Benutzer unter %AppData% ' Token-File pro Benutzer unter %AppData%
Private Shared ReadOnly StorePath As String = Private Shared ReadOnly StorePath As String =
@@ -179,6 +192,17 @@ Public Class cRelayHubToken
End Try End Try
End Sub End Sub
Public Shared Sub DeleteStore()
Try
If System.IO.File.Exists(StorePath) Then System.IO.File.Delete(StorePath)
Console.WriteLine("Token-Datei gelöscht: " & StorePath)
Catch ex As Exception
Console.WriteLine("Fehler beim Löschen der Token-Datei: " & ex.Message)
End Try
End Sub
' ======= DTOs ======= ' ======= DTOs =======
Private Class TokenResponse Private Class TokenResponse
Public Property access_token As String Public Property access_token As String