Revision aea2f0ea
Added by Andreas Kohlbecker over 3 years ago
modules/cdm_dataportal/cdm_dataportal.module | ||
---|---|---|
2149 | 2149 |
/** |
2150 | 2150 |
* Returns a registration page as a Drupal node to be rendered by Drupal. |
2151 | 2151 |
* |
2152 |
* @param string $registration_identifier_encoded
|
|
2152 |
* @param string $registration_identifie |
|
2153 | 2153 |
* The persistent identifier of the registration urlencoded. |
2154 | 2154 |
* @return mixed |
2155 | 2155 |
* The formatted registration page as node. |
2156 | 2156 |
*/ |
2157 |
function cdm_dataportal_registration_page_view($registration_identifier_encoded) {
|
|
2157 |
function cdm_dataportal_registration_page_view() { |
|
2158 | 2158 |
|
2159 |
cdm_check_valid_portal_page("/\/cdm_dataportal\/registration\/.*$/"); |
|
2160 |
$registration_page = cdm_dataportal_registration_view($registration_identifier_encoded); |
|
2159 |
cdm_check_valid_portal_page("/\/cdm_dataportal\/registration/"); |
|
2160 |
$registration_identifier = $_REQUEST['identifier']; |
|
2161 |
$registration_page = cdm_dataportal_registration_view($registration_identifier); |
|
2161 | 2162 |
return cdm_node_show_simulate($registration_page); |
2162 | 2163 |
} |
2163 | 2164 |
|
2164 | 2165 |
/** |
2165 |
* @param $registration_identifier_encoded
|
|
2166 |
* @param $registration_identifier |
|
2166 | 2167 |
* @return array |
2167 | 2168 |
* The drupal render array for the registration view. |
2168 | 2169 |
*/ |
2169 |
function cdm_dataportal_registration_view($registration_identifier_encoded) { |
|
2170 |
|
|
2171 |
$registration_identifier = urldecode($registration_identifier_encoded); // FIXME remove |
|
2170 |
function cdm_dataportal_registration_view($registration_identifier) { |
|
2172 | 2171 |
|
2173 | 2172 |
RenderHints::pushToRenderStack('registration_page'); |
2174 | 2173 |
RenderHints::setFootnoteListKey('registration_page'); |
src/main/java/eu/etaxonomy/dataportal/pages/PortalPage.java | ||
---|---|---|
9 | 9 |
import java.net.URL; |
10 | 10 |
import java.util.ArrayList; |
11 | 11 |
import java.util.List; |
12 |
import java.util.Map; |
|
13 |
import java.util.Map.Entry; |
|
12 | 14 |
import java.util.concurrent.TimeUnit; |
13 | 15 |
import java.util.regex.Matcher; |
14 | 16 |
import java.util.regex.Pattern; |
... | ... | |
117 | 119 |
return isZenTheme.booleanValue(); |
118 | 120 |
} |
119 | 121 |
|
122 |
|
|
120 | 123 |
/** |
121 | 124 |
* Creates a new PortaPage. Implementations of this class will provide the base path of the page by |
122 | 125 |
* implementing the method {@link #getDrupalPageBase()}. The constructor argument <code>pagePathSuffix</code> |
... | ... | |
125 | 128 |
* <li>{@link #getDrupalPageBase()} returns <code>/cdm_dataportal/taxon</code></li> |
126 | 129 |
* <li><code>pagePathSuffix</code> gives <code>7fe8a8b6-b0ba-4869-90b3-177b76c1753f</code></li> |
127 | 130 |
* </ol> |
128 |
* Both are combined to form the URL pathelement <code>/cdm_dataportal/taxon/7fe8a8b6-b0ba-4869-90b3-177b76c1753f</code> |
|
131 |
* Both are combined to form the URL path element <code>/cdm_dataportal/taxon/7fe8a8b6-b0ba-4869-90b3-177b76c1753f</code>
|
|
129 | 132 |
* |
130 | 133 |
*/ |
131 |
public PortalPage(WebDriver driver, DataPortalContext context, String pagePathSuffix) throws MalformedURLException { |
|
134 |
public PortalPage(WebDriver driver, DataPortalContext context, String pagePathSuffix, Map<String, String> queryParameters) throws MalformedURLException {
|
|
132 | 135 |
|
133 | 136 |
this.driver = driver; |
134 | 137 |
|
... | ... | |
138 | 141 |
|
139 | 142 |
this.initialDrupalPagePath = getDrupalPageBase() + (pagePathSuffix != null ? "/" + pagePathSuffix: ""); |
140 | 143 |
|
141 |
this.pageUrl = new URL(context.getSiteUri().toString() + "?" + DRUPAL_PAGE_QUERY + initialDrupalPagePath); |
|
144 |
StringBuilder queryStringB = new StringBuilder(); |
|
145 |
if(queryParameters != null && !queryParameters.isEmpty()) { |
|
146 |
for(Entry<String, String> entry : queryParameters.entrySet()) { |
|
147 |
queryStringB.append("&").append(entry.getKey()).append("=").append(entry.getValue()); |
|
148 |
} |
|
149 |
} |
|
150 |
this.pageUrl = new URL(context.getSiteUri().toString() + "?" + DRUPAL_PAGE_QUERY + initialDrupalPagePath + queryStringB.toString()); |
|
142 | 151 |
|
143 | 152 |
// tell browser to navigate to the page |
144 | 153 |
logger.info("loading " + pageUrl); |
... | ... | |
151 | 160 |
PageFactory.initElements(driver, this); |
152 | 161 |
|
153 | 162 |
pageHealthChecks(); |
163 |
} |
|
154 | 164 |
|
165 |
/** |
|
166 |
* Creates a new PortaPage. Implementations of this class will provide the base path of the page by |
|
167 |
* implementing the method {@link #getDrupalPageBase()}. The constructor argument <code>pagePathSuffix</code> |
|
168 |
* specifies the specific page to navigate to. For example: |
|
169 |
* <ol> |
|
170 |
* <li>{@link #getDrupalPageBase()} returns <code>/cdm_dataportal/taxon</code></li> |
|
171 |
* <li><code>pagePathSuffix</code> gives <code>7fe8a8b6-b0ba-4869-90b3-177b76c1753f</code></li> |
|
172 |
* </ol> |
|
173 |
* Both are combined to form the URL path element <code>/cdm_dataportal/taxon/7fe8a8b6-b0ba-4869-90b3-177b76c1753f</code> |
|
174 |
* |
|
175 |
*/ |
|
176 |
public PortalPage(WebDriver driver, DataPortalContext context, String pagePathSuffix) throws MalformedURLException { |
|
177 |
this(driver, context, pagePathSuffix, null); |
|
155 | 178 |
} |
156 | 179 |
|
157 | 180 |
/** |
src/main/java/eu/etaxonomy/dataportal/pages/RegistrationPage.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import java.io.UnsupportedEncodingException; |
12 | 12 |
import java.net.MalformedURLException; |
13 |
import java.net.URLEncoder;
|
|
13 |
import java.util.Collections;
|
|
14 | 14 |
import java.util.UUID; |
15 | 15 |
|
16 | 16 |
import org.apache.log4j.Logger; |
... | ... | |
36 | 36 |
|
37 | 37 |
protected static String drupalPagePathBase = "cdm_dataportal/registration"; |
38 | 38 |
|
39 |
|
|
39 | 40 |
@FindBy(id = "registration") |
40 | 41 |
@CacheLookup |
41 | 42 |
private WebElement registrationElement; |
... | ... | |
53 | 54 |
|
54 | 55 |
|
55 | 56 |
public RegistrationPage(WebDriver driver, DataPortalContext context, String httpID) throws MalformedURLException, UnsupportedEncodingException { |
56 |
super(driver, context, URLEncoder.encode(URLEncoder.encode(httpID, "UTF-8")));
|
|
57 |
super(driver, context, null, Collections.singletonMap("identifier", httpID));
|
|
57 | 58 |
} |
58 | 59 |
|
59 | 60 |
/** |
Also available in: Unified diff
ref #9220 registratin page using query param 'identifier' to protect against CVE-2007-0450 vulnerability