Skip to content

Commit a9ec011

Browse files
CDellaGiustamcalmer
authored andcommitted
Change naming of ISS route accessibility
1 parent 0992dc8 commit a9ec011

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

java/code/src/com/suse/manager/hub/HubController.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
package com.suse.manager.hub;
1313

14-
import static com.suse.manager.hub.HubSparkHelper.allowingOnlyHub;
15-
import static com.suse.manager.hub.HubSparkHelper.allowingOnlyRegistered;
16-
import static com.suse.manager.hub.HubSparkHelper.allowingOnlyUnregistered;
14+
import static com.suse.manager.hub.HubSparkHelper.onlyFromHub;
15+
import static com.suse.manager.hub.HubSparkHelper.onlyFromRegistered;
16+
import static com.suse.manager.hub.HubSparkHelper.onlyFromUnregistered;
1717
import static com.suse.manager.hub.HubSparkHelper.usingTokenAuthentication;
1818
import static com.suse.manager.webui.utils.SparkApplicationHelper.asJson;
1919
import static com.suse.manager.webui.utils.SparkApplicationHelper.badRequest;
@@ -90,26 +90,26 @@ public HubController(HubManager hubManagerIn) {
9090
*/
9191
public void initRoutes() {
9292
post("/hub/ping", asJson(usingTokenAuthentication(this::ping)));
93-
post("/hub/sync/deregister", asJson(usingTokenAuthentication(allowingOnlyRegistered(this::deregister))));
94-
post("/hub/sync/registerHub", asJson(usingTokenAuthentication(allowingOnlyUnregistered(this::registerHub))));
95-
post("/hub/sync/replaceTokens", asJson(usingTokenAuthentication(allowingOnlyHub(this::replaceTokens))));
96-
post("/hub/sync/storeCredentials", asJson(usingTokenAuthentication(allowingOnlyHub(this::storeCredentials))));
97-
post("/hub/sync/setHubDetails", asJson(usingTokenAuthentication(allowingOnlyHub(this::setHubDetails))));
98-
get("/hub/managerinfo", asJson(usingTokenAuthentication(allowingOnlyHub(this::getManagerInfo))));
93+
post("/hub/sync/deregister", asJson(usingTokenAuthentication(onlyFromRegistered(this::deregister))));
94+
post("/hub/sync/registerHub", asJson(usingTokenAuthentication(onlyFromUnregistered(this::registerHub))));
95+
post("/hub/sync/replaceTokens", asJson(usingTokenAuthentication(onlyFromHub(this::replaceTokens))));
96+
post("/hub/sync/storeCredentials", asJson(usingTokenAuthentication(onlyFromHub(this::storeCredentials))));
97+
post("/hub/sync/setHubDetails", asJson(usingTokenAuthentication(onlyFromHub(this::setHubDetails))));
98+
get("/hub/managerinfo", asJson(usingTokenAuthentication(onlyFromHub(this::getManagerInfo))));
9999
post("/hub/storeReportDbCredentials",
100-
asJson(usingTokenAuthentication(allowingOnlyHub(this::setReportDbCredentials))));
100+
asJson(usingTokenAuthentication(onlyFromHub(this::setReportDbCredentials))));
101101
post("/hub/removeReportDbCredentials",
102-
asJson(usingTokenAuthentication(allowingOnlyHub(this::removeReportDbCredentials))));
102+
asJson(usingTokenAuthentication(onlyFromHub(this::removeReportDbCredentials))));
103103
get("/hub/listAllPeripheralOrgs",
104-
asJson(usingTokenAuthentication(allowingOnlyHub(this::listAllPeripheralOrgs))));
104+
asJson(usingTokenAuthentication(onlyFromHub(this::listAllPeripheralOrgs))));
105105
get("/hub/listAllPeripheralChannels",
106-
asJson(usingTokenAuthentication(allowingOnlyHub(this::listAllPeripheralChannels))));
106+
asJson(usingTokenAuthentication(onlyFromHub(this::listAllPeripheralChannels))));
107107
post("/hub/addVendorChannels",
108-
asJson(usingTokenAuthentication(allowingOnlyHub(this::addVendorChannels))));
108+
asJson(usingTokenAuthentication(onlyFromHub(this::addVendorChannels))));
109109
post("/hub/addCustomChannels",
110-
asJson(usingTokenAuthentication(allowingOnlyHub(this::addCustomChannels))));
110+
asJson(usingTokenAuthentication(onlyFromHub(this::addCustomChannels))));
111111
post("/hub/modifyCustomChannels",
112-
asJson(usingTokenAuthentication(allowingOnlyHub(this::modifyCustomChannels))));
112+
asJson(usingTokenAuthentication(onlyFromHub(this::modifyCustomChannels))));
113113
}
114114

115115
private String setHubDetails(Request request, Response response, IssAccessToken accessToken) {

java/code/src/com/suse/manager/hub/HubSparkHelper.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,38 +114,38 @@ else if (!fqdn.equals(issuedToken.getServerFqdn())) {
114114
* @param route the route
115115
* @return the route
116116
*/
117-
public static RouteWithHubToken allowingOnlyHub(RouteWithHubToken route) {
118-
return allowingOnly(List.of(IssRole.HUB), route);
117+
public static RouteWithHubToken onlyFromHub(RouteWithHubToken route) {
118+
return onlyFrom(List.of(IssRole.HUB), route);
119119
}
120120

121121
/**
122122
* Use in ISS routes only accessible from a peripheral
123123
* @param route the route
124124
* @return the route
125125
*/
126-
public static RouteWithHubToken allowingOnlyPeripheral(RouteWithHubToken route) {
127-
return allowingOnly(List.of(IssRole.PERIPHERAL), route);
126+
public static RouteWithHubToken onlyFromPeripheral(RouteWithHubToken route) {
127+
return onlyFrom(List.of(IssRole.PERIPHERAL), route);
128128
}
129129

130130
/**
131131
* Use in ISS routes only accessible from a registered server
132132
* @param route the route
133133
* @return the route
134134
*/
135-
public static RouteWithHubToken allowingOnlyRegistered(RouteWithHubToken route) {
136-
return allowingOnly(List.of(IssRole.HUB, IssRole.PERIPHERAL), route);
135+
public static RouteWithHubToken onlyFromRegistered(RouteWithHubToken route) {
136+
return onlyFrom(List.of(IssRole.HUB, IssRole.PERIPHERAL), route);
137137
}
138138

139139
/**
140140
* Use in ISS routes only accessible from an unregistered server
141141
* @param route the route
142142
* @return the route
143143
*/
144-
public static RouteWithHubToken allowingOnlyUnregistered(RouteWithHubToken route) {
145-
return allowingOnly(List.of(), route);
144+
public static RouteWithHubToken onlyFromUnregistered(RouteWithHubToken route) {
145+
return onlyFrom(List.of(), route);
146146
}
147147

148-
private static RouteWithHubToken allowingOnly(List<IssRole> allowedRoles, RouteWithHubToken route) {
148+
private static RouteWithHubToken onlyFrom(List<IssRole> allowedRoles, RouteWithHubToken route) {
149149
return (request, response, issAccessToken) -> {
150150
String fqdn = issAccessToken.getServerFqdn();
151151
Optional<IssHub> issHub = HUB_FACTORY.lookupIssHubByFqdn(fqdn);

0 commit comments

Comments
 (0)