changeset 1049:0edcfd3d256d

ProviderContext removed
author Devel 1
date Tue, 14 Apr 2020 16:06:52 +0200
parents 0b0971546a00
children a7a719af3302
files stress-tester/src/main/java/com/passus/st/client/credentials/CredentialsProvider.java stress-tester/src/main/java/com/passus/st/client/credentials/CsvUsernamePasswordCredentialsProvider.java stress-tester/src/main/java/com/passus/st/client/credentials/MultiCredentialsProvider.java stress-tester/src/main/java/com/passus/st/client/credentials/SingleCredentialsProvider.java stress-tester/src/main/java/com/passus/st/client/credentials/UsernamePasswordCredentialsProvider.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpAbstractLoginFilter.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpBasicAuthLoginFilter.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpDigestAuthLoginFilter.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFormLoginFilter.java stress-tester/src/main/java/com/passus/st/client/pgsql/filter/PgSqlLoginFilter.java
diffstat 10 files changed, 17 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/credentials/CredentialsProvider.java	Tue Apr 14 15:45:01 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/credentials/CredentialsProvider.java	Tue Apr 14 16:06:52 2020 +0200
@@ -1,9 +1,7 @@
 package com.passus.st.client.credentials;
 
 import com.passus.config.Configurable;
-import com.passus.net.http.HttpRequest;
-import com.passus.net.http.HttpResponse;
-import com.passus.st.emitter.SessionInfo;
+import com.passus.st.client.FlowContext;
 
 /**
  *
@@ -13,37 +11,6 @@
 
     public String getType();
     
-    public Credentials getCredentials(ProviderContext context);
-
-    public static class ProviderContext {
-
-        private final HttpRequest req;
-        private final HttpResponse resp;
-        private final HttpResponse origResp;
-        private final SessionInfo session;
-
-        public ProviderContext(HttpRequest req, HttpResponse resp, HttpResponse origResp, SessionInfo session) {
-            this.req = req;
-            this.resp = resp;
-            this.origResp = origResp;
-            this.session = session;
-        }
+    public Credentials getCredentials(FlowContext context);
 
-        public HttpRequest getReq() {
-            return req;
-        }
-
-        public HttpResponse getResp() {
-            return resp;
-        }
-
-        public HttpResponse getOrigResp() {
-            return origResp;
-        }
-
-        public SessionInfo getSession() {
-            return session;
-        }
-
-    }
 }
--- a/stress-tester/src/main/java/com/passus/st/client/credentials/CsvUsernamePasswordCredentialsProvider.java	Tue Apr 14 15:45:01 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/credentials/CsvUsernamePasswordCredentialsProvider.java	Tue Apr 14 16:06:52 2020 +0200
@@ -12,6 +12,7 @@
 import static com.passus.config.schema.ConfigurationSchemaBuilder.valueDef;
 import com.passus.config.schema.NodeDefinition;
 import com.passus.config.schema.NodeDefinitionCreator;
+import com.passus.st.client.FlowContext;
 import com.passus.st.plugin.PluginConstants;
 import java.io.File;
 import java.io.FileInputStream;
@@ -61,7 +62,7 @@
 
     private List<Credentials> credentialsList;
 
-    private AtomicInteger index = new AtomicInteger();
+    private final AtomicInteger index = new AtomicInteger();
 
     @Override
     public String getType() {
@@ -102,7 +103,7 @@
     }
 
     @Override
-    public Credentials getCredentials(ProviderContext context) {
+    public Credentials getCredentials(FlowContext context) {
         // TODO: remove
         if (credentialsList == null || credentialsList.isEmpty()) {
             return null;
--- a/stress-tester/src/main/java/com/passus/st/client/credentials/MultiCredentialsProvider.java	Tue Apr 14 15:45:01 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/credentials/MultiCredentialsProvider.java	Tue Apr 14 16:06:52 2020 +0200
@@ -3,6 +3,7 @@
 import com.passus.commons.Assert;
 import com.passus.config.Configuration;
 import com.passus.config.ConfigurationContext;
+import com.passus.st.client.FlowContext;
 
 import java.util.List;
 
@@ -31,7 +32,7 @@
     }
 
     @Override
-    public Credentials getCredentials(ProviderContext context) {
+    public Credentials getCredentials(FlowContext context) {
         if (providers != null) {
             for (CredentialsProvider provider : providers) {
                 Credentials credentials = provider.getCredentials(context);
--- a/stress-tester/src/main/java/com/passus/st/client/credentials/SingleCredentialsProvider.java	Tue Apr 14 15:45:01 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/credentials/SingleCredentialsProvider.java	Tue Apr 14 16:06:52 2020 +0200
@@ -2,6 +2,7 @@
 
 import com.passus.config.Configuration;
 import com.passus.config.ConfigurationContext;
+import com.passus.st.client.FlowContext;
 
 /**
  *
@@ -27,7 +28,7 @@
     }
 
     @Override
-    public Credentials getCredentials(ProviderContext context) {
+    public Credentials getCredentials(FlowContext context) {
         return credentials;
     }
 
--- a/stress-tester/src/main/java/com/passus/st/client/credentials/UsernamePasswordCredentialsProvider.java	Tue Apr 14 15:45:01 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/credentials/UsernamePasswordCredentialsProvider.java	Tue Apr 14 16:06:52 2020 +0200
@@ -7,6 +7,7 @@
 import static com.passus.config.schema.ConfigurationSchemaBuilder.*;
 import com.passus.config.schema.NodeDefinition;
 import com.passus.config.schema.NodeDefinitionCreator;
+import com.passus.st.client.FlowContext;
 import com.passus.st.plugin.PluginConstants;
 
 /**
@@ -53,7 +54,7 @@
     }
 
     @Override
-    public Credentials getCredentials(ProviderContext context) {
+    public Credentials getCredentials(FlowContext context) {
         return new Credentials(username, password);
     }
 
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpAbstractLoginFilter.java	Tue Apr 14 15:45:01 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpAbstractLoginFilter.java	Tue Apr 14 16:06:52 2020 +0200
@@ -14,7 +14,6 @@
 import com.passus.st.client.FlowContext;
 import com.passus.st.client.credentials.Credentials;
 import com.passus.st.client.credentials.CredentialsProvider;
-import com.passus.st.client.credentials.CredentialsProvider.ProviderContext;
 import com.passus.st.client.credentials.CredentialsProviderFactory;
 import com.passus.st.client.credentials.MultiCredentialsProviderTransformer;
 import com.passus.st.filter.FlowFilterFactory;
@@ -56,7 +55,7 @@
         return credentialsProvider;
     }
 
-    protected Credentials getCredentials(ProviderContext context) {
+    protected Credentials getCredentials(FlowContext context) {
         return credentialsProvider == null ? null : credentialsProvider.getCredentials(context);
     }
 
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpBasicAuthLoginFilter.java	Tue Apr 14 15:45:01 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpBasicAuthLoginFilter.java	Tue Apr 14 16:06:52 2020 +0200
@@ -12,7 +12,6 @@
 import com.passus.st.client.FlowContext;
 import com.passus.st.client.credentials.Credentials;
 import com.passus.st.client.credentials.CredentialsProvider;
-import com.passus.st.client.credentials.CredentialsProvider.ProviderContext;
 import static com.passus.st.client.http.HttpConsts.PARAM_USERNAME;
 import static com.passus.st.client.http.filter.HttpFlowUtils.extractHttpContext;
 
@@ -52,8 +51,7 @@
         if (entry != null) {
             ByteString oldValue = entry.getValue();
             if (oldValue.startsWith(BASIC)) {
-                ProviderContext providerContext = new ProviderContext(request, resp, null, context.sessionInfo());
-                Credentials credentials = getCredentials(providerContext);
+                Credentials credentials = getCredentials(context);
                 ParametersBag conversation = extractHttpContext(context).scopes().getConversation(request);
 
                 if (credentials != null) {
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpDigestAuthLoginFilter.java	Tue Apr 14 15:45:01 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpDigestAuthLoginFilter.java	Tue Apr 14 16:06:52 2020 +0200
@@ -16,7 +16,6 @@
 import com.passus.st.client.FlowContext;
 import com.passus.st.client.credentials.Credentials;
 import com.passus.st.client.credentials.CredentialsProvider;
-import com.passus.st.client.credentials.CredentialsProvider.ProviderContext;
 import static com.passus.st.client.http.HttpConsts.PARAM_USERNAME;
 import static com.passus.st.client.http.filter.HttpFlowUtils.extractHttpContext;
 
@@ -74,8 +73,7 @@
 
             ByteString nonce = nonceMap.get(currReqAuth.getNonce());
             if (nonce != null) {
-                ProviderContext providerContext = new ProviderContext(request, resp, null, context.sessionInfo());
-                Credentials credentials = getCredentials(providerContext);
+                Credentials credentials = getCredentials(context);
                 ParametersBag conversation = extractHttpContext(context).scopes().getConversation(request);
 
                 if (credentials != null) {
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFormLoginFilter.java	Tue Apr 14 15:45:01 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFormLoginFilter.java	Tue Apr 14 16:06:52 2020 +0200
@@ -10,7 +10,6 @@
 import com.passus.st.client.FlowContext;
 import com.passus.st.client.credentials.Credentials;
 import com.passus.st.client.credentials.CredentialsProvider;
-import com.passus.st.client.credentials.CredentialsProvider.ProviderContext;
 import com.passus.st.filter.MessagePredicate;
 import com.passus.st.client.http.HttpScopes;
 import com.passus.st.plugin.PluginConstants;
@@ -60,8 +59,7 @@
             try {
                 HttpParameters parameters = helper.decodeFormUrlencoded(request);
                 if (parameters != null && parameters.contains(userField) && parameters.contains(passwordField)) {
-                    ProviderContext providerContext = new ProviderContext(request, resp, null, context.sessionInfo());
-                    Credentials credentials = getCredentials(providerContext);
+                    Credentials credentials = getCredentials(context);
                     ParametersBag conversation = extractHttpContext(context).scopes().getConversation(request);
 
                     if (credentials != null) {
--- a/stress-tester/src/main/java/com/passus/st/client/pgsql/filter/PgSqlLoginFilter.java	Tue Apr 14 15:45:01 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/pgsql/filter/PgSqlLoginFilter.java	Tue Apr 14 16:06:52 2020 +0200
@@ -45,8 +45,7 @@
             PgSqlAuthRequestMessage.AuthType authType = context.getParamValue("authType");
 
             byte[] salt = new byte[4];
-            CredentialsProvider.ProviderContext pc = null;
-            Credentials credentials = getCredentials(pc);
+            Credentials credentials = getCredentials(context);
             String password = credentials.getPassword();
             String user = credentials.getUser();
 
@@ -68,7 +67,7 @@
         return DUNNO;
     }
 
-    protected Credentials getCredentials(CredentialsProvider.ProviderContext context) {
+    protected Credentials getCredentials(FlowContext context) {
         return credentialsProvider == null ? null : credentialsProvider.getCredentials(context);
     }