Skip to content

Commit a35b24c

Browse files
committed
refactor: rename http specific classes
1 parent 7d95403 commit a35b24c

File tree

14 files changed

+100
-95
lines changed

14 files changed

+100
-95
lines changed

gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/main/java/io/gravitee/gateway/reactive/handlers/api/SyncApiReactor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
import io.gravitee.gateway.reactive.handlers.api.flow.FlowChain;
5858
import io.gravitee.gateway.reactive.handlers.api.flow.FlowChainFactory;
5959
import io.gravitee.gateway.reactive.handlers.api.processor.ApiProcessorChainFactory;
60-
import io.gravitee.gateway.reactive.handlers.api.security.SecurityChain;
60+
import io.gravitee.gateway.reactive.handlers.api.security.HttpSecurityChain;
6161
import io.gravitee.gateway.reactive.handlers.api.v4.analytics.logging.LoggingHook;
6262
import io.gravitee.gateway.reactive.policy.PolicyManager;
6363
import io.gravitee.gateway.reactive.reactor.ApiReactor;
@@ -119,7 +119,7 @@ public class SyncApiReactor extends AbstractLifecycleComponent<ReactorHandler> i
119119
private final AtomicInteger pendingRequests = new AtomicInteger(0);
120120
private final long pendingRequestsTimeout;
121121
protected AnalyticsContext analyticsContext;
122-
protected SecurityChain securityChain;
122+
protected HttpSecurityChain httpSecurityChain;
123123

