use of org.apache.tapestry5.http.services.BaseURLSource in project tapestry-5 by apache.
the class AppModule method setupCustomBaseURLSource.
@Contribute(ServiceOverride.class)
public void setupCustomBaseURLSource(MappedConfiguration<Class, Object> configuration) {
BaseURLSource source = new BaseURLSource() {
public String getBaseURL(boolean secure) {
String protocol = secure ? "https" : "http";
// This is all a bit jury-rigged together. This is for running the app
// interactively; Selenium doesn't seem to handle the transition to https.
int port = secure ? 8443 : 9090;
return String.format("%s://localhost:%d", protocol, port);
}
};
configuration.add(BaseURLSource.class, source);
}
use of org.apache.tapestry5.http.services.BaseURLSource in project tapestry-5 by apache.
the class LinkImplTest method force_link_to_secure.
@Test
public void force_link_to_secure() {
Response response = mockResponse();
BaseURLSource baseURLSource = mockBaseURLSource();
train_getBaseURL(baseURLSource, true, SECURE_BASE_URL);
train_encodeURL(response, SECURE_BASE_URL + BASE_PATH, ENCODED);
replay();
Link link = new LinkImpl(BASE_PATH, false, LinkSecurity.INSECURE, response, null, baseURLSource);
link.setSecurity(LinkSecurity.FORCE_SECURE);
assertEquals(link.toAbsoluteURI(), ENCODED);
verify();
}
use of org.apache.tapestry5.http.services.BaseURLSource in project tapestry-5 by apache.
the class ComponentEventLinkEncoderImpl method createPageRenderLink.
public Link createPageRenderLink(PageRenderRequestParameters parameters) {
StringBuilder builder = new StringBuilder(BUFFER_SIZE);
// Build up the absolute URI.
String activePageName = parameters.getLogicalPageName();
builder.append(contextPath);
encodeAppFolderAndLocale(builder);
builder.append(SLASH);
String encodedPageName = encodePageName(activePageName);
builder.append(encodedPageName);
appendContext(encodedPageName.length() > 0, parameters.getActivationContext(), builder);
Link link = new LinkImpl(builder.toString(), false, requestSecurityManager.checkPageSecurity(activePageName), response, contextPathEncoder, baseURLSource);
if (parameters.isLoopback()) {
link.addParameter(TapestryConstants.PAGE_LOOPBACK_PARAMETER_NAME, "t");
}
return link;
}
use of org.apache.tapestry5.http.services.BaseURLSource in project tapestry-5 by apache.
the class LinkImplTest method absolute_URI_for_default_secure_link.
@Test
public void absolute_URI_for_default_secure_link() {
Response response = mockResponse();
BaseURLSource baseURLSource = mockBaseURLSource();
train_getBaseURL(baseURLSource, true, SECURE_BASE_URL);
train_encodeURL(response, SECURE_BASE_URL + BASE_PATH, ENCODED);
replay();
Link link = new LinkImpl(BASE_PATH, false, LinkSecurity.SECURE, response, null, baseURLSource);
assertEquals(link.toAbsoluteURI(), ENCODED);
verify();
}
use of org.apache.tapestry5.http.services.BaseURLSource in project tapestry-5 by apache.
the class LinkImplTest method force_secure_URI_from_insecure_link.
@Test
public void force_secure_URI_from_insecure_link() {
Response response = mockResponse();
BaseURLSource baseURLSource = mockBaseURLSource();
train_getBaseURL(baseURLSource, true, SECURE_BASE_URL);
train_encodeURL(response, SECURE_BASE_URL + BASE_PATH, ENCODED);
replay();
Link link = new LinkImpl(BASE_PATH, false, LinkSecurity.INSECURE, response, null, baseURLSource);
assertEquals(link.toAbsoluteURI(true), ENCODED);
verify();
}
Aggregations