Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.

1 /*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. The ASF licenses this file to You4 * under the Apache License, Version 2.0 (the "License"); you may not5 * use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License. For additional information regarding15 * copyright in this work, please see the NOTICE file in the top level16 * directory of this distribution.17 */18 19 package org.apache.roller.ui.rendering.util;20 21 importjava.util.Locale;22 importjavax.servlet.http.HttpServletRequest;23 24 25 /**26 * An abstract class representing any request made to Roller that has been27 * parsed in order to extract relevant pieces of information from the url.28 *29 * NOTE: It is extremely important to mention that this class and all of its30 * subclasses are meant to be extremely light weight. Meaning they should31 * avoid any time consuming operations at all costs, especially operations32 * which require a trip to the db. Those operations should be used very, very33 * sparingly and should only be triggered when it's guaranteed that they are34 * needed.35 */36 publicabstractclass ParsedRequest {37 38 HttpServletRequest request = null;39 40 privateString language = null;41 privateString authenticUser = null;42 43 44 ParsedRequest() {}45 46 47 /**48 * Parse the given http request and extract any information we can.49 *50 * This abstract version of the constructor gathers info likely to be51 * relevant to all requests to Roller.52 */53 public ParsedRequest(HttpServletRequest request) throwsInvalidRequestException {54 55 // keep a reference to the original request56 this.request = request;57 58 // login status59 java.security.Principal prince = request.getUserPrincipal();60 if(prince != null) {61 this.authenticUser = prince.getName();62 }63 64 }65 66 67 publicString getAuthenticUser() {68 returnthis.authenticUser;69 }70 71 72 publicboolean isLoggedIn() {73 return (this.authenticUser != null);74 }75 76 }77