congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
HttpsMapper
Code IndexAdd Tabnine to your IDE (free)

How to use
HttpsMapper
in
org.apache.wicket.protocol.https

Best Java code snippets using org.apache.wicket.protocol.https.HttpsMapper (Showing top 17 results out of 315)

origin: stackoverflow.com

 setRootRequestMapper(new HttpsMapper(getRootRequestMapper(), new HttpsConfig(8080, 8443)){
  @Override
  public Url mapHandler(IRequestHandler requestHandler) {
    Url url = super.mapHandler(requestHandler);
    if ("https".equals(url.getProtocol)){
      // Force the HostName for HTTPS requests
      url.setHost("securepage.example.com");   
    }
    return url;
  }
});
origin: org.apache.wicket/wicket-core

@Override
public final IRequestHandler mapRequest(Request request)
{
  IRequestHandler handler = delegate.mapRequest(request);
  Scheme desired = getDesiredSchemeFor(handler);
  Scheme current = getSchemeOf(request);
  if (!desired.isCompatibleWith(current))
  {
    // we are currently on the wrong scheme for this handler
    // construct a url for the handler on the correct scheme
    String url = createRedirectUrl(handler, request, desired);
    // replace handler with one that will redirect to the created url
    handler = createRedirectHandler(url);
  }
  return handler;
}
origin: org.apache.wicket/wicket-core

/**
 * Checks if the specified {@code type} has the {@link RequireHttps} annotation
 * 
 * @param type
 * @return {@code true} iff {@code type} has the {@link RequireHttps} annotation
 */
private boolean hasSecureAnnotation(Class<?> type)
{
  if (type.getAnnotation(RequireHttps.class) != null)
  {
    return true;
  }
  for (Class<?> iface : type.getInterfaces())
  {
    if (hasSecureAnnotation(iface))
    {
      return true;
    }
  }
  if (type.getSuperclass() != null)
  {
    return hasSecureAnnotation(type.getSuperclass());
  }
  return false;
}
origin: org.apache.wicket/wicket-core

/**
 * Creates a url for the handler. Modifies it with the correct {@link Scheme} if necessary.
 * 
 * @param handler
 * @param request
 * @return url
 */
final Url mapHandler(IRequestHandler handler, Request request)
{
  Url url = delegate.mapHandler(handler);
  Scheme desired = getDesiredSchemeFor(handler);
  Scheme current = getSchemeOf(request);
  if (!desired.isCompatibleWith(current))
  {
    // the generated url does not have the correct scheme, set it (which in turn will cause
    // the url to be rendered in its full representation)
    url.setProtocol(desired.urlName());
    url.setPort(desired.getPort(config));
  }
  return url;
}
origin: apache/wicket

/**
 * Figures out which {@link Scheme} should be used to access the request handler
 * 
 * @param handler
 *            request handler
 * @return {@link Scheme}
 */
protected Scheme getDesiredSchemeFor(IRequestHandler handler)
{
  if (handler instanceof IPageClassRequestHandler)
  {
    return getDesiredSchemeFor(((IPageClassRequestHandler)handler).getPageClass());
  }
  return Scheme.ANY;
}
origin: org.wicketstuff/wicketstuff-portlet

  @Override
  protected Scheme getDesiredSchemeFor(IRequestHandler handler) {
    Request request = RequestCycle.get().getRequest();
    return super.getSchemeOf(request);
  }
});
origin: apache/wicket

@Override
public final Url mapHandler(IRequestHandler handler)
{
  return mapHandler(handler, RequestCycle.get().getRequest());
}
origin: apache/wicket

/**
 * Creates a url for the handler. Modifies it with the correct {@link Scheme} if necessary.
 * 
 * @param handler
 * @param request
 * @return url
 */
final Url mapHandler(IRequestHandler handler, Request request)
{
  Url url = delegate.mapHandler(handler);
  Scheme desired = getDesiredSchemeFor(handler);
  Scheme current = getSchemeOf(request);
  if (!desired.isCompatibleWith(current))
  {
    // the generated url does not have the correct scheme, set it (which in turn will cause
    // the url to be rendered in its full representation)
    url.setProtocol(desired.urlName());
    url.setPort(desired.getPort(config));
  }
  return url;
}
origin: org.apache.wicket/wicket-core

/**
 * Figures out which {@link Scheme} should be used to access the request handler
 * 
 * @param handler
 *            request handler
 * @return {@link Scheme}
 */
protected Scheme getDesiredSchemeFor(IRequestHandler handler)
{
  if (handler instanceof IPageClassRequestHandler)
  {
    return getDesiredSchemeFor(((IPageClassRequestHandler)handler).getPageClass());
  }
  return Scheme.ANY;
}
origin: org.apache.wicket/wicket-core

@Override
public final Url mapHandler(IRequestHandler handler)
{
  return mapHandler(handler, RequestCycle.get().getRequest());
}
origin: apache/wicket

