Skip to content

Commit

Permalink
disable APIs which add channels and org credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
mcalmer committed Feb 6, 2025
1 parent 310c170 commit f15dba4
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.redhat.rhn.manager.setup.MirrorCredentialsManager;

import com.suse.manager.api.ReadOnly;
import com.suse.manager.model.hub.HubFactory;

import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -197,6 +198,11 @@ public Integer synchronizeRepositories(User loggedInUser, String mirrorUrl) thro
public Integer addChannel(User loggedInUser, String channelLabel, String mirrorUrl)
throws ContentSyncException {
ensureSatAdmin(loggedInUser);
HubFactory hubFactory = new HubFactory();
if (hubFactory.isISSPeripheral()) {
throw new ContentSyncException("This is an ISS Peripheral Server. " +
"Managing channels is disabled and can only be done from the Hub Server.");
}
ContentSyncManager csm = new ContentSyncManager();
if (csm.isRefreshNeeded(mirrorUrl)) {
throw new ContentSyncException("Product Data refresh needed. Please call mgr-sync refresh.");
Expand All @@ -223,6 +229,11 @@ public Integer addChannel(User loggedInUser, String channelLabel, String mirrorU
public Object[] addChannels(User loggedInUser, String channelLabel, String mirrorUrl)
throws ContentSyncException {
ensureSatAdmin(loggedInUser);
HubFactory hubFactory = new HubFactory();
if (hubFactory.isISSPeripheral()) {
throw new ContentSyncException("This is an ISS Peripheral Server. " +
"Managing channels is disabled and can only be done from the Hub Server.");
}
ContentSyncManager csm = new ContentSyncManager();
if (csm.isRefreshNeeded(mirrorUrl)) {
throw new ContentSyncException("Product Data refresh needed. Please call mgr-sync refresh.");
Expand Down Expand Up @@ -268,6 +279,10 @@ public Object[] addChannels(User loggedInUser, String channelLabel, String mirro
public Integer addCredentials(User loggedInUser, String username, String password,
boolean primary) throws ContentSyncException {
ensureSatAdmin(loggedInUser);
HubFactory hubFactory = new HubFactory();
if (hubFactory.isISSPeripheral()) {
throw new ContentSyncException("This is an ISS Peripheral Server. Managing credentials is disabled.");
}
MirrorCredentialsDto creds = new MirrorCredentialsDto(username, password);
MirrorCredentialsManager credsManager = new MirrorCredentialsManager();
long id = credsManager.storeMirrorCredentials(creds, null);
Expand All @@ -293,6 +308,10 @@ public Integer addCredentials(User loggedInUser, String username, String passwor
public Integer deleteCredentials(User loggedInUser, String username)
throws ContentSyncException {
ensureSatAdmin(loggedInUser);
HubFactory hubFactory = new HubFactory();
if (hubFactory.isISSPeripheral()) {
throw new ContentSyncException("This is an ISS Peripheral Server. Managing credentials is disabled.");
}
for (SCCCredentials c : CredentialsFactory.listSCCCredentials()) {
if (c.getUsername().equals(username)) {
new MirrorCredentialsManager().deleteMirrorCredentials(c.getId(), null);
Expand Down

0 comments on commit f15dba4

Please sign in to comment.