Java Code Examples for org.apache.commons.lang3.StringUtils.right()

The following are Jave code examples for showing how to use right() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: springboot-shiro-cas-mybatis   File: CasDelegatingLogger.java   View Source Code Vote up 6 votes
/**
 * Remove ticket id from the log message.
 *
 * @param msg the message
 * @return the modified message with tgt id removed
 */
private String removeTicketId(final String msg) {
    String modifiedMessage = msg;

    if (StringUtils.isNotBlank(msg)) {
        final Matcher matcher = TICKET_ID_PATTERN.matcher(msg);
        while (matcher.find()) {
            final String match = matcher.group();
            final String newId = matcher.group(1) + '-'
                    + StringUtils.repeat("*", match.length() - VISIBLE_ID_TAIL_LENGTH)
                    + StringUtils.right(match, VISIBLE_ID_TAIL_LENGTH);

            modifiedMessage = modifiedMessage.replaceAll(match, newId);
        }
    }
    return modifiedMessage;
}
 
Example 2
Project: springboot-shiro-cas-mybatis   File: CasDelegatingLogger.java   View Source Code Vote up 6 votes
/**
 * Remove ticket id from the log message.
 *
 * @param msg the message
 * @return the modified message with tgt id removed
 */
private String removeTicketId(final String msg) {
    String modifiedMessage = msg;

    if (StringUtils.isNotBlank(msg)) {
        final Matcher matcher = TICKET_ID_PATTERN.matcher(msg);
        while (matcher.find()) {
            final String match = matcher.group();
            final String newId = matcher.group(1) + '-'
                    + StringUtils.repeat("*", match.length() - VISIBLE_ID_TAIL_LENGTH)
                    + StringUtils.right(match, VISIBLE_ID_TAIL_LENGTH);

            modifiedMessage = modifiedMessage.replaceAll(match, newId);
        }
    }
    return modifiedMessage;
}
 
Example 3
Project: cas-server-4.2.1   File: CasDelegatingLogger.java   View Source Code Vote up 6 votes
/**
 * Remove ticket id from the log message.
 *
 * @param msg the message
 * @return the modified message with tgt id removed
 */
private String removeTicketId(final String msg) {
    String modifiedMessage = msg;

    if (StringUtils.isNotBlank(msg)) {
        final Matcher matcher = TICKET_ID_PATTERN.matcher(msg);
        while (matcher.find()) {
            final String match = matcher.group();
            final String newId = matcher.group(1) + '-'
                    + StringUtils.repeat("*", match.length() - VISIBLE_ID_TAIL_LENGTH)
                    + StringUtils.right(match, VISIBLE_ID_TAIL_LENGTH);

            modifiedMessage = modifiedMessage.replaceAll(match, newId);
        }
    }
    return modifiedMessage;
}
 
Example 4
Project: cas-5.1.0   File: TicketIdSanitizationUtils.java   View Source Code Vote up 5 votes
/**
 * Remove ticket id from the message.
 *
 * @param msg the message
 * @return the modified message with tgt id removed
 */
public static String sanitize(final String msg) {
    String modifiedMessage = msg;
    if (StringUtils.isNotBlank(msg) && !Boolean.getBoolean("CAS_TICKET_ID_SANITIZE_SKIP")) {
        final Matcher matcher = TICKET_ID_PATTERN.matcher(msg);
        while (matcher.find()) {
            final String match = matcher.group();
            final String newId = matcher.group(1) + '-'
                    + StringUtils.repeat("*", match.length() - VISIBLE_TAIL_LENGTH)
                    + StringUtils.right(match, VISIBLE_TAIL_LENGTH);
            modifiedMessage = modifiedMessage.replaceAll(match, newId);
        }
    }
    return modifiedMessage;
}
 
Example 5
Project: xm-commons   File: MdcUtils.java   View Source Code Vote up 5 votes
/**
 * Generates request id based on UID and SHA-256.
 *
 * @return request identity
 */
public static String generateRid() {
    byte[] encode = Base64.getEncoder().encode(DigestUtils.sha256(UUID.randomUUID().toString()));
    try {
        String rid = new String(encode, StandardCharsets.UTF_8.name());
        rid = StringUtils.replaceChars(rid, "+/=", "");
        return StringUtils.right(rid, RID_LENGTH);
    } catch (UnsupportedEncodingException e) {
        throw new IllegalStateException(e);
    }
}
 
Example 6
Project: uroborosql   File: StringFunction.java   View Source Code Vote up 2 votes
/**
 * 文字列の最後から指定した文字数の文字列を取得する
 *
 * <pre>
 * StringUtils.right(null, *)    = null
 * StringUtils.right(*, -ve)     = ""
 * StringUtils.right("", *)      = ""
 * StringUtils.right("abc", 0)   = ""
 * StringUtils.right("abc", 2)   = "bc"
 * StringUtils.right("abc", 4)   = "abc"
 * </pre>
 *
 * @param str 対象文字列
 * @param len 文字数
 * @return 文字列の最後から文字数で指定した長さの文字列
 */
public String right(final String str, final int len) {
	return StringUtils.right(str, len);
}