List of usage examples for org.apache.commons.lang3 StringUtils overlay
public static String overlay(final String str, String overlay, int start, int end)
Overlays part of a String with another String.
A null string input returns null .
From source file:com.github.achatain.nopasswordauthentication.utils.ExtendedStringUtils.java
public static String obfuscate(String str, int visible) { String defaultStr = StringUtils.defaultString(str); if (defaultStr.length() > visible) return StringUtils.overlay(defaultStr, STARS, 0, defaultStr.length() - visible); return STARS; }
From source file:com.gst.portfolio.client.domain.AccountNumberGenerator.java
private String generateAccountNumber(Map<String, String> propertyMap, AccountNumberFormat accountNumberFormat) { String accountNumber = StringUtils.leftPad(propertyMap.get(ID), AccountNumberGenerator.maxLength, '0'); if (accountNumberFormat != null && accountNumberFormat.getPrefixEnum() != null) { AccountNumberPrefixType accountNumberPrefixType = AccountNumberPrefixType .fromInt(accountNumberFormat.getPrefixEnum()); String prefix = null;//from w w w .ja v a 2s . c o m switch (accountNumberPrefixType) { case CLIENT_TYPE: prefix = propertyMap.get(CLIENT_TYPE); break; case OFFICE_NAME: prefix = propertyMap.get(OFFICE_NAME); break; case LOAN_PRODUCT_SHORT_NAME: prefix = propertyMap.get(LOAN_PRODUCT_SHORT_NAME); break; case SAVINGS_PRODUCT_SHORT_NAME: prefix = propertyMap.get(SAVINGS_PRODUCT_SHORT_NAME); break; default: break; } accountNumber = StringUtils.overlay(accountNumber, prefix, 0, 0); } return accountNumber; }
From source file:com.github.dactiv.fear.user.web.AccountController.java
/** * ???/* w ww . jav a2s . c o m*/ * * @param username * @param captcha ?? * @param request http servlet request * * @return ??:WEB-INF/page/index.ftl * * @throws Exception */ @RequestMapping(value = "forgot-password", method = { RequestMethod.GET, RequestMethod.POST }) public String forgotPassword(String username, String captcha, HttpServletRequest request) throws Exception { if (request.getMethod().equals(HttpMethod.GET.name())) { return "/forgot-password"; } else { Map<String, Object> user; try { user = accountService.forgotPassword(username, captcha); } catch (ServiceException e) { request.setAttribute("message", e.getMessage()); return "/forgot-password"; } String email = Casts.cast(user.get("email"), String.class); request.setAttribute("email", StringUtils.overlay(email, "******", 4, email.indexOf("@"))); return "reset-password-mail-send"; } }
From source file:org.audit4j.core.annotation.DeIdentifyUtil.java
/** * Deidentify left./* w w w.ja va 2 s . c om*/ * * @param str the str * @param size the size * @return the string * * @since 2.0.0 */ public static String deidentifyLeft(String str, int size) { int repeat; if (size > str.length()) { repeat = str.length(); } else { repeat = size; } return StringUtils.overlay(str, StringUtils.repeat('*', repeat), 0, size); }
From source file:org.audit4j.core.annotation.DeIdentifyUtil.java
/** * Deidentify right./*from w w w. j av a2 s. c om*/ * * @param str the str * @param size the size * @return the string * * @since 2.0.0 */ public static String deidentifyRight(String str, int size) { int end = str.length(); int repeat; if (size > str.length()) { repeat = str.length(); } else { repeat = size; } return StringUtils.overlay(str, StringUtils.repeat('*', repeat), end - size, end); }
From source file:org.audit4j.core.annotation.DeIdentifyUtil.java
/** * Deidentify from left./* w ww. j a v a 2 s . co m*/ * * @param str the str * @param size the size * @return the string * * @since 2.0.0 */ public static String deidentifyFromLeft(String str, int size) { int end = str.length(); int repeat; if (size > str.length()) { repeat = 0; } else { repeat = str.length() - size; } return StringUtils.overlay(str, StringUtils.repeat('*', repeat), size, end); }
From source file:org.audit4j.core.annotation.DeIdentifyUtil.java
/** * Deidentify from right.//from ww w . j av a 2 s. c om * * @param str the str * @param size the size * @return the string * * @since 2.0.0 */ public static String deidentifyFromRight(String str, int size) { int end = str.length(); int repeat; if (size > str.length()) { repeat = str.length(); } else { repeat = end - size; } return StringUtils.overlay(str, StringUtils.repeat('*', repeat), 0, end - size); }
From source file:org.audit4j.core.annotation.DeIdentifyUtil.java
/** * Deidentify middle.//from w ww .ja v a 2 s.co m * * @param str the str * @param start the start * @param end the end * @return the string * * @since 2.0.0 */ public static String deidentifyMiddle(String str, int start, int end) { int repeat; if (end - start > str.length()) { repeat = str.length(); } else { repeat = (str.length() - end) - start; } return StringUtils.overlay(str, StringUtils.repeat('*', repeat), start, str.length() - end); }
From source file:org.audit4j.core.DeIndentifyUtil.java
/** * Deidentify left./* www. jav a2s . c om*/ * * @param str the str * @param size the size * @return the string * * @since 2.0.0 */ public static String deidentifyLeft(String str, int size) { int repeat = 0; if (size > str.length()) { repeat = str.length(); } else { repeat = size; } return StringUtils.overlay(str, StringUtils.repeat('*', repeat), 0, size); }
From source file:org.audit4j.core.DeIndentifyUtil.java
/** * Deidentify right.//from www . java2 s .c om * * @param str the str * @param size the size * @return the string * * @since 2.0.0 */ public static String deidentifyRight(String str, int size) { int end = str.length(); int repeat = 0; if (size > str.length()) { repeat = str.length(); } else { repeat = size; } return StringUtils.overlay(str, StringUtils.repeat('*', repeat), end - size, end); }