124124
public SyncApiReactor(
125125
final Api api,
@@ -231,7 +231,7 @@ private Completable handleRequest(final MutableExecutionContext ctx) {
231231
// Before Security Chain.
232232
.andThen(executeProcessorChain(ctx, beforeSecurityChainProcessors, REQUEST))
233233
// Execute security chain.
234-
.andThen(securityChain.execute(ctx))
234+
.andThen(httpSecurityChain.execute(ctx))
235235
// Execute before flows processors
236236
.andThen(executeProcessorChain(ctx, beforeApiFlowsProcessors, REQUEST))
237237
.andThen(executeFlowChain(ctx, apiPlanFlowChain, REQUEST))
@@ -430,8 +430,8 @@ protected void doStart() throws Exception {
430430

431431
dumpVirtualHosts();
432432

433-
// Create securityChain once policy manager has been started.
434-
this.securityChain = new SecurityChain(api.getDefinition(), policyManager, REQUEST);
433+
// Create httpSecurityChain once policy manager has been started.
434+
this.httpSecurityChain = new HttpSecurityChain(api.getDefinition(), policyManager, REQUEST);
435435

436436
tracingContext.start();
437437
this.analyticsContext =
@@ -444,7 +444,7 @@ protected void doStart() throws Exception {
444444
processorChainHooks.add(new TracingHook("Processor chain"));
445445
}
446446
invokerHooks.add(new InvokerTracingHook("Invoker"));
447-
securityChain.addHooks(new TracingHook("Security plan"));
447+
httpSecurityChain.addHooks(new TracingHook("Security plan"));
448448
}
449449

450450
long endTime = System.currentTimeMillis(); // Get the end Time

gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/main/java/io/gravitee/gateway/reactive/handlers/api/security/AbstractSecurityChain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public abstract class AbstractSecurityChain<
5050
protected static final String PLAN_RESOLUTION_FAILURE = "GATEWAY_PLAN_RESOLUTION_FAILURE";
5151
protected static final String UNAUTHORIZED_MESSAGE = "Unauthorized";
5252
protected static final String TEMPORARILY_UNAVAILABLE_MESSAGE = "Temporarily Unavailable";
53-
protected static final String ATTR_INTERNAL_PLAN_RESOLUTION_FAILURE = "securityChain.planResolutionFailure";
53+
protected static final String ATTR_INTERNAL_PLAN_RESOLUTION_FAILURE = "httpSecurityChain.planResolutionFailure";
5454

5555
protected static final Single<Boolean> TRUE = Single.just(true);
5656
protected static final Single<Boolean> FALSE = Single.just(false);
Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import io.gravitee.gateway.reactive.api.hook.Hookable;
2424
import io.gravitee.gateway.reactive.api.hook.SecurityPlanHook;
2525
import io.gravitee.gateway.reactive.core.hook.HookHelper;
26-
import io.gravitee.gateway.reactive.handlers.api.security.plan.SecurityPlan;
27-
import io.gravitee.gateway.reactive.handlers.api.security.plan.SecurityPlanFactory;
26+
import io.gravitee.gateway.reactive.handlers.api.security.plan.HttpSecurityPlan;
27+
import io.gravitee.gateway.reactive.handlers.api.security.plan.HttpSecurityPlanFactory;
2828
import io.gravitee.gateway.reactive.policy.PolicyManager;
2929
import io.reactivex.rxjava3.core.Completable;
3030
import io.reactivex.rxjava3.core.Flowable;
@@ -36,36 +36,38 @@
3636
import java.util.stream.Collectors;
3737

3838
/**
39-
* {@link SecurityChain} is a special chain dedicated to execute policy associated with plans.
40-
* The security chain is responsible to create {@link SecurityPlan} for each plan of the api and executed them in order.
41-
* Only the first {@link SecurityPlan} that can handle the current request is executed.
42-
* The result of the security chain execution depends on this {@link SecurityPlan} execution.
39+
* {@link HttpSecurityChain} is a special chain dedicated to execute policy associated with plans.
40+
* The security chain is responsible to create {@link HttpSecurityPlan} for each plan of the api and executed them in order.
41+
* Only the first {@link HttpSecurityPlan} that can handle the current request is executed.
42+
* The result of the security chain execution depends on this {@link HttpSecurityPlan} execution.
4343
*
4444
* @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com)
4545
* @author GraviteeSource Team
4646
*/
47-
public class SecurityChain extends AbstractSecurityChain<SecurityPlan, HttpPlainExecutionContext> implements Hookable<SecurityPlanHook> {
47+
public class HttpSecurityChain
48+
extends AbstractSecurityChain<HttpSecurityPlan, HttpPlainExecutionContext>
49+
implements Hookable<SecurityPlanHook> {
4850

4951
private final ExecutionPhase executionPhase;
5052

5153
private List<SecurityPlanHook> securityPlanHooks;
5254

53-
public SecurityChain(Api api, PolicyManager policyManager, ExecutionPhase executionPhase) {
55+
public HttpSecurityChain(Api api, PolicyManager policyManager, ExecutionPhase executionPhase) {
5456
super(
5557
Flowable.fromIterable(
5658
api
5759
.getPlans()
5860
.stream()
59-
.map(plan -> SecurityPlanFactory.forPlan(plan, policyManager))
61+
.map(plan -> HttpSecurityPlanFactory.forPlan(plan, policyManager))
6062
.filter(Objects::nonNull)
61-
.sorted(Comparator.comparingInt(SecurityPlan::order))
63+
.sorted(Comparator.comparingInt(HttpSecurityPlan::order))
6264
.collect(Collectors.toList())
6365
)
6466
);
6567
this.executionPhase = executionPhase;
6668
}
6769

68-
public SecurityChain(Flowable<SecurityPlan> securityPlans, ExecutionPhase executionPhase) {
70+
public HttpSecurityChain(Flowable<HttpSecurityPlan> securityPlans, ExecutionPhase executionPhase) {
6971
super(securityPlans);
7072
this.executionPhase = executionPhase;
7173
}
@@ -76,11 +78,11 @@ protected Completable sendError(HttpPlainExecutionContext ctx, ExecutionFailure
7678
}
7779

7880
@Override
79-
protected Single<Boolean> executePlan(SecurityPlan securityPlan, HttpPlainExecutionContext ctx) {
81+
protected Single<Boolean> executePlan(HttpSecurityPlan httpSecurityPlan, HttpPlainExecutionContext ctx) {
8082
return HookHelper
8183
.hook(
82-
() -> securityPlan.execute(ctx, executionPhase),
83-
securityPlan.id(),
84+
() -> httpSecurityPlan.execute(ctx, executionPhase),
85+
httpSecurityPlan.id(),
8486
securityPlanHooks,
8587
(HttpExecutionContext) ctx,
8688
executionPhase
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import jakarta.annotation.Nonnull;
2525

2626
/**
27-
* {@link SecurityPlan} allows to wrap a {@link io.gravitee.gateway.reactive.api.policy.http.HttpPolicy} implementing {@link HttpSecurityPolicy} and make it working in a security chain.
27+
* {@link HttpSecurityPlan} allows to wrap a {@link io.gravitee.gateway.reactive.api.policy.http.HttpPolicy} implementing {@link HttpSecurityPolicy} and make it working in a security chain.
2828
* Security plan is responsible to
2929
* <ul>
3030
* <li>Check if a policy can handle the security or not</li>
@@ -36,9 +36,9 @@
3636
* @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com)
3737
* @author GraviteeSource Team
3838
*/
39-
public class SecurityPlan extends AbstractSecurityPlan<HttpSecurityPolicy, HttpPlainExecutionContext> {
39+
public class HttpSecurityPlan extends AbstractSecurityPlan<HttpSecurityPolicy, HttpPlainExecutionContext> {
4040

41-
public SecurityPlan(@Nonnull final String planId, @Nonnull final HttpSecurityPolicy policy, final String selectionRule) {
41+
public HttpSecurityPlan(@Nonnull final String planId, @Nonnull final HttpSecurityPolicy policy, final String selectionRule) {
4242
super(planId, policy, selectionRule);
4343
}
4444

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@
2828
* @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com)
2929
* @author GraviteeSource Team
3030
*/
31-
public class SecurityPlanFactory {
31+
public class HttpSecurityPlanFactory {
3232

33-
private static final Logger log = LoggerFactory.getLogger(SecurityPlanFactory.class);
33+
private static final Logger log = LoggerFactory.getLogger(HttpSecurityPlanFactory.class);
3434

35-
private SecurityPlanFactory() {}
35+
private HttpSecurityPlanFactory() {}
3636

3737
@Nullable
38-
public static SecurityPlan forPlan(@Nonnull Plan plan, @Nonnull PolicyManager policyManager) {
38+
public static HttpSecurityPlan forPlan(@Nonnull Plan plan, @Nonnull PolicyManager policyManager) {
3939
final HttpSecurityPolicy policy = SecurityPolicyFactory.forPlan(plan, policyManager);
4040

4141
if (policy != null) {
42-
return new SecurityPlan(plan.getId(), policy, plan.getSelectionRule());
42+
return new HttpSecurityPlan(plan.getId(), policy, plan.getSelectionRule());
4343
}
4444

4545
log.warn(

gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/main/java/io/gravitee/gateway/reactive/handlers/api/v4/DefaultApiReactor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
import io.gravitee.gateway.reactive.handlers.api.v4.flow.FlowChain;
5858
import io.gravitee.gateway.reactive.handlers.api.v4.flow.FlowChainFactory;
5959
import io.gravitee.gateway.reactive.handlers.api.v4.processor.ApiProcessorChainFactory;
60-
import io.gravitee.gateway.reactive.handlers.api.v4.security.SecurityChain;
60+
import io.gravitee.gateway.reactive.handlers.api.v4.security.HttpSecurityChain;
6161
import io.gravitee.gateway.reactive.policy.PolicyManager;
6262
import io.gravitee.gateway.reactor.handler.Acceptor;
6363
import io.gravitee.gateway.reactor.handler.AccessPointHttpAcceptor;
@@ -124,7 +124,7 @@ public class DefaultApiReactor extends AbstractApiReactor {
124124
protected final String loggingExcludedResponseType;
125125
protected final String loggingMaxSize;
126126
private final DeploymentContext deploymentContext;
127-
protected SecurityChain securityChain;
127+
protected HttpSecurityChain httpSecurityChain;
128128
private Lifecycle.State lifecycleState;
129129
protected AnalyticsContext analyticsContext;
130130
private List<ApiService> services;
@@ -250,7 +250,7 @@ protected Completable handleRequest(final MutableExecutionContext ctx) {
250250
// Before Security Chain.
251251
.chainWith(executeProcessorChain(ctx, beforeSecurityChainProcessors, REQUEST))
252252
// Execute security chain.
253-
.chainWith(securityChain.execute(ctx))
253+
.chainWith(httpSecurityChain.execute(ctx))
254254
// Before flows processors.
255255
.chainWith(executeProcessorChain(ctx, beforeApiExecutionProcessors, REQUEST))
256256
// Resolve entrypoint and prepare request to be handled.
@@ -472,8 +472,8 @@ protected void doStart() throws Exception {
472472
resourceLifecycleManager.start();
473473
policyManager.start();
474474

475-
// Create securityChain once policy manager has been started.
476-
securityChain = new SecurityChain(api.getDefinition(), policyManager, ExecutionPhase.REQUEST);
475+
// Create httpSecurityChain once policy manager has been started.
476+
httpSecurityChain = new HttpSecurityChain(api.getDefinition(), policyManager, ExecutionPhase.REQUEST);
477477

478478
tracingContext.start();
479479
analyticsContext = analyticsContext();
@@ -487,7 +487,7 @@ protected void doStart() throws Exception {
487487
processorChainHooks.add(new TracingHook("Processor chain"));
488488
}
489489
invokerHooks.add(new InvokerTracingHook("Invoker"));
490-
securityChain.addHooks(new TracingHook("Security"));
490+
httpSecurityChain.addHooks(new TracingHook("Security"));
491491
}
492492
}
493493
addInvokerHooks(invokerHooks);
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
import io.gravitee.definition.model.v4.Api;
1919
import io.gravitee.gateway.reactive.api.ExecutionPhase;
20-
import io.gravitee.gateway.reactive.handlers.api.security.plan.SecurityPlan;
21-
import io.gravitee.gateway.reactive.handlers.api.v4.security.plan.SecurityPlanFactory;
20+
import io.gravitee.gateway.reactive.handlers.api.security.plan.HttpSecurityPlan;
21+
import io.gravitee.gateway.reactive.handlers.api.v4.security.plan.HttpSecurityPlanFactory;
2222
import io.gravitee.gateway.reactive.policy.PolicyManager;
2323
import io.reactivex.rxjava3.core.Flowable;
2424
import jakarta.annotation.Nonnull;
@@ -34,15 +34,19 @@
3434
* @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com)
3535
* @author GraviteeSource Team
3636
*/
37-
public class SecurityChain extends io.gravitee.gateway.reactive.handlers.api.security.SecurityChain {
37+
public class HttpSecurityChain extends io.gravitee.gateway.reactive.handlers.api.security.HttpSecurityChain {
3838

39-
public SecurityChain(@Nonnull final Api api, @Nonnull final PolicyManager policyManager, @Nonnull final ExecutionPhase executionPhase) {
39+
public HttpSecurityChain(
40+
@Nonnull final Api api,
41+
@Nonnull final PolicyManager policyManager,
42+
@Nonnull final ExecutionPhase executionPhase
43+
) {
4044
super(
4145
Flowable.fromIterable(
4246
stream(api.getPlans())
43-
.map(plan -> SecurityPlanFactory.forPlan(api.getId(), plan, policyManager, executionPhase))
47+
.map(plan -> HttpSecurityPlanFactory.forPlan(api.getId(), plan, policyManager, executionPhase))
4448
.filter(Objects::nonNull)
45-
.sorted(Comparator.comparingInt(SecurityPlan::order))
49+
.sorted(Comparator.comparingInt(HttpSecurityPlan::order))
4650
.collect(Collectors.toList())
4751
),
4852
executionPhase
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import io.gravitee.definition.model.v4.plan.AbstractPlan;
1919
import io.gravitee.gateway.reactive.api.ExecutionPhase;
2020
import io.gravitee.gateway.reactive.api.policy.http.HttpSecurityPolicy;
21-
import io.gravitee.gateway.reactive.handlers.api.security.plan.SecurityPlan;
21+
import io.gravitee.gateway.reactive.handlers.api.security.plan.HttpSecurityPlan;
2222
import io.gravitee.gateway.reactive.handlers.api.v4.security.policy.SecurityPolicyFactory;
2323
import io.gravitee.gateway.reactive.policy.PolicyManager;
2424
import jakarta.annotation.Nonnull;
@@ -30,12 +30,12 @@
3030
* @author GraviteeSource Team
3131
*/
3232
@Slf4j
33-
public class SecurityPlanFactory {
33+
public class HttpSecurityPlanFactory {
3434

35-
private SecurityPlanFactory() {}
35+
private HttpSecurityPlanFactory() {}
3636

3737
@Nullable
38-
public static SecurityPlan forPlan(
38+
public static HttpSecurityPlan forPlan(
3939
@Nonnull final String apiId,
4040
@Nonnull AbstractPlan plan,
4141
@Nonnull PolicyManager policyManager,
@@ -49,7 +49,7 @@ public static SecurityPlan forPlan(
4949
final HttpSecurityPolicy policy = SecurityPolicyFactory.forPlan(apiId, plan, policyManager, executionPhase);
5050

5151
if (policy != null) {
52-
return new SecurityPlan(plan.getId(), policy, plan.getSelectionRule());
52+
return new HttpSecurityPlan(plan.getId(), policy, plan.getSelectionRule());
5353
}
5454

5555
log.warn(

0 commit comments

Comments
 (0)