Example usage for org.apache.wicket.util.crypt Base64 isArrayByteBase64

List of usage examples for org.apache.wicket.util.crypt Base64 isArrayByteBase64

Introduction

In this page you can find the example usage for org.apache.wicket.util.crypt Base64 isArrayByteBase64.

Prototype

public static boolean isArrayByteBase64(final byte[] arrayOctet) 

Source Link

Document

Tests a given byte array to see if it contains only valid characters within the Base64 alphabet.

Usage

From source file:org.xaloon.wicket.util.UrlUtils.java

License:Apache License

/**
 * Decodes provided string from base64/*w w  w .j a va  2  s . c  o m*/
 * 
 * @param value
 * @param preffix
 * @return decoded string from base64
 */
public static String decodeBase64(String value, String preffix) {
    if (StringUtils.isEmpty(value)) {
        return null;
    }
    if (StringUtils.isNotEmpty(preffix) && value.contains(preffix)) {
        value = value.substring(0, value.indexOf(preffix));
    }
    byte[] bytes = value.getBytes();
    if (!Base64.isArrayByteBase64(bytes)) {
        return value;
    }
    return new String(Base64.decodeBase64(bytes));
}