conversation listlengths 2 2 |
|---|
[
{
"content": "Instantiate timing of a particular class and method for a specific application.\n\n@param appid the application that invoked the request\n@param clazz the Class to be timed\n@param names one or more unique names to identify the timer - usually a method name\n@return a closeable context that encaps... |
[
{
"content": "Creates a new counter for a particular class and method for a specific application.\n\n@param appid the application that invoked the request\n@param clazz the Class to be counted\n@param names one or more unique names to identify the counter - usually a method name\n@return a counter",
"role":... |
[
{
"content": "Calls the Facebook API to get the user profile using a given access token.\n@param app the app where the user will be created, use null for root app\n@param accessToken access token\n@return {@link UserAuthentication} object or null if something went wrong\n@throws IOException ex",
"role": "us... |
[
{
"content": "Extracts a User object from the security context.\n@param auth the authentication object\n@return an authenticated user or null if a user is not authenticated",
"role": "user"
},
{
"content": "public static User getAuthenticatedUser(Authentication auth) {\n\t\tUser user = null;\n\t\tif... |
[
{
"content": "Extracts a App object from the security context.\n@return an authenticated app or null if a app is not authenticated",
"role": "user"
},
{
"content": "public static App getAuthenticatedApp() {\n\t\tApp app = null;\n\t\tif (SecurityContextHolder.getContext().getAuthentication() != null)... |
[
{
"content": "An app can edit itself or delete itself. It can't read, edit, overwrite or delete other apps, unless it is the\nroot app.\n\n@param app an app\n@param object another object\n@return true if app passes the check",
"role": "user"
},
{
"content": "public static boolean checkImplicitAppPer... |
[
{
"content": "Check if a user can modify an object. If there's no user principal found, this returns true.\n\n@param app app in context\n@param object some object\n@return true if user is the owner/creator of the object.",
"role": "user"
},
{
"content": "public static boolean checkIfUserCanModifyObj... |
[
{
"content": "Clears the session. Deletes cookies and clears the security context.\n@param req HTTP request",
"role": "user"
},
{
"content": "public static void clearSession(HttpServletRequest req) {\n\t\tSecurityContextHolder.clearContext();\n\t\tif (req != null) {\n\t\t\tHttpSession session = req.... |
[
{
"content": "Validates a JWT token.\n@param secret secret used for generating the token\n@param jwt token to validate\n@return true if token is valid",
"role": "user"
},
{
"content": "public static boolean isValidJWToken(String secret, SignedJWT jwt) {\n\t\ttry {\n\t\t\tif (secret != null && jwt !=... |
[
{
"content": "Generates a new JWT token.\n@param user a User object belonging to the app\n@param app the app object\n@return a new JWT or null",
"role": "user"
},
{
"content": "public static SignedJWT generateJWToken(User user, App app) {\n\t\tif (app != null) {\n\t\t\ttry {\n\t\t\t\tDate now = new ... |
[
{
"content": "Decides when the next token refresh should be.\n@param tokenValiditySec token validity period\n@return a refresh timestamp to be used by API clients",
"role": "user"
},
{
"content": "private static long getNextRefresh(long tokenValiditySec) {\n\t\tlong interval = Config.JWT_REFRESH_INT... |
[
{
"content": "Return the OAuth app ID and secret key for a given app by reading the app settings, or the config file.\n@param app the app in which to look for these keys\n@param prefix a service prefix: \"fb\" for facebook, \"tw\" for twitter etc. See {@link Config}\n@return an array [\"app_id\", \"secret_key\"... |
[
{
"content": "Returns a map of LDAP configuration properties for a given app, read from app.settings or config file.\n@param app the app in which to look for these keys\n@return a map of keys and values",
"role": "user"
},
{
"content": "public static Map<String, String> getLdapSettingsForApp(App ap... |
[
{
"content": "Returns the value of the app setting, read from from app.settings or from the config file if app is root.\n@param app the app in which to look for these keys\n@param key setting key\n@param defaultValue default value\n@return the value of the configuration property as string",
"role": "user"
... |
[
{
"content": "Checks if account is active.\n@param userAuth user authentication object\n@param user user object\n@param throwException throw or not\n@return the authentication object if {@code user.active == true}",
"role": "user"
},
{
"content": "public static UserAuthentication checkIfActive(UserA... |
[
{
"content": "Validates the signature of the request.\n@param incoming the incoming HTTP request containing a signature\n@param secretKey the app's secret key\n@return true if the signature is valid",
"role": "user"
},
{
"content": "public static boolean isValidSignature(HttpServletRequest incoming,... |
[
{
"content": "Executes all initialize listeners and prints logo. Call this method first.",
"role": "user"
},
{
"content": "public static void initialize() {\n\t\tif (isInitialized) {\n\t\t\treturn;\n\t\t}\n\t\tisInitialized = true;\n\t\tprintLogo();\n\t\ttry {\n\t\t\tlogger.info(\"--- Para.initializ... |
[
{
"content": "Calls all registered listeners on exit. Call this method last.",
"role": "user"
},
{
"content": "public static void destroy() {\n\t\ttry {\n\t\t\tlogger.info(\"--- Para.destroy() ---\");\n\t\t\tfor (DestroyListener destroyListener : DESTROY_LISTENERS) {\n\t\t\t\tif (destroyListener != ... |
[
{
"content": "Creates the root application and returns the credentials for it.\n@return credentials for the root app",
"role": "user"
},
{
"content": "public static Map<String, String> setup() {\n\t\treturn newApp(Config.getRootAppIdentifier(), Config.APP_NAME, false, false);\n\t}",
"role": "ass... |
[
{
"content": "Creates a new application and returns the credentials for it.\n@param appid the app identifier\n@param name the full name of the app\n@param sharedTable false if the app should have its own table\n@param sharedIndex false if the app should have its own index\n@return credentials for the root app",... |
[
{
"content": "Returns a map of all translations for a given language.\nDefaults to the default language which must be set.\n@param appid appid name of the {@link com.erudika.para.core.App}\n@param langCode the 2-letter language code\n@return the language map",
"role": "user"
},
{
"content": "public ... |
[
{
"content": "Persists the language map in the data store. Overwrites any existing maps.\n@param appid appid name of the {@link com.erudika.para.core.App}\n@param langCode the 2-letter language code\n@param lang the language map\n@param writeToDatabase true if you want the language map to be stored in the DB as... |
[
{
"content": "Returns a non-null locale for a given language code.\n@param langCode the 2-letter language code\n@return a locale. default is English",
"role": "user"
},
{
"content": "public Locale getProperLocale(String langCode) {\n\t\tif (StringUtils.startsWith(langCode, \"zh\")) {\n\t\t\tif (\"zh... |
[
{
"content": "Returns the default language map.\n@param appid appid name of the {@link com.erudika.para.core.App}\n@return the default language map or an empty map if the default isn't set.",
"role": "user"
},
{
"content": "public Map<String, String> getDefaultLanguage(String appid) {\n\t\tif (!LANG... |
[
{
"content": "Sets the default language map. It is the basis language template which is to be translated.\n@param deflang the default language map",
"role": "user"
},
{
"content": "public void setDefaultLanguage(Map<String, String> deflang) {\n\t\tif (deflang != null && !deflang.isEmpty()) {\n\t\t\t... |
[
{
"content": "Returns a list of translations for a specific string.\n@param appid appid name of the {@link com.erudika.para.core.App}\n@param locale a locale\n@param key the string key\n@param pager the pager object\n@return a list of translations",
"role": "user"
},
{
"content": "public List<Transl... |
[
{
"content": "Returns the set of all approved translations.\n@param appid appid name of the {@link com.erudika.para.core.App}\n@param langCode the 2-letter language code\n@return a set of keys for approved translations",
"role": "user"
},
{
"content": "public Set<String> getApprovedTransKeys(String ... |
[
{
"content": "Returns a map of language codes and the percentage of translated string for that language.\n@param appid appid name of the {@link com.erudika.para.core.App}\n@return a map indicating translation progress",
"role": "user"
},
{
"content": "public Map<String, Integer> getTranslationProgre... |
[
{
"content": "Approves a translation for a given language.\n@param appid appid name of the {@link com.erudika.para.core.App}\n@param langCode the 2-letter language code\n@param key the translation key\n@param value the translated string\n@return true if the operation was successful",
"role": "user"
},
{... |
[
{
"content": "Disapproves a translation for a given language.\n@param appid appid name of the {@link com.erudika.para.core.App}\n@param langCode the 2-letter language code\n@param key the translation key\n@return true if the operation was successful",
"role": "user"
},
{
"content": "public boolean d... |
[
{
"content": "Updates the progress for all languages.\n@param appid appid name of the {@link com.erudika.para.core.App}\n@param langCode the 2-letter language code\n@param value {@link #PLUS}, {@link #MINUS} or the total percent of completion (0-100)",
"role": "user"
},
{
"content": "private void up... |
[
{
"content": "A list of roles for the authenticated user.\n@return a list of roles",
"role": "user"
},
{
"content": "public Collection<? extends GrantedAuthority> getAuthorities() {\n\t\tif (principal == null) {\n\t\t\treturn Collections.emptyList();\n\t\t}\n\t\treturn Collections.unmodifiableCollec... |
[
{
"content": "Checks if it is a rest request.\n@param request request\n@return true if rest or ajax",
"role": "user"
},
{
"content": "protected boolean isRestRequest(HttpServletRequest request) {\n\t\treturn RestRequestMatcher.INSTANCE.matches(request) || AjaxRequestMatcher.INSTANCE.matches(request)... |
[
{
"content": "Loads a user from the data store.\n@param ident the user identifier\n@return a user object or null if user is not found",
"role": "user"
},
{
"content": "public UserDetails loadUserByUsername(String ident) {\n\t\tUser user = new User();\n\t\t// check if the cookie has an appid prefix\n... |
[
{
"content": "Loads a user from the data store or creates a new user from an OpenID profile.\n@param token the OpenID authentication token holding the user profile\n@return a user object or null if user is not found",
"role": "user"
},
{
"content": "public UserDetails loadUserDetails(OpenIDAuthentic... |
[
{
"content": "Configures the authentication providers.\n\n@param auth a builder\n@throws Exception ex",
"role": "user"
},
{
"content": "@Override\n\tprotected void configure(AuthenticationManagerBuilder auth) throws Exception {\n\t\tOpenIDAuthenticationProvider openidProvider = new OpenIDAuthenticat... |
[
{
"content": "Configures the unsecured public resources.\n\n@param web web sec object\n@throws Exception ex",
"role": "user"
},
{
"content": "@Override\n\tpublic void configure(WebSecurity web) throws Exception {\n\t\tweb.ignoring().requestMatchers(IgnoredRequestMatcher.INSTANCE);\n\t\tDefaultHttpFi... |
[
{
"content": "Configures the protected private resources.\n\n@param http HTTP sec object\n@throws Exception ex",
"role": "user"
},
{
"content": "@Override\n\tprotected void configure(HttpSecurity http) throws Exception {\n\t\tConfigObject protectedResources = Config.getConfig().getObject(\"security.... |
[
{
"content": "Verifies that the given annotation type corresponds to a known constraint.\n@param anno annotation type\n@param consName constraint name\n@return true if known",
"role": "user"
},
{
"content": "public static boolean matches(Class<? extends Annotation> anno, String consName) {\n\t\tretu... |
[
{
"content": "Builds a new constraint from the annotation data.\n@param anno JSR-303 annotation instance\n@return a new constraint",
"role": "user"
},
{
"content": "public static Constraint fromAnnotation(Annotation anno) {\n\t\tif (anno instanceof Min) {\n\t\t\treturn min(((Min) anno).value());\n\t... |
[
{
"content": "Creates a new map representing a simple validation constraint.\n@param name the name of the constraint\n@return a map",
"role": "user"
},
{
"content": "static Map<String, Object> simplePayload(final String name) {\n\t\tif (name == null) {\n\t\t\treturn null;\n\t\t}\n\t\tMap<String, Obj... |
[
{
"content": "The 'required' constraint - marks a field as required.\n@return constraint",
"role": "user"
},
{
"content": "public static Constraint required() {\n\t\treturn new Constraint(\"required\", simplePayload(\"required\")) {\n\t\t\tpublic boolean isValid(Object actualValue) {\n\t\t\t\treturn... |
[
{
"content": "The 'min' constraint - field must contain a number larger than or equal to min.\n@param min the minimum value\n@return constraint",
"role": "user"
},
{
"content": "public static Constraint min(final Number min) {\n\t\treturn new Constraint(\"min\", minPayload(min)) {\n\t\t\tpublic bool... |
[
{
"content": "The 'max' constraint - field must contain a number smaller than or equal to max.\n@param max the maximum value\n@return constraint",
"role": "user"
},
{
"content": "public static Constraint max(final Number max) {\n\t\treturn new Constraint(\"max\", maxPayload(max)) {\n\t\t\tpublic boo... |
[
{
"content": "The 'pattern' constraint - field must contain a value matching a regular expression.\n@param regex a regular expression\n@return constraint",
"role": "user"
},
{
"content": "public static Constraint pattern(final Object regex) {\n\t\treturn new Constraint(\"pattern\", patternPayload(re... |
[
{
"content": "The 'email' constraint - field must contain a valid email.\n@return constraint",
"role": "user"
},
{
"content": "public static Constraint email() {\n\t\treturn new Constraint(\"email\", simplePayload(\"email\")) {\n\t\t\tpublic boolean isValid(Object actualValue) {\n\t\t\t\tif (actualV... |
[
{
"content": "The 'truthy' constraint - field value must be equal to 'true'.\n@return constraint",
"role": "user"
},
{
"content": "public static Constraint truthy() {\n\t\treturn new Constraint(\"true\", simplePayload(\"true\")) {\n\t\t\tpublic boolean isValid(Object actualValue) {\n\t\t\t\tif (actu... |
[
{
"content": "The 'url' constraint - field value must be a valid URL.\n@return constraint",
"role": "user"
},
{
"content": "public static Constraint url() {\n\t\treturn new Constraint(\"url\", simplePayload(\"url\")) {\n\t\t\tpublic boolean isValid(Object actualValue) {\n\t\t\t\tif (actualValue != n... |
[
{
"content": "Builds a new constraint from a given name and payload.\n@param cname the constraint name\n@param payload the payload\n@return constraint",
"role": "user"
},
{
"content": "public static Constraint build(String cname, Map<String, Object> payload) {\n\t\tif (cname != null && payload != nu... |
[
{
"content": "A list of roles for this user.\n@return a list of roles",
"role": "user"
},
{
"content": "@JsonIgnore\n\tpublic Collection<? extends GrantedAuthority> getAuthorities() {\n\t\tif (user.isAdmin()) {\n\t\t\treturn Collections.singleton(new SimpleGrantedAuthority(Roles.ADMIN.toString()));\... |
[
{
"content": "Returns a map of the core data types.\n@return a map of type plural - type singular form",
"role": "user"
},
{
"content": "public static Map<String, String> getCoreTypes() {\n\t\tif (CORE_TYPES.isEmpty()) {\n\t\t\ttry {\n\t\t\t\tfor (Class<? extends ParaObject> clazz : getCoreClassesMa... |
[
{
"content": "Returns a map of all registered types.\n@param app the app to search for custom types\n@return a map of plural - singular form of type names",
"role": "user"
},
{
"content": "public static Map<String, String> getAllTypes(App app) {\n\t\tMap<String, String> map = new LinkedHashMap<>(get... |
[
{
"content": "Returns the app identifier by parsing the Authorization.\n@param authorization Authorization header\n@return appid",
"role": "user"
},
{
"content": "public static String getAppidFromAuthHeader(String authorization) {\n\t\tif (StringUtils.isBlank(authorization)) {\n\t\t\treturn \"\";\n\... |
[
{
"content": "Checks if the type of an object matches its real Class name.\n\n@param so an object\n@return true if the types match",
"role": "user"
},
{
"content": "public static boolean typesMatch(ParaObject so) {\n\t\treturn (so == null) ? false : so.getClass().equals(toClass(so.getType()));\n\t}"... |
[
{
"content": "Constructs a new instance of a core object.\n\n@param <P> the object type\n@param type the simple name of a class\n@return a new instance of a core class. Defaults to {@link com.erudika.para.core.Sysprop}.\n@see #toClass(java.lang.String)",
"role": "user"
},
{
"content": "public static... |
[
{
"content": "Converts a domain object to JSON.\n\n@param <P> type of object to convert\n@param obj a domain object\n@return the JSON representation of that object",
"role": "user"
},
{
"content": "public static <P extends ParaObject> String toJSON(P obj) {\n\t\tif (obj == null) {\n\t\t\treturn \"{}... |
[
{
"content": "Flush OutputStream or PrintWriter.\n\n@throws IOException ex",
"role": "user"
},
{
"content": "@Override\n\tpublic void flushBuffer() throws IOException {\n\n\t\t//PrintWriter.flush() does not throw exception\n\t\tif (this.printWriter != null) {\n\t\t\tthis.printWriter.flush();\n\t\t}\... |
[
{
"content": "Flushes all the streams for this response.\n@throws IOException maybe",
"role": "user"
},
{
"content": "public void flush() throws IOException {\n\t\tif (printWriter != null) {\n\t\t\tprintWriter.flush();\n\t\t}\n\n\t\tif (gzipOutputStream != null) {\n\t\t\tgzipOutputStream.flush();\n\... |
[
{
"content": "Returns the correct id of this app with prefix.\n@param id an id like \"myapp\"\n@return the full id, e.g. \"app:myapp\"",
"role": "user"
},
{
"content": "public static final String id(String id) {\n\t\tif (StringUtils.startsWith(id, PREFIX)) {\n\t\t\treturn PREFIX.concat(Utils.noSpace... |
[
{
"content": "Adds a new setting to the map.\n@param name a key\n@param value a value\n@return this",
"role": "user"
},
{
"content": "public App addSetting(String name, Object value) {\n\t\tif (!StringUtils.isBlank(name) && value != null) {\n\t\t\tgetSettings().put(name, value);\n\t\t\tfor (AppSetti... |
[
{
"content": "Returns the value of a setting for a given key.\n@param name the key\n@return the value",
"role": "user"
},
{
"content": "public Object getSetting(String name) {\n\t\tif (!StringUtils.isBlank(name)) {\n\t\t\treturn getSettings().get(name);\n\t\t}\n\t\treturn null;\n\t}",
"role": "a... |
[
{
"content": "Removes a setting from the map.\n@param name the key\n@return this",
"role": "user"
},
{
"content": "public App removeSetting(String name) {\n\t\tif (!StringUtils.isBlank(name)) {\n\t\t\tObject result = getSettings().remove(name);\n\t\t\tif (result != null) {\n\t\t\t\tfor (AppSettingRe... |
[
{
"content": "Returns a map of user-defined data types and their validation annotations.\n@return the constraints map",
"role": "user"
},
{
"content": "public Map<String, Map<String, Map<String, Map<String, ?>>>> getValidationConstraints() {\n\t\tif (validationConstraints == null) {\n\t\t\tvalidatio... |
[
{
"content": "Sets the validation constraints map.\n@param validationConstraints the constraints map",
"role": "user"
},
{
"content": "public void setValidationConstraints(Map<String, Map<String, Map<String, Map<String, ?>>>> validationConstraints) {\n\t\tthis.validationConstraints = validationConst... |
[
{
"content": "Returns a map of resource permissions.\n@return the permissions map",
"role": "user"
},
{
"content": "public Map<String, Map<String, List<String>>> getResourcePermissions() {\n\t\tif (resourcePermissions == null) {\n\t\t\tresourcePermissions = new LinkedHashMap<>();\n\t\t}\n\t\treturn ... |
[
{
"content": "Sets the permissions map.\n@param resourcePermissions permissions map",
"role": "user"
},
{
"content": "public void setResourcePermissions(Map<String, Map<String, List<String>>> resourcePermissions) {\n\t\tthis.resourcePermissions = resourcePermissions;\n\t}",
"role": "assistant"
... |
[
{
"content": "Returns a set of custom data types for this app.\nAn app can have many custom types which describe its domain.\n@return a map of type names (plural form to singular)",
"role": "user"
},
{
"content": "@SuppressWarnings(\"unchecked\")\n\tpublic Map<String, String> getDatatypes() {\n\t\ti... |
[
{
"content": "Returns all validation constraints for a list of types.\n@param types a list of valid Para data types\n@return a map of validation constraints for given types",
"role": "user"
},
{
"content": "public Map<String, Map<String, Map<String, Map<String, ?>>>> getAllValidationConstraints(Stri... |
[
{
"content": "Adds a new constraint to the list of constraints for a given field and type.\n@param type the type\n@param field the field\n@param c the constraint\n@return true if successful",
"role": "user"
},
{
"content": "public boolean addValidationConstraint(String type, String field, Constraint... |
[
{
"content": "Removes a constraint from the map.\n@param type the type\n@param field the field\n@param constraintName the constraint name\n@return true if successful",
"role": "user"
},
{
"content": "public boolean removeValidationConstraint(String type, String field, String constraintName) {\n\t\ti... |
[
{
"content": "Returns all resource permission for a list of subjects ids.\n@param subjectids subject ids (user ids)\n@return a map of all resource permissions per subject",
"role": "user"
},
{
"content": "public Map<String, Map<String, List<String>>> getAllResourcePermissions(String... subjectids) {... |
[
{
"content": "Revokes a permission for given subject.\n@param subjectid subject id\n@param resourcePath resource path or object type\n@return true if successful",
"role": "user"
},
{
"content": "public boolean revokeResourcePermission(String subjectid, String resourcePath) {\n\t\tif (!StringUtils.is... |
[
{
"content": "Revokes all permissions for a subject id.\n@param subjectid subject id\n@return true if successful",
"role": "user"
},
{
"content": "public boolean revokeAllResourcePermissions(String subjectid) {\n\t\tif (!StringUtils.isBlank(subjectid) && getResourcePermissions().containsKey(subjecti... |
[
{
"content": "Check if a subject is explicitly denied access to a resource.\n@param subjectid subject id\n@param resourcePath resource path or object type\n@param httpMethod HTTP method name\n@return true if access is explicitly denied",
"role": "user"
},
{
"content": "final boolean isDeniedExplicit... |
[
{
"content": "Check if the permissions map contains \"OWN\" keyword, which restricts access to objects to their creators.\n\n@param user user in context\n@param object some object\n@return true if app contains permission for this resource and it is marked with \"OWN\"",
"role": "user"
},
{
"content"... |
[
{
"content": "Adds a user-defined data type to the types map.\n@param pluralDatatype the plural form of the type\n@param datatype a datatype, must not be null or empty",
"role": "user"
},
{
"content": "public void addDatatype(String pluralDatatype, String datatype) {\n\t\tpluralDatatype = Utils.noSp... |
[
{
"content": "Returns the map containing the app's access key and secret key.\n@return a map of API keys (never null)",
"role": "user"
},
{
"content": "@JsonIgnore\n\tpublic Map<String, String> getCredentials() {\n\t\tif (getId() == null) {\n\t\t\treturn Collections.emptyMap();\n\t\t} else {\n\t\t\t... |
[
{
"content": "Initializes the configuration class by loading the configuration file.\n@param conf overrides the default configuration",
"role": "user"
},
{
"content": "public static void init(com.typesafe.config.Config conf) {\n\t\ttry {\n\t\t\tconfig = ConfigFactory.load().getConfig(PARA);\n\n\t\t\... |
[
{
"content": "Returns the boolean value of a configuration parameter.\n@param key the param key\n@param defaultValue the default param value\n@return the value of a param",
"role": "user"
},
{
"content": "public static boolean getConfigBoolean(String key, boolean defaultValue) {\n\t\treturn Boolean.... |
[
{
"content": "Returns the integer value of a configuration parameter.\n@param key the param key\n@param defaultValue the default param value\n@return the value of a param",
"role": "user"
},
{
"content": "public static int getConfigInt(String key, int defaultValue) {\n\t\treturn NumberUtils.toInt(ge... |
[
{
"content": "Returns the double value of a configuration parameter.\n@param key the param key\n@param defaultValue the default param value\n@return the value of a param",
"role": "user"
},
{
"content": "public static double getConfigDouble(String key, double defaultValue) {\n\t\treturn NumberUtils.... |
[
{
"content": "Returns the Config object.\n@return the config object",
"role": "user"
},
{
"content": "public static com.typesafe.config.Config getConfig() {\n\t\tif (config == null) {\n\t\t\tinit(null);\n\t\t}\n\t\treturn config;\n\t}",
"role": "assistant"
}
] |
[
{
"content": "Saves a request in cache.\n@param request HTTP request\n@param response HTTP response",
"role": "user"
},
{
"content": "@Override\n\tpublic void saveRequest(HttpServletRequest request, HttpServletResponse response) {\n\t\tif (anyRequestMatcher.matches(request) && !ajaxRequestMatcher.ma... |
[
{
"content": "Removes a saved request from cache.\n@param request HTTP request\n@param response HTTP response",
"role": "user"
},
{
"content": "@Override\n\tpublic void removeRequest(HttpServletRequest request, HttpServletResponse response) {\n\t\tHttpUtils.removeStateParam(Config.RETURNTO_COOKIE, r... |
[
{
"content": "Executes code when a method is invoked.\n@param mi method invocation\n@return the returned value of the method invoked or something else (decided here)\n@throws Throwable error",
"role": "user"
},
{
"content": "public Object invoke(MethodInvocation mi) throws Throwable {\n\t\tif (!Modi... |
[
{
"content": "Deletes a cookie.\n@param name the name\n@param req HTTP request\n@param res HTTP response",
"role": "user"
},
{
"content": "public static void removeStateParam(String name, HttpServletRequest req,\n\t\t\tHttpServletResponse res) {\n\t\tsetRawCookie(name, \"\", req, res, false, 0);\n\t... |
[
{
"content": "Reads a cookie.\n@param name the name\n@param req HTTP request\n@return the cookie value",
"role": "user"
},
{
"content": "public static String getCookieValue(HttpServletRequest req, String name) {\n\t\tif (StringUtils.isBlank(name) || req == null) {\n\t\t\treturn null;\n\t\t}\n\t\tCoo... |
[
{
"content": "A list of OpenID attributes to send in a request.\n@param identifier a user identifier\n@return a list of attributes",
"role": "user"
},
{
"content": "public List<OpenIDAttribute> createAttributeList(String identifier) {\n\t\tList<OpenIDAttribute> list = new LinkedList<>();\n\t\tif (id... |
[
{
"content": "Returns the device's metadata.\n@return a map",
"role": "user"
},
{
"content": "@JsonIgnore\n\tpublic Map<String, Object> getDeviceMetadata() {\n\t\tif (deviceMetadata == null) {\n\t\t\tdeviceMetadata = new LinkedHashMap<>(20);\n\t\t}\n\t\treturn deviceMetadata;\n\t}",
"role": "ass... |
[
{
"content": "Checks if expired.\n@return true if expired",
"role": "user"
},
{
"content": "public boolean isExpired() {\n\t\tif (getTimestamp() == null || getExpiresAfter() == 0) {\n\t\t\treturn false;\n\t\t}\n\t\tlong expires = (getExpiresAfter() * 1000);\n\t\tlong now = Utils.timestamp();\n\t\tre... |
[
{
"content": "Checks if vote can still be amended.\n@return true if vote can still be changed",
"role": "user"
},
{
"content": "public boolean isAmendable() {\n\t\tif (getTimestamp() == null) {\n\t\t\treturn false;\n\t\t}\n\t\tlong now = Utils.timestamp();\n\t\t// check timestamp for recent correcti... |
[
{
"content": "Adds the gzip HTTP header to the response. This is needed when a gzipped body is returned so that browsers can\nproperly decompress it.\n@param response the response which will have a header added to it. I.e this method changes its parameter\n@throws ServletException Either the response is committ... |
[
{
"content": "Sign a request and return the \"Authorization\" header.\n\n@param httpMethod the HTTP method\n@param url the request URL\n@param params the parameters map\n@param apiKey the API key\n@param apiSecret the API secret\n@param oauthToken the token\n@param tokenSecret token secret\n@return the signed a... |
[
{
"content": "md5 hash function.\n@param s the string to be hashed\n@return an md5 hash",
"role": "user"
},
{
"content": "public static String md5(String s) {\n\t\tif (s == null) {\n\t\t\treturn \"\";\n\t\t}\n\t\ttry {\n\t\t\tMessageDigest md = MessageDigest.getInstance(\"MD5\");\n\t\t\tmd.update(s.... |
[
{
"content": "bcrypt hash function implemented by Spring Security.\n\n@param s the string to be hashed\n@return the hash",
"role": "user"
},
{
"content": "public static String bcrypt(String s) {\n\t\treturn (s == null) ? s : BCrypt.hashpw(s, BCrypt.gensalt(12));\n\t}",
"role": "assistant"
}
] |
[
{
"content": "Checks if a hash matches a string.\n\n@param plain plain text string\n@param storedHash hashed string\n@return true if the hash matches",
"role": "user"
},
{
"content": "public static boolean bcryptMatches(String plain, String storedHash) {\n\t\tif (StringUtils.isBlank(plain) || String... |
[
{
"content": "Generates an authentication token - a random string encoded in Base64.\n@param length the length of the generated token\n@param urlSafe switches to a URL safe encoding\n@return a random string",
"role": "user"
},
{
"content": "public static String generateSecurityToken(int length, bool... |
[
{
"content": "Strips all HTML tags from a string.\n@param html HTML string\n@return just the text",
"role": "user"
},
{
"content": "public static String stripHtml(String html) {\n\t\treturn (html == null) ? \"\" : Jsoup.parse(html).text();\n\t}",
"role": "assistant"
}
] |
[
{
"content": "Abbreviates a string.\n@param str a string\n@param max max length\n@return a substring of that string",
"role": "user"
},
{
"content": "public static String abbreviate(String str, int max) {\n\t\treturn StringUtils.isBlank(str) ? \"\" : StringUtils.abbreviate(str, max);\n\t}",
"rol... |
[
{
"content": "Joins a list of strings to String using a separator.\n@param arr a list of strings\n@param separator a separator string\n@return a string",
"role": "user"
},
{
"content": "public static String arrayJoin(List<String> arr, String separator) {\n\t\treturn (arr == null || separator == null... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.