public Object getInstance(String className) { return instanceCache.getInstance(className); }
public Locale getLocaleByRequest( HttpServletRequest request) { RequestWrapper rw = new RequestWrapper(request, configurator.getDefaultLocale(), storeKeyName); return rw.getLocale(); }
private void safeClose(ClosableInputSource source) { if (source != null) { try { source.close(); } catch (IOException e) { log.debug(e.getMessage(), e); } } }
+ userName); String passwordDigest = new PasswordDigester(password, configurator.getDigest(), configurator.getEncoding()).toString(); user = userManager.createUser(userName, passwordDigest); GenericValue val = GenericValue.getGenericValueFromObject(properties.get(key)); if (val.isMultiValue()) { user.setProperty((String) key, val.getValues()); } else { user.setProperty((String) key, val.get());
private String getNodeContentAsString(Node node) throws ValueFormatException, PathNotFoundException, IOException, RepositoryException { if (node == null) return null; return IOUtils.toString(node.getNode("jcr:content").getProperty("jcr:data").getBinary().getStream(), configurator.getEncoding()); }
CompositeClassLoader cClassLoader = new CompositeClassLoader(); for (String key : classLoaders.keySet()) { cClassLoader.add(classLoaders.get(key)); perThreadRequest.set(null); perThreadResponse.set(null); response.setCharacterEncoding(config.getEncoding()); PrintWriter writer = response.getWriter(); writer.print(payload);
session = repository.loginAdministrative(null); String html = templateNode(Md5Encrypter.encrypt(template), resource, template, variables); if (html == null) throw new RepositoryException("Template is empty"); mailNode.setProperty("jcr:data", new BinaryValue(html.getBytes(configurator.getEncoding()))); mailNode.setProperty("jcr:lastModified", Calendar.getInstance()); mailNode.setProperty("jcr:mimeType", "message/rfc822");
public ClassLoader getClassLoaderByBundle(String name) throws ClassNotFoundException { return new BundleProxyClassLoader(getBundleByName(name)); }
CompositeClassLoader cClassLoader = new CompositeClassLoader(); for (String key : classLoaders.keySet()) { cClassLoader.add(classLoaders.get(key));
public void processOrderBy() { if (orderBy != null) { for (OrderByClause o : orderBy) { if (clazz != null) { Object[] annotations = BaseAnnotationHelper.findFieldAnnotationByAnnotationClass(clazz, o.getFieldName(), Column.class); if (annotations != null && annotations.length > 0) { o.setFieldName(((Column)annotations[0]).name()); } } } } }
if (cookie.getName().equals(PAR_CAPTCHA_ATTRIBUTE_NAME)) { foundCookie = true; cookie.setMaxAge(configurator.getSessionTimeout().intValue()); cookie.setValue(captchaId); cookie.setPath("/"); Cookie cookie = new Cookie(PAR_CAPTCHA_ATTRIBUTE_NAME, captchaId); cookie.setMaxAge(configurator.getSessionTimeout().intValue()); cookie.setPath("/"); response.addCookie(cookie); if (request.getSession() == null) { request.getSession(true).setMaxInactiveInterval( configurator.getSessionTimeout().intValue()); request.getSession().setAttribute(PAR_STORAGE, captchaId); captchaId = request.getSession().getId();
if (in != null) { return new ClosableInputSource(in); return new ClosableInputSource(new FileInputStream(f)); } else { + ", tried URL, filesystem "); return new ClosableInputSource(in);
protected Locale getLocale() { if (getThreadLocalRequest().getAttribute("locale") == null) { RequestWrapper rw = new RequestWrapper(getThreadLocalRequest(), config.getDefaultLocale()); getThreadLocalRequest().setAttribute("locale", rw.getLocale()); return rw.getLocale(); } else { return getThreadLocalRequest().getLocale(); } }
private InternetAddress[] convertToInternetAddress(Object address) throws AddressException, UnsupportedEncodingException { if (address == null) return new InternetAddress[]{}; if (address instanceof InternetAddress) return new InternetAddress[] {(InternetAddress)address}; else if (address instanceof String) { return new InternetAddress[] {new InternetAddress(MimeUtility.encodeText((String)address, configurator.getEncoding(), "Q"))}; } else if (address instanceof InternetAddress[]) { return (InternetAddress[]) address; } else if (address instanceof List<?>) { return convertToInternetAddress(((List) address).toArray()); } else if (address instanceof Object[]) { List<InternetAddress> list = new ArrayList<InternetAddress>(); for (Object o : (Object[])address) { for (InternetAddress addr : convertToInternetAddress(o)) { list.add(addr); } return list.toArray(new InternetAddress[list.size()]); } } return new InternetAddress[] {new InternetAddress(MimeUtility.encodeText(address.toString(), configurator.getEncoding(), "Q"))}; }
private ClassLoader getClassLoaderByBundle(String name) throws ClassNotFoundException { return new BundleProxyClassLoader(getBundleByName(name)); }
@Override public <T extends Locator<?, ?>> T createLocator(Class<T> clazz) { // Searching for locator and setting super.createLocator(clazz); return (T) instanceCache.getInstance(clazz); }
@SuppressWarnings("rawtypes") public static String getOperandSource(Operand operand, Class clazz, ToSQLStringEvent toSQLString) throws Exception { String source; if (operand.isLiteral()) { source = new ObjectToSQLLiteral(getOperandValue(operand), toSQLString).getLiteral(); } else { String fieldName = (String) getOperandValue(operand); if (clazz != null) { Object[] annotations = BaseAnnotationHelper.findFieldAnnotationByAnnotationClass(clazz, fieldName, Column.class); if (annotations != null && annotations.length > 0) { fieldName = ((Column)annotations[0]).name(); } } source = fieldName; } String qualifier = operand.getQualifier(); String function = operand.getFunction(); if (!((qualifier == null) || (qualifier.equals("")))) { source = qualifier + "." + source; } if (!((function == null) || (function.equals("")))) { source = function + "(" + source + ")"; } return source; }
protected Locale getLocale() { if (getThreadLocalRequest().getAttribute("locale") == null) { RequestWrapper rw = new RequestWrapper(getThreadLocalRequest(), config.getDefaultLocale()); getThreadLocalRequest().setAttribute("locale", rw.getLocale()); return rw.getLocale(); } else { return getThreadLocalRequest().getLocale(); } }
public void removeXSSsecurityVulnerability(String parentFolder, String fileName) throws RepositoryException, Exception { if (!session.isLive()) session = repository.loginAdministrative(null); Node node = session.getRootNode().getNode(parentFolder+"/"+fileName); if (isValidMimeType(node)) { log.info("Removing XSS Vulnerability codes for node {}", node.getPath()); StringWriter sw = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(sw); xmlWriter.setOutputProperty(XMLWriter.OMIT_XML_DECLARATION, "yes"); xmlWriter.setOutputProperty(XMLWriter.ENCODING, configurator.getEncoding()); parser.setContentHandler(xmlWriter); parser.parse(new InputSource(new InputStreamReader(node.getNode("jcr:content").getProperty("jcr:data").getStream(), configurator.getEncoding()))); node.getNode("jcr:content").setProperty("jcr:data", new ByteArrayInputStream(sw.toString().getBytes(configurator.getEncoding()))); } else { log.info("No XSS Vulnerability remove, not a HTML: {} - {}", node.getPath(), node.getNode("jcr:content").getProperty("jcr:mimeType")); } session.save(); }
@Override public void registerResourceBundle(Bundle bundle, String className) { synchronized (classNames) { ResourceBundle.clearCache(getClassLoader(className, null)); classNames.add(className); bundleResourceCaches.put(className, new BundleProxyClassLoader(bundle)); // Iterate over existing locales in cache and add new entry for (Locale locale : resourceBundles.keySet()) { addToCache(className, locale, getCompositeProxyResourceBundleFromCache(locale)); } } }