RequestUtils.java revision e82342ec9174effcb0cb1c35abf149025282212d
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: RequestUtils.java,v 1.5 2008/08/19 19:09:00 veiming Exp $
*
* Portions Copyrighted 2015 ForgeRock AS.
*
*/
/**
* This class provides common utilities for requests.
*/
public class RequestUtils {
// the debug file name
// the resource bundle name
// get instance of debug instance
// http request max content length
private static int maxContentLength = getMaxContentLength();
static {
}
}
}
/*
* Returns right protocol for redirection. This method picks up configured
* protocol and host name and returned configured protocol whenever request
* needs to be redirected to configured host.
*
* @param scheme Protocol of request. @param host Host name of request.
* @return the right protocol for redirection.
*/
// Check appended port number
// Check appended uri
if (idx == -1) {
}
// Get host name only
if (idx != -1) {
}
}
}
return protocol;
}
/**
* Use this method to check an HTTP servlet request size against the
* configured limit to insure that it is not too large, and possibly being
* sent to an OpenAM servlet to cause a Denial of Service (DOS).
*
* @param servletRequest
* The HTTP servlet request.
* @throws L10NMessageImpl
* If the request content length is too long.
*/
throws L10NMessageImpl {
// get content length of request
// Check content length against configured limit
if (length > maxContentLength) {
new Integer(maxContentLength) };
throw new L10NMessageImpl(
} else {
return;
}
}
/*
* Get the maxContentLength.
*/
private static int getMaxContentLength() {
// set the default content length to 16k
int maxContentLength = 16384;
// get the maxContentLength from properties file
try {
} catch (NumberFormatException ne) {
if (debug.messageEnabled()) {
}
}
return maxContentLength;
}
}