Skip to content

Commit

Permalink
several fixes and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rjpmestre committed Feb 21, 2025
1 parent ff29e9e commit a0952ea
Show file tree
Hide file tree
Showing 42 changed files with 2,911 additions and 572 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,12 @@
<context context-type="sourcefile">Navigation Menu</context>
</context-group>
</trans-unit>
<trans-unit id="Clients" xml:space="preserve">
<source>Clients</source>
<context-group name="ctx">
<context context-type="sourcefile">Navigation Menu</context>
</context-group>
</trans-unit>
<trans-unit id="Activation" xml:space="preserve">
<source>Activation</source>
<context-group name="ctx">
Expand Down
12 changes: 8 additions & 4 deletions java/code/src/com/redhat/rhn/manager/system/SystemManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@
import com.redhat.rhn.manager.system.entitling.SystemEntitlementManager;
import com.redhat.rhn.manager.system.entitling.SystemEntitler;
import com.redhat.rhn.manager.system.entitling.SystemUnentitler;
import com.redhat.rhn.manager.system.proxycontainerconfig.ProxyContainerConfigCreate;
import com.redhat.rhn.manager.system.proxycontainerconfig.ProxyContainerConfigCreateFacade;
import com.redhat.rhn.manager.system.proxycontainerconfig.ProxyContainerConfigCreateFacadeImpl;
import com.redhat.rhn.manager.user.UserManager;
import com.redhat.rhn.taskomatic.task.systems.SystemsOverviewUpdateDriver;
import com.redhat.rhn.taskomatic.task.systems.SystemsOverviewUpdateWorker;
Expand Down Expand Up @@ -192,6 +193,7 @@ public class SystemManager extends BaseManager {
private SaltApi saltApi;
private ServerFactory serverFactory;
private ServerGroupFactory serverGroupFactory;
private ProxyContainerConfigCreateFacade proxyContainerConfigCreateFacade;

/**
* Instantiates a new system manager.
Expand All @@ -211,6 +213,7 @@ public SystemManager(ServerFactory serverFactoryIn, ServerGroupFactory serverGro
new SystemUnentitler(monitoringManager, serverGroupManager),
new SystemEntitler(saltApiIn, monitoringManager, serverGroupManager)
);
this.proxyContainerConfigCreateFacade = new ProxyContainerConfigCreateFacadeImpl();
}

/**
Expand Down Expand Up @@ -2156,7 +2159,7 @@ public byte[] createProxyContainerConfig(User user, String proxyName, Integer pr
SSLCertManager certManager)
throws SSLCertGenerationException {

return new ProxyContainerConfigCreate().create(
return proxyContainerConfigCreateFacade.create(
saltApi, systemEntitlementManager, user, server, proxyName, proxyPort, maxCache, email,
rootCA, intermediateCAs, proxyCertKey, caPair, caPassword, certData, certManager);
}
Expand Down Expand Up @@ -2191,9 +2194,10 @@ public Map<String, Object> createProxyContainerConfigFiles(
SSLCertPair caPair, String caPassword, SSLCertData certData,
SSLCertManager certManager
) throws SSLCertGenerationException {
return new ProxyContainerConfigCreate().createFiles(
return this.proxyContainerConfigCreateFacade.createFiles(
saltApi, systemEntitlementManager, user, server, proxyName, proxyPort, maxCache, email,
rootCA, intermediateCAs, proxyCertKey, caPair, caPassword, certData, certManager);
rootCA, intermediateCAs, proxyCertKey, caPair, caPassword, certData, certManager
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright (c) 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.manager.system.proxycontainerconfig;

import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.manager.system.entitling.SystemEntitlementManager;

import com.suse.manager.ssl.SSLCertData;
import com.suse.manager.ssl.SSLCertManager;
import com.suse.manager.ssl.SSLCertPair;
import com.suse.manager.webui.services.iface.SaltApi;

import java.util.List;
import java.util.Map;

public interface ProxyContainerConfigCreateFacade {

/**
* Create and provide proxy container configuration.
*
* @param saltApi the Salt API instance
* @param systemEntitlementManager the system entitlement manager instance
* @param user the current user
* @param serverFqdn the FQDN of the server the proxy uses
* @param proxyFqdn the FQDN of the proxy
* @param proxyPort the SSH port the proxy listens on
* @param maxCache the maximum memory cache size
* @param email the email of proxy admin
* @param rootCA root CA used to sign the SSL certificate in PEM format
* @param intermediateCAs intermediate CAs used to sign the SSL certificate in PEM format
* @param proxyCertKey proxy CRT and key pair
* @param caPair the CA certificate and key used to sign the certificate to generate.
* Can be omitted if proxyCertKey is not provided
* @param caPassword the CA private key password.
* Can be omitted if proxyCertKey is not provided
* @param certData the data needed to generate the new proxy SSL certificate.
* Can be omitted if proxyCertKey is not provided
* @param certManager the SSLCertManager to use
* @return the tarball configuration file as a byte array
*/
byte[] create(
SaltApi saltApi, SystemEntitlementManager systemEntitlementManager, User user,
String serverFqdn, String proxyFqdn, Integer proxyPort, Long maxCache, String email,
String rootCA, List<String> intermediateCAs, SSLCertPair proxyCertKey,
SSLCertPair caPair, String caPassword, SSLCertData certData, SSLCertManager certManager
);

/**
* Create and provide proxy container configuration files.
*
* @param saltApi the Salt API instance
* @param systemEntitlementManager the system entitlement manager instance
* @param user the current user
* @param serverFqdn the FQDN of the server the proxy uses
* @param proxyFqdn the FQDN of the proxy
* @param proxyPort the SSH port the proxy listens on
* @param maxCache the maximum memory cache size
* @param email the email of proxy admin
* @param rootCA root CA used to sign the SSL certificate in PEM format
* @param intermediateCAs intermediate CAs used to sign the SSL certificate in PEM format
* @param proxyCertKey proxy CRT and key pair
* @param caPair the CA certificate and key used to sign the certificate to generate.
* Can be omitted if proxyCertKey is not provided
* @param caPassword the CA private key password.
* Can be omitted if proxyCertKey is not provided
* @param certData the data needed to generate the new proxy SSL certificate.
* Can be omitted if proxyCertKey is not provided
* @param certManager the SSLCertManager to use
* @return the configuration files as a map
*/
Map<String, Object> createFiles(
SaltApi saltApi, SystemEntitlementManager systemEntitlementManager, User user,
String serverFqdn, String proxyFqdn, Integer proxyPort, Long maxCache, String email,
String rootCA, List<String> intermediateCAs, SSLCertPair proxyCertKey,
SSLCertPair caPair, String caPassword, SSLCertData certData, SSLCertManager certManager
);

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,23 @@
/**
* Main handler for creating proxy container configuration files.
* Three files should be created and compressed into a tarball:
* - config.yaml : yaml configuration file that contains the server FQDN, max cache size, email, server version,
* proxy FQDN, and root CA
* - httpd.yaml : yaml file containing the system ID, server certificate, and server key
* - ssh.yaml : yaml file containing the server SSH public key, proxy SSH key, and proxy SSH public key
*
* - config.yaml : yaml configuration file that contains the server FQDN, max cache size, email, server version,
* proxy FQDN, and root CA
* - httpd.yaml : yaml file containing the system ID, server certificate, and server key
* - ssh.yaml : yaml file containing the server SSH public key, proxy SSH key, and proxy SSH public key
* <p>
* This flow is divided into three main steps:
* - Acquire and validate all necessary data
* - Compute contents for files
* - Create tar archive with all necessary files
*
*/
public class ProxyContainerConfigCreate {
public class ProxyContainerConfigCreateFacadeImpl implements ProxyContainerConfigCreateFacade {
private final List<ProxyContainerConfigCreateContextHandler> contextHandlerChain = new ArrayList<>();

/**
* Constructor
*/
public ProxyContainerConfigCreate() {
public ProxyContainerConfigCreateFacadeImpl() {
this.contextHandlerChain.addAll(asList(
new ProxyContainerConfigCreateAcquisitor(),
new ProxyContainerConfigCreateGenerateFileMaps(),
Expand Down Expand Up @@ -81,6 +80,7 @@ public ProxyContainerConfigCreate() {
* @param certManager the SSLCertManager to use
* @return the tarball configuration file as a byte array
*/
@Override
public byte[] create(
SaltApi saltApi, SystemEntitlementManager systemEntitlementManager, User user,
String serverFqdn, String proxyFqdn, Integer proxyPort, Long maxCache, String email,
Expand Down Expand Up @@ -120,6 +120,7 @@ public byte[] create(
* @param certManager the SSLCertManager to use
* @return the configuration files as a map
*/
@Override
public Map<String, Object> createFiles(
SaltApi saltApi, SystemEntitlementManager systemEntitlementManager, User user,
String serverFqdn, String proxyFqdn, Integer proxyPort, Long maxCache, String email,
Expand Down
Loading

0 comments on commit a0952ea

Please sign in to comment.