View Javadoc
1   package com.jsql.model.suspendable.callable;
2   
3   import com.jsql.model.InjectionModel;
4   import org.apache.commons.lang3.StringUtils;
5   
6   import java.util.concurrent.Callable;
7   
8   /**
9    * Callable for concurrent HTTP tasks
10   * url: SQL query
11   * content: source code of the web page
12   * tag: store user information (ex. current index)
13   */
14  public class CallablePageSource implements Callable<CallablePageSource> {
15      
16      /**
17       * URL to load.
18       */
19      private final String query;
20      private final int nbIndex;
21      private final String metadataInjectionProcess;
22  
23      /**
24       * Source code for current page.
25       */
26      private String content = StringUtils.EMPTY;
27  
28      /**
29       * Character used for current page.
30       */
31      private String characterInsertion;
32      
33      private final InjectionModel injectionModel;
34      
35      /**
36       * Create a callable to get initial query or insertion character.
37       */
38      public CallablePageSource(String query, InjectionModel injectionModel, String metadataInjectionProcess, int nbIndex) {
39          this.query = query;
40          this.nbIndex = nbIndex;
41          this.injectionModel = injectionModel;
42          this.metadataInjectionProcess = metadataInjectionProcess;
43      }
44  
45      /**
46       * Create callable for current insertion character test.
47       */
48      public CallablePageSource(
49          String query,
50          String characterInsertion,
51          InjectionModel injectionModel,
52          String metadataInjectionProcess
53      ) {
54          this(query, injectionModel, metadataInjectionProcess, 0);
55          this.characterInsertion = characterInsertion;
56      }
57      
58      @Override
59      public CallablePageSource call() {
60          this.content = this.injectionModel.injectWithoutIndex(this.query, this.metadataInjectionProcess);
61          return this;
62      }
63  
64      
65      // Getters
66  
67      public String getQuery() {
68          return this.query;
69      }
70      
71      public String getContent() {
72          return this.content;
73      }
74      
75      public String getCharacterInsertion() {
76          return this.characterInsertion;
77      }
78  
79      public int getNbIndex() {
80          return this.nbIndex;
81      }
82  }