View Javadoc
1   /*******************************************************************************
2    * Copyhacked (H) 2012-2025.
3    * This program and the accompanying materials
4    * are made available under no term at all, use it like
5    * you want, but share and discuss it
6    * every time possible with every body.
7    * 
8    * Contributors:
9    *      ron190 at ymail dot com - initial implementation
10   ******************************************************************************/
11  package com.jsql.model;
12  
13  import com.jsql.model.bean.util.Request;
14  import com.jsql.model.injection.strategy.blind.AbstractCallableBinary;
15  
16  import java.util.concurrent.SubmissionPublisher;
17  
18  /**
19   * Define the features of the injection model :<br>
20   * - stop the preparation of injection,<br>
21   * - Callable for parallelize HTTP tasks,<br>
22   * - communication with view, via Observable.
23   */
24  public abstract class AbstractModelObservable extends SubmissionPublisher<Request> {
25      
26      /**
27       * True if user wants to stop preparation.<br>
28       * During the preparation, several methods will
29       * check if the execution must be stopped.
30       */
31      protected boolean isStoppedByUser = false;
32  
33      /**
34       * Function header for the inject() methods, definition needed by call(),
35       * dataInjection: SQL query,
36       * responseHeader unused,
37       * useVisibleIndex false if injection indexes aren't needed,
38       * return source page after the HTTP call.
39       */
40      public abstract String inject(
41          String dataInjection,
42          boolean isUsingIndex,
43          String metadataInjectionProcess,
44          AbstractCallableBinary<?> callableBoolean,
45          boolean isReport
46      );
47      
48      /**
49       * Inject without the need of index like in "select 1,2,...".<br>
50       * Used for example by: first index test (getVisibleIndex), Error test, and Error, Blind, Time strategies.
51       * @return source code of current page
52       */
53      public String injectWithoutIndex(String dataInjection, String metadataInjectionProcess) {
54          return this.inject(dataInjection, false, metadataInjectionProcess, null, false);
55      }
56  
57      public String injectWithoutIndex(String dataInjection, String metadataInjectionProcess, AbstractCallableBinary<?> callableBoolean) {
58          return this.inject(dataInjection, false, metadataInjectionProcess, callableBoolean, false);
59      }
60  
61      public String injectWithIndexes(String dataInjection, String metadataInjectionProcess) {
62          return this.inject(dataInjection, true, metadataInjectionProcess, null, false);
63      }
64  
65      public String getReportWithoutIndex(String dataInjection, String metadataInjectionProcess) {
66          return this.inject(dataInjection, false, metadataInjectionProcess, null, true);
67      }
68  
69      public String getReportWithoutIndex(String dataInjection, String metadataInjectionProcess, AbstractCallableBinary<?> callableBoolean) {
70          return this.inject(dataInjection, false, metadataInjectionProcess, callableBoolean, true);
71      }
72  
73      public String getReportWithIndexes(String dataInjection, String metadataInjectionProcess) {
74          return this.inject(dataInjection, true, metadataInjectionProcess, null, true);
75      }
76  
77      /**
78       * Send an interaction message to registered views.
79       * @param request The event bean corresponding to the interaction
80       */
81      public void sendToViews(final Request request) {
82          this.submit(request);
83      }
84  
85      
86      // Getters and setters
87      
88      public boolean isStoppedByUser() {
89          return this.isStoppedByUser;
90      }
91  
92      public void setIsStoppedByUser(boolean processStopped) {
93          this.isStoppedByUser = processStopped;
94      }
95  }