18 package org.turro.elephant.context;
20 import java.io.IOException;
21 import java.util.List;
22 import java.util.Locale;
24 import java.util.ResourceBundle;
25 import java.util.logging.Level;
26 import java.util.logging.Logger;
27 import javax.servlet.http.Cookie;
28 import javax.servlet.http.HttpServletRequest;
29 import javax.servlet.http.HttpServletResponse;
30 import javax.servlet.http.HttpSession;
31 import org.turro.annotation.ElephantSessionResolver;
32 import org.turro.elephant.impl.context.ContextFactory;
33 import org.turro.elephant.impl.security.UserPreferences;
34 import org.turro.elephant.impl.util.CookieUtil;
35 import org.turro.elephant.sitemap.SitemapGenerator;
36 import org.turro.elephant.web.ElContextMap;
37 import org.turro.i18n.I_;
38 import org.turro.i18n.Labels;
39 import org.turro.i18n.locale.I18nLocales;
40 import org.turro.plugin.contacts.IContact;
41 import org.turro.reflection.Instances;
42 import org.turro.security.SecurityGroups;
43 import org.turro.string.Strings;
65 protected static ThreadLocal<Application>
app =
new ThreadLocal<>();
74 if(application ==
null) {
77 if(application ==
null) {
80 if(application ==
null) {
82 request.setAttribute(
"el_app", application);
86 if(application !=
null) {
92 }
catch(Exception ex) {
142 }
catch (IOException ex) {
148 public boolean isInRole(String role, String redirect)
throws IOException {
151 if(!isWebAdministering) {
154 result = constructor.
isInRole(role);
155 if(!isWebAdministering) {
158 if(!result && redirect !=
null) {
171 if(user ==
null && doLogin) {
186 }
catch (IOException ex) {
201 }
catch (IOException ex) {
221 }
catch(Exception ex) {
255 return c !=
null ? c.getValue() :
null;
258 public static void setCookie(String name, String value, String path,
int age) {
262 public static void encryptCookie(String name, String value, String path,
int age) {
266 }
catch (Exception ex) {
278 }
catch (Exception ex) {
291 return I_.
api().used();
306 public static String
getString(String key, String locale) {
310 public static String
getString(String key, Locale locale) {
318 public static ResourceBundle
getBundle(String bundle, Locale locale, String configured) {
336 HttpServletRequest
request = iSessionResolver.getRequest();
346 HttpServletResponse
response = iSessionResolver.getResponse();
356 HttpSession session = iSessionResolver.getSession(create);
357 if(session !=
null) {
static String decryptCookieValue(String name)
static HttpSession getResolverSession(boolean create)
IImplementation getImplementation(String name)
abstract IConstructor doConstructor()
static ResourceBundle getBundle(String bundle, Locale locale, String configured)
IConstructor getConstructor()
abstract HttpServletResponse getHttpServletResponse()
static String getCookieValue(String name)
static void resetSchemes()
static List< String > getAllLocales(String key)
ApplicationContext getContext()
HttpServletResponse response
static HttpServletRequest getResolverRequest()
static String getString(String key, Locale locale)
abstract void sendRedirect(String uri)
boolean hasAnyRoleKey(String role)
static void resetSettings()
static Application getFromConstructor(IConstructor constructor)
static String getString(String key, String locale)
static boolean loadResources(String path)
void putPreference(String key, Object value)
static void encryptCookie(String name, String value, String path, int age)
boolean isInRole(String role)
static HttpServletResponse getResolverResponse()
boolean isInRole(String role, String redirect)
UserPreferences preferences
static IContact getUser()
HttpSession getHttpSession(boolean create)
static final String REGEXP_NO_RESOURCES
static final String[] BUNDLES
static Cookie getCookie(String name)
abstract void navigateBack()
Object getPreference(String key)
static Map getStringMap(Locale locale, String configured)
HttpServletRequest request
List getImplementationNamesByType(String type)
static Application getApplication()
static String getString(String key)
static void deleteCookie(String name, String path)
static void setCookie(String name, String value, String path, int age)
static Locale getUsedLocale()
abstract HttpServletRequest getHttpServletRequest()
static Map getStringMap()
IContact checkUser(boolean doLogin)
static ThreadLocal< Application > app
static String getServerBase(String scheme)
static String getServerUrl(String scheme)
static String logMsg(String msg)
static byte[] encrypt(byte[] value)
static byte[] decrypt(byte[] value)
static void resetSchemes()
static void redirectToLogin(IConstructor constructor)
static void resetProperties()
static HeadlessApplication getInstance()
static Object getImplementation(IElement iel, String name)
static void resetImplementationsStartingWith(String name)
static List getImplementationNamesByType(String type)
static UserPreferences getInstance(String id)
boolean isEqual(String id)
Object put(String key, Object value)
static Cookie getCookie(HttpServletRequest request, String name)
static void setCookie(HttpServletResponse response, String name, String value, String path, int age)
static byte[] decryptCookieValue(Cookie cookie)
static void encryptCookie(HttpServletResponse response, String name, byte[] value, String path, int age)
static void deleteCookie(HttpServletResponse response, String name, String path)
static void generateSitemap()
ResourceBundle asBundle()
List< String > getInLocales(String msg)
static I18nApiWrapper api()
static I18nCompatibilityWrapper compatibility()
static I18nCompatibilityMap compatibilityMap()
boolean isWebAdministering()
void setWebAdministering(boolean value)
void redirect(String path)
HttpServletRequest getRequest()
boolean hasAnyRoleKey(String role)
boolean isInRole(String role)