@Override
public final IRequestHandler mapRequest(Request request)
{
  IRequestHandler handler = delegate.mapRequest(request);
  Scheme desired = getDesiredSchemeFor(handler);
  Scheme current = getSchemeOf(request);
  if (!desired.isCompatibleWith(current))
  {
    // we are currently on the wrong scheme for this handler
    // construct a url for the handler on the correct scheme
    String url = createRedirectUrl(handler, request, desired);
    // replace handler with one that will redirect to the created url
    handler = createRedirectHandler(url);
  }
  return handler;
}
origin: de.alpharogroup/jaulp-wicket-base

/**
 * Sets the root request mapper for the given application from the given httpPort and httpsPort.
 *
 * @param application
 *            the application
 * @param httpPort
 *            the http port
 * @param httpsPort
 *            the https port
 * @return the i request mapper
 */
public static IRequestMapper setRootRequestMapper(final Application application,
  final int httpPort, final int httpsPort)
{
  final IRequestMapper httpsMapper = new HttpsMapper(application.getRootRequestMapper(),
    new HttpsConfig(httpPort, httpsPort));
  application.setRootRequestMapper(httpsMapper);
  return httpsMapper;
}
origin: de.alpharogroup/jaulp-wicket-base

  @Override
  protected Scheme getDesiredSchemeFor(final Class<? extends IRequestablePage> pageClass)
  {
    if (application.getConfigurationType().equals(RuntimeConfigurationType.DEVELOPMENT))
    {
      // is in development mode, returning Scheme.HTTP...
      return Scheme.HTTP;
    }
    else
    {
      // not in development mode, letting the mapper decide
      return super.getDesiredSchemeFor(pageClass);
    }
  }
});
origin: apache/wicket

/**
 * Checks if the specified {@code type} has the {@link RequireHttps} annotation
 * 
 * @param type
 * @return {@code true} iff {@code type} has the {@link RequireHttps} annotation
 */
private boolean hasSecureAnnotation(Class<?> type)
{
  if (type.getAnnotation(RequireHttps.class) != null)
  {
    return true;
  }
  for (Class<?> iface : type.getInterfaces())
  {
    if (hasSecureAnnotation(iface))
    {
      return true;
    }
  }
  if (type.getSuperclass() != null)
  {
    return hasSecureAnnotation(type.getSuperclass());
  }
  return false;
}
origin: de.alpharogroup/jaulp-wicket-base

final int httpPort, final int httpsPort)
application.setRootRequestMapper(new HttpsMapper(application.getRootRequestMapper(),
  new HttpsConfig(httpPort, httpsPort))
origin: apache/wicket

/**
 * Determines which {@link Scheme} should be used to access the page
 * 
 * @param pageClass
 *            type of page
 * @return {@link Scheme}
 */
protected Scheme getDesiredSchemeFor(Class<? extends IRequestablePage> pageClass)
{
  if (pageClass == null)
  {
    return Scheme.ANY;
  }
  Scheme SCHEME = cache.get(pageClass);
  if (SCHEME == null)
  {
    if (hasSecureAnnotation(pageClass))
    {
      SCHEME = Scheme.HTTPS;
    }
    else
    {
      SCHEME = Scheme.HTTP;
    }
    cache.put(pageClass, SCHEME);
  }
  return SCHEME;
}
origin: org.apache.wicket/wicket-core

/**
 * Determines which {@link Scheme} should be used to access the page
 * 
 * @param pageClass
 *            type of page
 * @return {@link Scheme}
 */
protected Scheme getDesiredSchemeFor(Class<? extends IRequestablePage> pageClass)
{
  if (pageClass == null)
  {
    return Scheme.ANY;
  }
  Scheme SCHEME = cache.get(pageClass);
  if (SCHEME == null)
  {
    if (hasSecureAnnotation(pageClass))
    {
      SCHEME = Scheme.HTTPS;
    }
    else
    {
      SCHEME = Scheme.HTTP;
    }
    cache.put(pageClass, SCHEME);
  }
  return SCHEME;
}
org.apache.wicket.protocol.httpsHttpsMapper

Javadoc

A IRequestMapper that will issue a redirect to secured communication (over https) if the page resolved by #delegate is annotated with @ RequireHttps

To setup it:

 
public class MyApplication extends WebApplication 
{ 
public void init() 
{ 
super.init(); 
getRootRequestMapperAsCompound().add(new MountedMapper("secured", HttpsPage.class)); 
mountPage(SomeOtherPage.class); 
// notice that in most cases this should be done as the 
// last mounting-related operation because it replaces the root mapper 
setRootRequestMapper(new HttpsMapper(getRootRequestMapper(), new HttpsConfig(80, 443))); 
} 
} 
any request to http://hostname:httpPort/secured will be redirected to https://hostname:httpsPort/secured

Most used methods

  • <init>
    Constructor
  • getDesiredSchemeFor
    Figures out which Scheme should be used to access the request handler
  • getSchemeOf
    Determines the Scheme of the request
  • createRedirectHandler
    Creates the IRequestHandler that will be responsible for the redirect
  • createRedirectUrl
    Constructs a redirect url that should switch the user to the specified scheme
  • hasSecureAnnotation
    Checks if the specified type has the RequireHttps annotation
  • mapHandler
    Creates a url for the handler. Modifies it with the correct Scheme if necessary.

Popular in Java

  • Making http post requests using okhttp
  • putExtra (Intent)
  • runOnUiThread (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now