Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issv3 hub peripherals list add #9833

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
330 commits
Select commit Hold shift + click to select a range
e787316
Introduce common IssServer interface
mackdk Jan 10, 2025
2c91296
Added API to register hub/peripherals
mackdk Jan 10, 2025
5c66b89
Generate and store the SCC credentials on the peripheral
mackdk Jan 10, 2025
90bde38
Add new credentials type for the hub scc endpoint
mackdk Jan 10, 2025
cd7c79f
Refactored the package structure
mackdk Jan 17, 2025
b48aaeb
Ensure each public method in the HubManager enforce authorization
mackdk Jan 20, 2025
03bbef6
Unified changelog
mackdk Jan 20, 2025
ea8a0c6
Add SQL scripts to create root-ca-cert-update task in taskomatic
CDellaGiusta Jan 22, 2025
bd6056b
Create a task in taskomatic to save and update root ca certificates
CDellaGiusta Jan 22, 2025
cb2731e
move findByAnyFqdn to ServerFactory
mcalmer Jan 16, 2025
deb0d79
manager api for report db configuration
mcalmer Jan 5, 2025
8315ecd
remove setting manager info during registation
mcalmer Jan 17, 2025
562643c
update unit test for reportdb configuration
mcalmer Jan 17, 2025
8e3168c
adapt messages for changed behavior
mcalmer Jan 17, 2025
4645b87
better logging
mcalmer Jan 21, 2025
6681c30
only allow registration of a peripheral server from the hub
mcalmer Jan 27, 2025
4e68759
Restrict the register API to only work for hub registration
mackdk Jan 27, 2025
21dd8b4
Removed API to request SCC credentials generation
mackdk Jan 27, 2025
b49acac
rename public API register to registerPeripheral
mcalmer Jan 28, 2025
26c3575
rename IssHandler into HubHandler
mcalmer Jan 28, 2025
5e69f44
rename internal and external clients from Iss into Hub
mcalmer Jan 28, 2025
e6d2de0
rename helper classes from Iss into Hub
mcalmer Jan 28, 2025
0b3e68e
change sync controller namespace using hub
mcalmer Jan 28, 2025
8f25793
rename SyncController into HubController
mcalmer Jan 28, 2025
322c7a5
add link for credential back to hub/peripheral
lucidd Oct 18, 2024
b2cdbae
CreateAPI endpoints to list all peripheral orgs and channels; Create …
CDellaGiusta Feb 3, 2025
299667f
refresh custom repositories when delivered via repositories endpoint
mcalmer Jan 27, 2025
17a301b
db schema: add gpg_key for Hub and custom-gpg-key-import task
mcalmer Jan 29, 2025
4201446
submit, store and import the Hub GPG key on the Peripheral Server, if…
mcalmer Jan 29, 2025
57434c9
adapt unit tests for gpg keys
mcalmer Jan 30, 2025
00d7dc6
APIs to de-register, replace tokens and update details of ISS server
mcalmer Jan 31, 2025
d9354bc
unit tests for de-register, replace tokens and update details of ISS …
mcalmer Feb 3, 2025
7ec53f7
support multiple allowed roles in spark check
mcalmer Feb 5, 2025
fd65cee
specify custom repo fake scc id
mcalmer Feb 6, 2025
4d4a40a
disable unused pages in Hub Online Sync case
mcalmer Feb 4, 2025
ffafb0b
bump API version 27 to 28
mcalmer Feb 4, 2025
4d92c48
disable APIs which add channels and org credentials
mcalmer Feb 4, 2025
fce692a
fix sonarlint suggestions
mcalmer Feb 7, 2025
c5b7d94
unit test deny API access
mcalmer Feb 7, 2025
fe85548
Add a TextArea component
mackdk Feb 14, 2025
383a1dc
Add index for panels components
mackdk Feb 14, 2025
61cdbd4
Added exception for handling invalid responses from the remote server
mackdk Feb 14, 2025
e97d5ce
Added UI component to perform ISS server registration
mackdk Feb 14, 2025
cefa86d
Added created/modified date to access tokens
mackdk Feb 14, 2025
c6892e3
Add page to manage access tokens
mackdk Feb 14, 2025
4f4cc2b
Added toggle validity and delete in the token list page
mackdk Feb 14, 2025
9fbc6ea
Add actions to issue and store tokens
mackdk Feb 14, 2025
c0797a1
Fixed icon spacing in Dropdownbutton when using LinkButton as entries
mackdk Feb 14, 2025
5e5fb9d
Merge branch 'uyuni-project:issv3' into issv3
Serp1co Feb 15, 2025
778a203
new paginated peripheral list
Serp1co Feb 16, 2025
b67db0f
channel sync component start
Serp1co Feb 16, 2025
75eb8ac
Merge remote-tracking branch 'uyuni-upstream/issv3' into issv3-hub-pe…
Serp1co Feb 16, 2025
e4b83f1
Initial skeleton of the UI
Serp1co Jan 13, 2025
0aa6627
Merge remote-tracking branch 'uyuni-upstream/issv3-hub-peripherals-ui…
Serp1co Feb 17, 2025
e542805
add hub scc endpoint
lucidd Jan 29, 2025
cf1d52a
fixup! Added API to register hub/peripherals
mcalmer Feb 13, 2025
0fa0547
fixup! fix sonarlint suggestions
mcalmer Feb 13, 2025
f34c35f
add special download route for hubsync using the scc repo id
mcalmer Feb 14, 2025
e6175f2
change all vendor repo URLs to hub by using new hubsync download endp…
mcalmer Feb 14, 2025
3860bfe
fix sonarcloud issues
mcalmer Feb 16, 2025
de422d2
set signing repo flag correct for vendor channels
mcalmer Feb 16, 2025
c41254d
make peripheral channel tokens short lived
lucidd Feb 17, 2025
2855e43
fix setup wizard link
lucidd Feb 17, 2025
ca288b7
move scc endpoint into the hub namespace
lucidd Feb 18, 2025
71d0143
move isSCCCredentials check into CloudPaygManager to break a cyclic d…
mcalmer Feb 18, 2025
a085725
Add a TextArea component
mackdk Feb 14, 2025
28eebab
Add index for panels components
mackdk Feb 14, 2025
fbdd6cf
Added exception for handling invalid responses from the remote server
mackdk Feb 14, 2025
0c40c04
Added UI component to perform ISS server registration
mackdk Feb 14, 2025
697ac8d
Added created/modified date to access tokens
mackdk Feb 14, 2025
ee39c4b
Add page to manage access tokens
mackdk Feb 14, 2025
5998f47
Added toggle validity and delete in the token list page
mackdk Feb 14, 2025
ef5ca07
Add actions to issue and store tokens
mackdk Feb 14, 2025
df06aa9
Fixed icon spacing in Dropdownbutton when using LinkButton as entries
mackdk Feb 14, 2025
6ee463b
channel sync component wip
Serp1co Feb 18, 2025
eaf3a87
issv3 peripheral controller
Serp1co Feb 18, 2025
c44153e
Merge remote-tracking branch 'refs/remotes/uyuni-upstream/issv3' into…
Serp1co Feb 18, 2025
70e9de4
Merge remote-tracking branch 'uyuni-upstream/issv3-scc-endpoints' int…
Serp1co Feb 18, 2025
a06db40
wrong peripheral path
Serp1co Feb 19, 2025
aae7a63
peripheral/list or it wont work (will fix)
Serp1co Feb 19, 2025
b08e8d5
client authz changes
Serp1co Feb 19, 2025
ff5b6fd
usage of superinterface Type instead of Class for parsing responses: …
Serp1co Feb 19, 2025
cf63968
initial DB schema for ISSv3
mcalmer Oct 14, 2024
237bf46
ISSv3 DB schema migration
mcalmer Oct 14, 2024
440e215
initial Hibernate Schema for ISS Hub and Peripheral
mcalmer Oct 14, 2024
d64c97a
unit tests for HubFactory
mcalmer Oct 14, 2024
f0161bc
apply review suggestions
mcalmer Oct 18, 2024
c6f4ded
Refactored building/parsing of the JTW tokens
mackdk Dec 6, 2024
b299c3a
Simplified handling of PostgreSQL enum types
mackdk Dec 11, 2024
480a962
Added database tables and java object to handle ISS tokens
mackdk Dec 6, 2024
d6e72c9
Added API to generate and store tokens
mackdk Dec 6, 2024
abf2fef
Added new /iss path for v3 APIs
mackdk Dec 6, 2024
42edebf
Ensure only one issued and one consumed tokens can exit per server fqdn
mackdk Jan 10, 2025
debd6d5
Renamed the handler consistently
mackdk Jan 10, 2025
87a5c3b
Moved ISS-related code to specific Spark Helper
mackdk Jan 10, 2025
4fd78f6
Introduce common IssServer interface
mackdk Jan 10, 2025
1e422db
Added API to register hub/peripherals
mackdk Jan 10, 2025
bfd9c46
Generate and store the SCC credentials on the peripheral
mackdk Jan 10, 2025
6e00ae8
Add new credentials type for the hub scc endpoint
mackdk Jan 10, 2025
e37cc7e
Refactored the package structure
mackdk Jan 17, 2025
6efd1fb
Ensure each public method in the HubManager enforce authorization
mackdk Jan 20, 2025
e95afcc
Unified changelog
mackdk Jan 20, 2025
e6fff79
Add SQL scripts to create root-ca-cert-update task in taskomatic
CDellaGiusta Jan 22, 2025
ef3bbd6
Create a task in taskomatic to save and update root ca certificates
CDellaGiusta Jan 22, 2025
c53ec14
move findByAnyFqdn to ServerFactory
mcalmer Jan 16, 2025
a8c9fb1
manager api for report db configuration
mcalmer Jan 5, 2025
608ae0d
remove setting manager info during registation
mcalmer Jan 17, 2025
08e74a4
update unit test for reportdb configuration
mcalmer Jan 17, 2025
1a9562c
adapt messages for changed behavior
mcalmer Jan 17, 2025
92d9a5d
better logging
mcalmer Jan 21, 2025
34c4213
only allow registration of a peripheral server from the hub
mcalmer Jan 27, 2025
74b7954
Restrict the register API to only work for hub registration
mackdk Jan 27, 2025
bca4e40
Removed API to request SCC credentials generation
mackdk Jan 27, 2025
0eb3263
rename public API register to registerPeripheral
mcalmer Jan 28, 2025
30745b4
rename IssHandler into HubHandler
mcalmer Jan 28, 2025
9814b0a
rename internal and external clients from Iss into Hub
mcalmer Jan 28, 2025
b9f2c76
rename helper classes from Iss into Hub
mcalmer Jan 28, 2025
562474b
change sync controller namespace using hub
mcalmer Jan 28, 2025
3afa8fb
rename SyncController into HubController
mcalmer Jan 28, 2025
ef6c1b4
add link for credential back to hub/peripheral
lucidd Oct 18, 2024
79e1f2f
CreateAPI endpoints to list all peripheral orgs and channels; Create …
CDellaGiusta Feb 3, 2025
a711d56
refresh custom repositories when delivered via repositories endpoint
mcalmer Jan 27, 2025
2c4cfc4
db schema: add gpg_key for Hub and custom-gpg-key-import task
mcalmer Jan 29, 2025
5e38335
submit, store and import the Hub GPG key on the Peripheral Server, if…
mcalmer Jan 29, 2025
906e4fd
adapt unit tests for gpg keys
mcalmer Jan 30, 2025
5abdbcf
APIs to de-register, replace tokens and update details of ISS server
mcalmer Jan 31, 2025
0e263e4
unit tests for de-register, replace tokens and update details of ISS …
mcalmer Feb 3, 2025
741011c
support multiple allowed roles in spark check
mcalmer Feb 5, 2025
79d1edc
specify custom repo fake scc id
mcalmer Feb 6, 2025
5c1fcfd
disable unused pages in Hub Online Sync case
mcalmer Feb 4, 2025
2772db3
bump API version 27 to 28
mcalmer Feb 4, 2025
f3701b4
disable APIs which add channels and org credentials
mcalmer Feb 4, 2025
a13795a
fix sonarlint suggestions
mcalmer Feb 7, 2025
67b3bc2
unit test deny API access
mcalmer Feb 7, 2025
03e274f
Add a TextArea component
mackdk Feb 14, 2025
d73a2b1
Add index for panels components
mackdk Feb 14, 2025
6c16ab5
Added exception for handling invalid responses from the remote server
mackdk Feb 14, 2025
27f1b56
Added UI component to perform ISS server registration
mackdk Feb 14, 2025
382f887
Added created/modified date to access tokens
mackdk Feb 14, 2025
8395743
Add page to manage access tokens
mackdk Feb 14, 2025
8df24a4
Added toggle validity and delete in the token list page
mackdk Feb 14, 2025
1e0f7f3
Add actions to issue and store tokens
mackdk Feb 14, 2025
5d0b485
Fixed icon spacing in Dropdownbutton when using LinkButton as entries
mackdk Feb 14, 2025
c4913be
add hub scc endpoint
lucidd Jan 29, 2025
e0ba5f1
add special download route for hubsync using the scc repo id
mcalmer Feb 14, 2025
a92ff7c
fix sonarcloud issues
mcalmer Feb 16, 2025
8b1e6c8
set signing repo flag correct for vendor channels
mcalmer Feb 16, 2025
d3ddc6d
make peripheral channel tokens short lived
lucidd Feb 17, 2025
36fce37
move scc endpoint into the hub namespace
lucidd Feb 18, 2025
5e1551d
move isSCCCredentials check into CloudPaygManager to break a cyclic d…
mcalmer Feb 18, 2025
a1a5bac
Ensure sync hub APIs are responding correctly if a runtime exception …
CDellaGiusta Feb 12, 2025
d818ce1
Remove redundand exception catching
CDellaGiusta Feb 12, 2025
e581314
Add addVendorChannel peripheral sync API endpoint
CDellaGiusta Feb 5, 2025
28a3799
Adds missing equals, hashcode, tostring methods to ChannelInfoJson
CDellaGiusta Feb 7, 2025
c0162c8
Adds addCustomChannels peripheral sync API endpoint
CDellaGiusta Feb 7, 2025
2186b4a
Adds modifyCustomChannels peripheral sync API endpoint
CDellaGiusta Feb 18, 2025
04fc78e
Change naming of ISS route accessibility
CDellaGiusta Feb 20, 2025
180fb43
channels sync wip
Serp1co Feb 20, 2025
b5f2a95
deregister peripheral api
Serp1co Feb 21, 2025
8da9477
Merge remote-tracking branch 'serp1co-uyuni/issv3' into issv3-hub-per…
Serp1co Feb 21, 2025
2fbf17a
Remove redundand exception catching
CDellaGiusta Feb 12, 2025
fcfb1ac
Add addVendorChannel peripheral sync API endpoint
CDellaGiusta Feb 5, 2025
56fd8b6
Adds missing equals, hashcode, tostring methods to ChannelInfoJson
CDellaGiusta Feb 7, 2025
2b8dfc3
Adds addCustomChannels peripheral sync API endpoint
CDellaGiusta Feb 7, 2025
2331da6
Merge remote-tracking branch 'uyuni-upstream/issv3' into issv3-hub-pe…
Serp1co Feb 21, 2025
1b82ca2
hub api controller new apis for management of peripheral
CDellaGiusta Feb 18, 2025
c06ac73
channels sync api wip
Serp1co Feb 21, 2025
eeb79eb
channels sync api wip
Serp1co Feb 21, 2025
9741979
channels sync api wip
Serp1co Feb 21, 2025
55cd82d
error when calling addVendorChannel -> product doesn't have auth on g…
Serp1co Feb 21, 2025
051e04d
initial DB schema for ISSv3
mcalmer Oct 14, 2024
871f76f
ISSv3 DB schema migration
mcalmer Oct 14, 2024
d7f974a
initial Hibernate Schema for ISS Hub and Peripheral
mcalmer Oct 14, 2024
95a46d4
unit tests for HubFactory
mcalmer Oct 14, 2024
7f7c818
apply review suggestions
mcalmer Oct 18, 2024
67b288d
Refactored building/parsing of the JTW tokens
mackdk Dec 6, 2024
8ea089e
Simplified handling of PostgreSQL enum types
mackdk Dec 11, 2024
e711a16
Added database tables and java object to handle ISS tokens
mackdk Dec 6, 2024
7c9335c
Added API to generate and store tokens
mackdk Dec 6, 2024
1810998
Added new /iss path for v3 APIs
mackdk Dec 6, 2024
c955343
Ensure only one issued and one consumed tokens can exit per server fqdn
mackdk Jan 10, 2025
ffe6c6d
Renamed the handler consistently
mackdk Jan 10, 2025
1df2bb2
Moved ISS-related code to specific Spark Helper
mackdk Jan 10, 2025
4f6e654
Introduce common IssServer interface
mackdk Jan 10, 2025
6bcecce
Added API to register hub/peripherals
mackdk Jan 10, 2025
a3a38ff
Generate and store the SCC credentials on the peripheral
mackdk Jan 10, 2025
94039e9
Add new credentials type for the hub scc endpoint
mackdk Jan 10, 2025
4fa3b29
Refactored the package structure
mackdk Jan 17, 2025
cfeac7c
Ensure each public method in the HubManager enforce authorization
mackdk Jan 20, 2025
b4fba92
Unified changelog
mackdk Jan 20, 2025
1e0707b
Add SQL scripts to create root-ca-cert-update task in taskomatic
CDellaGiusta Jan 22, 2025
3aadeef
Create a task in taskomatic to save and update root ca certificates
CDellaGiusta Jan 22, 2025
07f42a7
move findByAnyFqdn to ServerFactory
mcalmer Jan 16, 2025
15a3ab1
manager api for report db configuration
mcalmer Jan 5, 2025
6ed7125
remove setting manager info during registation
mcalmer Jan 17, 2025
49c6ecf
update unit test for reportdb configuration
mcalmer Jan 17, 2025
00740ef
adapt messages for changed behavior
mcalmer Jan 17, 2025
1c25ded
better logging
mcalmer Jan 21, 2025
de702ee
only allow registration of a peripheral server from the hub
mcalmer Jan 27, 2025
cfe4ab8
Restrict the register API to only work for hub registration
mackdk Jan 27, 2025
640c0ff
Removed API to request SCC credentials generation
mackdk Jan 27, 2025
6b99336
rename public API register to registerPeripheral
mcalmer Jan 28, 2025
5368469
rename IssHandler into HubHandler
mcalmer Jan 28, 2025
39bffb5
rename internal and external clients from Iss into Hub
mcalmer Jan 28, 2025
c8f3e56
rename helper classes from Iss into Hub
mcalmer Jan 28, 2025
1efbbcf
change sync controller namespace using hub
mcalmer Jan 28, 2025
0d0cf90
rename SyncController into HubController
mcalmer Jan 28, 2025
188baef
add link for credential back to hub/peripheral
lucidd Oct 18, 2024
d7badad
CreateAPI endpoints to list all peripheral orgs and channels; Create …
CDellaGiusta Feb 3, 2025
0fd3b38
refresh custom repositories when delivered via repositories endpoint
mcalmer Jan 27, 2025
9c59e0d
db schema: add gpg_key for Hub and custom-gpg-key-import task
mcalmer Jan 29, 2025
a7d6cad
submit, store and import the Hub GPG key on the Peripheral Server, if…
mcalmer Jan 29, 2025
7d65c50
adapt unit tests for gpg keys
mcalmer Jan 30, 2025
e9ab378
APIs to de-register, replace tokens and update details of ISS server
mcalmer Jan 31, 2025
7c5fe94
unit tests for de-register, replace tokens and update details of ISS …
mcalmer Feb 3, 2025
5c8d3e3
support multiple allowed roles in spark check
mcalmer Feb 5, 2025
10b70e4
specify custom repo fake scc id
mcalmer Feb 6, 2025
c5c2106
disable unused pages in Hub Online Sync case
mcalmer Feb 4, 2025
7a5f657
bump API version 27 to 28
mcalmer Feb 4, 2025
d7b39ae
disable APIs which add channels and org credentials
mcalmer Feb 4, 2025
2947477
fix sonarlint suggestions
mcalmer Feb 7, 2025
51e3365
unit test deny API access
mcalmer Feb 7, 2025
1d365b7
Add a TextArea component
mackdk Feb 14, 2025
6fc63fc
Add index for panels components
mackdk Feb 14, 2025
7134d0b
Added exception for handling invalid responses from the remote server
mackdk Feb 14, 2025
523b78a
Added UI component to perform ISS server registration
mackdk Feb 14, 2025
7c9d96c
Added created/modified date to access tokens
mackdk Feb 14, 2025
8008e13
Add page to manage access tokens
mackdk Feb 14, 2025
5b008e2
Added toggle validity and delete in the token list page
mackdk Feb 14, 2025
3f185a3
Add actions to issue and store tokens
mackdk Feb 14, 2025
7a673c8
Fixed icon spacing in Dropdownbutton when using LinkButton as entries
mackdk Feb 14, 2025
3e5a457
add hub scc endpoint
lucidd Jan 29, 2025
39ee052
add special download route for hubsync using the scc repo id
mcalmer Feb 14, 2025
dcca67d
fix sonarcloud issues
mcalmer Feb 16, 2025
90778d3
set signing repo flag correct for vendor channels
mcalmer Feb 16, 2025
82021d4
make peripheral channel tokens short lived
lucidd Feb 17, 2025
c9ded07
move scc endpoint into the hub namespace
lucidd Feb 18, 2025
5f73a3a
move isSCCCredentials check into CloudPaygManager to break a cyclic d…
mcalmer Feb 18, 2025
7b054bb
Ensure sync hub APIs are responding correctly if a runtime exception …
CDellaGiusta Feb 12, 2025
e75333d
Remove redundand exception catching
CDellaGiusta Feb 12, 2025
022117d
Add addVendorChannel peripheral sync API endpoint
CDellaGiusta Feb 5, 2025
fb79055
Adds missing equals, hashcode, tostring methods to ChannelInfoJson
CDellaGiusta Feb 7, 2025
6389cf7
Adds addCustomChannels peripheral sync API endpoint
CDellaGiusta Feb 7, 2025
0992dc8
Adds modifyCustomChannels peripheral sync API endpoint
CDellaGiusta Feb 18, 2025
a9ec011
Change naming of ISS route accessibility
CDellaGiusta Feb 20, 2025
a2ea972
Add APIs to perform product refresh on the peripheral from the hub
CDellaGiusta Feb 21, 2025
ff86c8c
fixup! Added toggle validity and delete in the token list page
mcalmer Feb 22, 2025
cec6e39
Merge pull request #9831 from mcalmer/issv3-sonarcloud-2
mcalmer Feb 22, 2025
8b1f410
Merge remote-tracking branch 'uyuni-upstream/issv3' into issv3-hub-pe…
Serp1co Feb 22, 2025
6dc7afc
fixup delete peripheral with link (todo with btn...)
Serp1co Feb 22, 2025
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
31 changes: 31 additions & 0 deletions java/code/src/com/redhat/rhn/common/conf/Config.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2024 SUSE LLC
* Copyright (c) 2009--2014 Red Hat, Inc.
*
* This software is licensed to you under the GNU General Public License,
Expand Down Expand Up @@ -282,6 +283,36 @@ public Integer getInteger(String s) {
return Integer.valueOf(val);
}

