Skip to content

Commit b13deb7

Browse files
authored
[secure-mode] Refactor secure mode plugin (#2058)
1 parent 9f484df commit b13deb7

File tree

7 files changed

+262
-397
lines changed

7 files changed

+262
-397
lines changed

jacoco/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies {
1616
jacocoAggregation(project(":plugins:kserve"))
1717
// jacocoAggregation(project(":plugins:management-console"))
1818
jacocoAggregation(project(":plugins:plugin-management-plugin"))
19+
jacocoAggregation(project(":plugins:secure-mode"))
1920
jacocoAggregation(project(":plugins:static-file-plugin"))
2021
jacocoAggregation(project(":prometheus"))
2122
jacocoAggregation(project(":serving"))

plugins/secure-mode/src/main/java/ai/djl/serving/plugins/securemode/SecureModeModelServerListener.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,21 @@
1212
*/
1313
package ai.djl.serving.plugins.securemode;
1414

15-
import ai.djl.Device;
16-
import ai.djl.ModelException;
15+
import ai.djl.serving.http.IllegalConfigurationException;
1716
import ai.djl.serving.wlm.ModelInfo;
1817
import ai.djl.serving.wlm.util.ModelServerListenerAdapter;
1918

2019
import java.io.IOException;
21-
import java.net.URISyntaxException;
2220

2321
class SecureModeModelServerListener extends ModelServerListenerAdapter {
2422

23+
/** {@inheritDoc} */
2524
@Override
26-
public void onModelLoading(ModelInfo<?, ?> model, Device device) {
27-
super.onModelLoading(model, device);
28-
29-
if (SecureModeUtils.isSecureMode()) {
30-
try {
31-
SecureModeUtils.validateSecurity();
32-
SecureModeUtils.reconcileSources(model.getModelUrl());
33-
} catch (ModelException e) {
34-
throw new IllegalConfigurationException("Secure Mode check failed", e);
35-
} catch (IOException | URISyntaxException e) {
36-
throw new IllegalConfigurationException(
37-
"Error while running Secure Mode checks", e);
38-
}
25+
public void onModelConfigured(ModelInfo<?, ?> model) {
26+
try {
27+
SecureModeUtils.validateSecurity(model);
28+
} catch (IOException e) {
29+
throw new IllegalConfigurationException("Error while running Secure Mode checks", e);
3930
}
4031
}
4132
}

0 commit comments

Comments
 (0)