Codota Logo
HttpsMapper
Code IndexAdd Codota 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)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
List l =
  • Codota Iconnew LinkedList()
  • Codota IconCollections.emptyList()
  • Codota Iconnew ArrayList()
  • Smart code suggestions by Codota
}
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

  • Start an intent from android
  • requestLocationUpdates (LocationManager)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getSystemService (Context)
  • MalformedURLException (java.net)
    Thrown to indicate that a malformed URL has occurred. Either no legal protocol could be found in a s
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • TreeSet (java.util)
    A NavigableSet implementation based on a TreeMap. The elements are ordered using their Comparable, o
  • JCheckBox (javax.swing)
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.This exception may include information for locating the er
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now