/**
* get the config entry for string s, if no value is found
* return the defaultValue specified.
*
* @param s string to get the value of
* @param defaultValue Default value if entry is not found.
* @return the value
*/
public long getLong(String s, long defaultValue) {
Long val = getLong(s);
if (val == null) {
return defaultValue;
}
return val;
}

/**
* get the config entry for string s
*
* @param s string to get the value of
* @return the value
*/
public Long getLong(String s) {
String val = getString(s);
if (val == null) {
return null;
}
return Long.valueOf(val);
}

/**
* get the config entry for string s
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
/*
* Copyright (c) 2018 SUSE LLC
* Copyright (c) 2018--2025 SUSE LLC
*
* This software is licensed to you under the GNU General Public License,
* version 2 (GPLv2). There is NO WARRANTY for this software, express or
* implied, including the implied warranties of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
* along with this software; if not, see
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* Red Hat trademarks are not licensed under GPLv2. No permission is
* granted to use or replicate Red Hat trademarks that are incorporated
* in this software or its documentation.
*/
package com.redhat.rhn.common.hibernate;

Expand Down Expand Up @@ -55,6 +51,7 @@
import com.redhat.rhn.domain.contentmgmt.SoftwareProjectSource;
import com.redhat.rhn.domain.credentials.BaseCredentials;
import com.redhat.rhn.domain.credentials.CloudRMTCredentials;
import com.redhat.rhn.domain.credentials.HubSCCCredentials;
import com.redhat.rhn.domain.credentials.RHUICredentials;
import com.redhat.rhn.domain.credentials.RegistryCredentials;
import com.redhat.rhn.domain.credentials.ReportDBCredentials;
Expand Down Expand Up @@ -168,6 +165,10 @@
import com.suse.manager.model.attestation.CoCoResultTypeConverter;
import com.suse.manager.model.attestation.ServerCoCoAttestationConfig;
import com.suse.manager.model.attestation.ServerCoCoAttestationReport;
import com.suse.manager.model.hub.IssAccessToken;
import com.suse.manager.model.hub.IssHub;
import com.suse.manager.model.hub.IssPeripheral;
import com.suse.manager.model.hub.IssPeripheralChannels;
import com.suse.manager.model.maintenance.MaintenanceCalendar;
import com.suse.manager.model.maintenance.MaintenanceSchedule;

