001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.wicket.protocol.https; 018 019/** 020 * Configuration for http-https switching 021 * 022 * @see HttpsMapper 023 */ 024public class HttpsConfig 025{ 026 private int httpPort; 027 private int httpsPort; 028 029 /** 030 * A flag which can be used to configure {@link HttpsMapper} to bind or not the session before 031 * switching to secure (https) mode 032 */ 033 private boolean preferStateful = true; 034 035 /** 036 * Constructor 037 */ 038 public HttpsConfig() 039 { 040 this(80, 443); 041 } 042 043 /** 044 * Constructor 045 * 046 * @param httpPort 047 * http port 048 * @param httpsPort 049 * https port 050 */ 051 public HttpsConfig(int httpPort, int httpsPort) 052 { 053 this.httpPort = httpPort; 054 this.httpsPort = httpsPort; 055 } 056 057 058 /** 059 * Sets http port 060 * 061 * @param httpPort 062 */ 063 public void setHttpPort(int httpPort) 064 { 065 this.httpPort = httpPort; 066 } 067 068 /** 069 * Sets https port 070 * 071 * @param httpsPort 072 */ 073 public void setHttpsPort(int httpsPort) 074 { 075 this.httpsPort = httpsPort; 076 } 077 078 /** 079 * @return http port 080 */ 081 public int getHttpPort() 082 { 083 return httpPort; 084 } 085 086 /** 087 * @return https port 088 */ 089 public int getHttpsPort() 090 { 091 return httpsPort; 092 } 093 094 /** 095 * @see #setPreferStateful(boolean) 096 * @return preferStateless 097 */ 098 public boolean isPreferStateful() 099 { 100 return preferStateful; 101 } 102 103 /** 104 * Sets whether or not a new session is created before redirecting from {@code http} to 105 * {@code https} 106 * <p> 107 * BE VERY CAREFUL WHEN SETTING THIS VALUE TO {@code false}. 108 * 109 * If set to {@code false} it is possible that the session created when in {@code https} pages 110 * will not be accessible to {@code http} pages, and so you may end up with two sessions per 111 * user both potentially containing different login information. 112 * </p> 113 * 114 * @param preferStateful 115 */ 116 public void setPreferStateful(boolean preferStateful) 117 { 118 this.preferStateful = preferStateful; 119 } 120}