public ClientAuthSSLProtocolSocketFactory(KeyStore ks, String keyStorePass, String protocol, String kmfFactory, TrustManager tm) { if (ks == null) throw new IllegalArgumentException(Localizer.get("INVALID.KEYSTORE")); this.ks = ks; this.keyStorePass = keyStorePass; this.protocol = protocol != null ? protocol : DEFAULT_PROTOCOL; this.kmfFactory = kmfFactory != null ? kmfFactory : DEFAULT_KMF_FACTORY; this.tm = tm; }
public FOMUnsupportedTextTypeException(String message) { super(Localizer.sprintf("UNSUPPORTED.TEXT.TYPE", message)); }
public static synchronized Localizer getInstance() { if (instance == null) instance = new Localizer(); return instance; }
/** * @deprecated */ public static String format(String key, Object... args) { return getInstance().formatValue(key, args); }
public static String get(String key, String defaultValue) { return getInstance().getValue(key, defaultValue); }
public static String sprintf(String key, Object... args) { return getInstance().sprintfValue(key, args); }
/** * Sanitize the value of a Slug header. Any non alphanumeric characters in the slug are replaced with an underscore */ public static String sanitizeSlug(String slug) { if (slug == null) throw new IllegalArgumentException(Localizer.get("SLUG.NOT.NULL")); String sanitized = Sanitizer.sanitize(slug); log.debug(Localizer.sprintf("SLUG.SANITIZED", slug, sanitized)); return sanitized; }
public String getValue(String key, String defaultValue) { String value = getValue(key); return value != null ? value : defaultValue; }
public static String get(String key) { return getInstance().getValue(key); }
/** * Use the JDK 1.5 sprintf style Formatter */ public String sprintfValue(String key, Object... args) { String value = getValue(key); return value != null ? String.format(locale, value, args) : null; } }
public static ResponseContext notmodified(RequestContext request, String reason) { log.debug(Localizer.get("NOT.MODIFIED")); return new EmptyResponseContext(304, reason); }
public FOMUnsupportedContentTypeException(String message) { super(Localizer.sprintf("UNSUPPORTED.CONTENT.TYPE", message)); }
/** * Use the pre-JDK 1.5 MessageFormat. This should be avoided. Applications should use the sprintfValue method * instead * * @deprecated * @see springfValue */ public String formatValue(String key, Object... args) { String value = getValue(key); return value != null ? MessageFormat.format(value, args) : null; }
/** * Utility method for generating ETags. Works by concatenating the UTF-8 bytes * of the provided strings then generating an MD5 hash of the result. */ public static EntityTag generate(String... material) { String etag = null; try { MessageDigest md = MessageDigest.getInstance("md5"); for (String s : material) { if (s != null) md.update(s.getBytes("utf-8")); } byte[] digest = md.digest(); etag = new String(Hex.encodeHex(digest)); } catch (NoSuchAlgorithmException e) { throw new UnsupportedOperationException(Localizer .get("HASHING.NOT.AVAILABLE")); } catch (UnsupportedEncodingException e) { // should not happen throw new RuntimeException(Localizer.get("UTF8.NOT.SUPPORTED"), e); } return new EntityTag(etag); }
private RuntimeException throwex(String id, String arg, Throwable t) { return new RuntimeException(Localizer.sprintf(id, arg), t); }
/** * Utility method for generating ETags. Works by concatenating the UTF-8 bytes of the provided strings then * generating an MD5 hash of the result. */ public static EntityTag generate(String... material) { String etag = null; try { MessageDigest md = MessageDigest.getInstance("md5"); for (String s : material) { if (s != null) md.update(s.getBytes("utf-8")); } byte[] digest = md.digest(); etag = new String(Hex.encodeHex(digest)); } catch (NoSuchAlgorithmException e) { throw new UnsupportedOperationException(Localizer.get("HASHING.NOT.AVAILABLE")); } catch (UnsupportedEncodingException e) { // should not happen throw new RuntimeException(Localizer.get("UTF8.NOT.SUPPORTED"), e); } return new EntityTag(etag); }
public static int getPageSize(RequestContext request, String pagesizeparam, int defaultpagesize) { int size = defaultpagesize; try { String _ps = request.getParameter(pagesizeparam); size = (_ps != null) ? Math.min(Math.max(Integer.parseInt(_ps), 0), defaultpagesize) : defaultpagesize; } catch (Exception e) { } log.debug(Localizer.sprintf("PAGE.SIZE", size)); return size; }
public ResponseContext setSlug(String slug) { if (slug == null) { return removeHeader("Slug"); } if (slug.indexOf((char)10) > -1 || slug.indexOf((char)13) > -1) throw new IllegalArgumentException(Localizer.get("SLUG.BAD.CHARACTERS")); return setEscapedHeader("Slug", Profile.ASCIISANSCRLF, slug); }
protected void checkFactory(Factory factory) { if (!(factory instanceof FOMFactory)) throw new FOMException(Localizer.sprintf("WRONG.PARSER.INSTANCE", FOMFactory.class.getName())); }
/** * Return a service unavailable error */ public static ResponseContext unavailable(RequestContext request, String reason) { log.debug(Localizer.get("UNAVAILABLE")); return createErrorResponse(request.getAbdera(), 503, reason); }