Expand Down Expand Up @@ -226,6 +227,7 @@ private AnnotationRegistry() {
EnvironmentTarget.class,
ErrataFilter.class,
GroupRecurringAction.class,
HubSCCCredentials.class,
ImageFile.class,
ImageInfo.class,
ImageInfoCustomDataValue.class,
Expand All @@ -241,7 +243,11 @@ private AnnotationRegistry() {
InstalledPackage.class,
InternalState.class,
InventoryPath.class,
IssAccessToken.class,
IssHub.class,
IssMaster.class,
IssPeripheral.class,
IssPeripheralChannels.class,
KiwiProfile.class,
MaintenanceCalendar.class,
MaintenanceSchedule.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
/*
* Copyright (c) 2015 SUSE LLC
* Copyright (c) 2015--2024 SUSE LLC
*
* This software is licensed to you under the GNU General Public License,
* version 2 (GPLv2). There is NO WARRANTY for this software, express or
* implied, including the implied warranties of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
* along with this software; if not, see
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* Red Hat trademarks are not licensed under GPLv2. No permission is
* granted to use or replicate Red Hat trademarks that are incorporated
* in this software or its documentation.
*/
package com.redhat.rhn.common.util.http;

import com.redhat.rhn.common.conf.Config;
import com.redhat.rhn.common.conf.ConfigDefaults;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpException;
import org.apache.http.HttpHost;
Expand All @@ -34,6 +31,8 @@
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.cookie.Cookie;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.ProxyAuthenticationStrategy;
Expand All @@ -49,9 +48,11 @@
import java.net.URI;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

import javax.net.ssl.SSLContext;
Expand Down Expand Up @@ -101,14 +102,41 @@ public class HttpClientAdapter {

/** The credentials provider. */
private final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();

/**
* The cookie store
*/
private BasicCookieStore cookieStore;

/**
* Initialize an {@link HttpClient} for performing requests. Proxy settings will
* be read from the configuration and applied transparently.
* be read from the configuration and applied transparently. The cookies will not be supported.
*/
public HttpClientAdapter() {
this(List.of(), false);
}

/**
* Initialize an {@link HttpClient} for performing requests. Proxy settings will
* be read from the configuration and applied transparently. The cookies will not be supported.
*
* @param additionalCertificates a list of additional certificate to consider when establishing the connection
*/
public HttpClientAdapter(List<Certificate> additionalCertificates) {
this(additionalCertificates, false);
}

/**
* Initialize an {@link HttpClient} for performing requests. Proxy settings will
* be read from the configuration and applied transparently.
*
* @param allowCookies true, to allow and use cookies.
* @param additionalCertificates a list of additional certificate to consider when establishing the connection
*/
public HttpClientAdapter(List<Certificate> additionalCertificates, boolean allowCookies) {
Optional<SSLConnectionSocketFactory> sslSocketFactory = Optional.empty();
try {
SSLContext sslContext = buildSslSocketContext();
SSLContext sslContext = buildSslSocketContext(additionalCertificates);
List<String> supportedProtocols = Arrays.asList(sslContext.getSupportedSSLParameters().getProtocols());
List<String> wantedProtocols = Arrays.asList("TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3");
wantedProtocols.retainAll(supportedProtocols);
Expand All @@ -129,7 +157,7 @@ public HttpClientAdapter() {
Builder requestConfigBuilder = RequestConfig.custom()
.setConnectTimeout(HttpClientAdapter.getHTTPConnectionTimeout(5))
.setSocketTimeout(HttpClientAdapter.getHTTPSocketTimeout(5 * 60))
.setCookieSpec(CookieSpecs.IGNORE_COOKIES);
.setCookieSpec(allowCookies ? CookieSpecs.STANDARD : CookieSpecs.IGNORE_COOKIES);

// Store the proxy settings
String proxyHostname = ConfigDefaults.get().getProxyHost();
Expand Down Expand Up @@ -170,22 +198,36 @@ public HttpClientAdapter() {
requestConfig = requestConfigBuilder.build();
clientBuilder.setMaxConnPerRoute(Config.get().getInt(MAX_CONNCECTIONS, 1));
clientBuilder.setMaxConnTotal(Config.get().getInt(MAX_CONNCECTIONS, 1));
if (allowCookies) {
cookieStore = new BasicCookieStore();
clientBuilder.setDefaultCookieStore(cookieStore);
}

httpClient = clientBuilder.build();
}

private SSLContext buildSslSocketContext() throws NoSuchAlgorithmException {
private SSLContext buildSslSocketContext(List<Certificate> additionalCertificates) throws NoSuchAlgorithmException {

LOG.info("Started checking for certificates and if it finds the certificates will be loaded...");

String keyStoreLoc = System.getProperty("javax.net.ssl.trustStore",
System.getProperty("java.home") + "/lib/security/cacerts");
String defaultLocation = System.getProperty("java.home") + "/lib/security/cacerts";
String keyStoreLoc = System.getProperty("javax.net.ssl.trustStore", defaultLocation);

SSLContext context;

try (InputStream in = new FileInputStream(keyStoreLoc)) {
// Create a KeyStore containing our trusted CAs
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
keystore.load(in, null);

// Add any additional certificate to the store, if specified
if (CollectionUtils.isNotEmpty(additionalCertificates)) {
int customCert = 0;
for (Certificate certificate : additionalCertificates) {
keystore.setCertificateEntry("additional_certificate_" + customCert++, certificate);
}
}

// Create a TrustManager that trusts the CAs in our KeyStore
String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
Expand Down Expand Up @@ -327,6 +369,25 @@ public HttpResponse executeRequest(HttpRequestBase request, String username,
return executeRequest(request, ignoreNoProxy);
}

/**
* Set the value of a cookie
* @param cookie the cookie
*/
public void setCookie(Cookie cookie) {
cookieStore.addCookie(cookie);
}

/**
* Retrieves the cookies with the specified name from the cookie store.
* @param name the name of the cookie to retrieve
* @return the cookie with a matching name.
*/
public List<Cookie> getCookies(String name) {
return cookieStore.getCookies().stream()
.filter(cookie -> Objects.equals(name, cookie.getName()))
.toList();
}

/**
* Check for a given {@link URI} if a proxy should be used or not.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
/*
* Copyright (c) 2021 SUSE LLC
* Copyright (c) 2021--2024 SUSE LLC
*
* This software is licensed to you under the GNU General Public License,
* version 2 (GPLv2). There is NO WARRANTY for this software, express or
* implied, including the implied warranties of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
* along with this software; if not, see
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* Red Hat trademarks are not licensed under GPLv2. No permission is
* granted to use or replicate Red Hat trademarks that are incorporated
* in this software or its documentation.
*/
package com.redhat.rhn.domain.errata;
package com.redhat.rhn.domain;

import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
Expand Down
75 changes: 75 additions & 0 deletions java/code/src/com/redhat/rhn/domain/DatabaseEnumType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2024--2025 SUSE LLC
*
* This software is licensed to you under the GNU General Public License,
* version 2 (GPLv2). There is NO WARRANTY for this software, express or
* implied, including the implied warranties of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
* along with this software; if not, see
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*/

package com.redhat.rhn.domain;

import java.sql.Types;
import java.util.Arrays;
import java.util.Objects;

/**
* A {@link CustomEnumType} that maps a Java enum to a PostgreSQL enum type.
*
* <p>This type handles the conversion between Java enum values and their corresponding
* string representations in the PostgreSQL database.
*
* <p>If the enum type implements the {@link Labeled} interface, the
* {@link Labeled#getLabel()} method is used to obtain the value stored in the database.
* Otherwise, the standard {@link Enum#name()} method is called.
*
* @param <T> the type of the enum
*/
public abstract class DatabaseEnumType<T extends Enum<T>> extends CustomEnumType<T, String> {

/**
* Construct an instance for the specified enum class.
*
* @param enumClassIn the enum class
*/
protected DatabaseEnumType(Class<T> enumClassIn) {
super(enumClassIn, String.class, e -> getLabel(e), v -> findByLabel(enumClassIn, v));
}

// Converts the given enum constant to the string representation used in the database.
private static <T extends Enum<T>> String getLabel(T value) {
if (value instanceof Labeled labeled) {
return labeled.getLabel();
}

return value.name();
}

/**
* Converts a string value from the database to the proper enum value.
* @param enumType the class of the enum
* @param label the database value
* @return an instance of the specified enum
* @param <T> the enum
*/
public static <T extends Enum<T>> T findByLabel(Class<T> enumType, String label) {
return Arrays.stream(enumType.getEnumConstants())
.filter(e -> Objects.equals(label, getLabel(e)))
.findFirst()
.orElseThrow(
() -> new IllegalArgumentException("Invalid %s value %s".formatted(enumType.getName(), label))
);
}

/**
* {@inheritDoc}
* <p>
* @returns {@link Types#OTHER}, as this instance is mapping the enum values to a PostgreSQL enum.
*/
@Override
public int getSqlType() {
return Types.OTHER;
}
}
4 changes: 3 additions & 1 deletion java/code/src/com/redhat/rhn/domain/Label.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2024 SUSE LLC
* Copyright (c) 2009--2010 Red Hat, Inc.
*
* This software is licensed to you under the GNU General Public License,
Expand Down Expand Up @@ -45,7 +46,7 @@
* @see com.redhat.rhn.domain.server.VirtualInstanceType
*
*/
public abstract class Label {
public abstract class Label implements Labeled {

private Long id;
private String name;
Expand Down Expand Up @@ -84,6 +85,7 @@ private void setName(String newName) {
*
* @return The label text of this label
*/
@Override
public String getLabel() {
return label;
}
Expand Down
Loading
Loading