Java Code Examples for com.sun.org.apache.xerces.internal.impl.dv.util.Base64#decode()

The following examples show how to use com.sun.org.apache.xerces.internal.impl.dv.util.Base64#decode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Base64BinaryDV.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
    byte[] decoded = Base64.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "base64Binary"});

    return new XBase64(decoded);
}
 
Example 2
Source File: Base64BinaryDV.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
    byte[] decoded = Base64.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "base64Binary"});

    return new XBase64(decoded);
}
 
Example 3
Source File: Base64BinaryDV.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
    byte[] decoded = Base64.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "base64Binary"});

    return new XBase64(decoded);
}
 
Example 4
Source File: Base64BinaryDV.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
    byte[] decoded = Base64.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "base64Binary"});

    return new XBase64(decoded);
}
 
Example 5
Source File: Base64BinaryDV.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
    byte[] decoded = Base64.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "base64Binary"});

    return new XBase64(decoded);
}
 
Example 6
Source File: Base64BinaryDV.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
    byte[] decoded = Base64.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "base64Binary"});

    return new XBase64(decoded);
}
 
Example 7
Source File: Base64BinaryDV.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
    byte[] decoded = Base64.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "base64Binary"});

    return new XBase64(decoded);
}
 
Example 8
Source File: Base64BinaryDV.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
    byte[] decoded = Base64.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "base64Binary"});

    return new XBase64(decoded);
}
 
Example 9
Source File: LdapUtils.java    From spring-boot-demo with MIT License 5 votes vote down vote up
/**
 * 校验密码
 *
 * @param ldapPassword  ldap 加密密码
 * @param inputPassword 用户输入
 * @return boolean
 * @throws NoSuchAlgorithmException 加解密异常
 */
public static boolean verify(String ldapPassword, String inputPassword) throws NoSuchAlgorithmException {

    // MessageDigest 提供了消息摘要算法,如 MD5 或 SHA,的功能,这里LDAP使用的是SHA-1
    MessageDigest md = MessageDigest.getInstance("SHA-1");

    // 取出加密字符
    if (ldapPassword.startsWith("{SSHA}")) {
        ldapPassword = ldapPassword.substring(6);
    } else if (ldapPassword.startsWith("{SHA}")) {
        ldapPassword = ldapPassword.substring(5);
    }
    // 解码BASE64
    byte[] ldapPasswordByte = Base64.decode(ldapPassword);
    byte[] shaCode;
    byte[] salt;

    // 前20位是SHA-1加密段,20位后是最初加密时的随机明文
    if (ldapPasswordByte.length <= 20) {
        shaCode = ldapPasswordByte;
        salt = new byte[0];
    } else {
        shaCode = new byte[20];
        salt = new byte[ldapPasswordByte.length - 20];
        System.arraycopy(ldapPasswordByte, 0, shaCode, 0, 20);
        System.arraycopy(ldapPasswordByte, 20, salt, 0, salt.length);
    }
    // 把用户输入的密码添加到摘要计算信息
    md.update(inputPassword.getBytes());
    // 把随机明文添加到摘要计算信息
    md.update(salt);

    // 按SSHA把当前用户密码进行计算
    byte[] inputPasswordByte = md.digest();

    // 返回校验结果
    return MessageDigest.isEqual(shaCode, inputPasswordByte);
}
 
Example 10
Source File: Base64BinaryDV.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
    byte[] decoded = Base64.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "base64Binary"});

    return new XBase64(decoded);
}
 
Example 11
Source File: Base64BinaryDV.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
    byte[] decoded = Base64.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "base64Binary"});

    return new XBase64(decoded);
}
 
Example 12
Source File: Base64BinaryDV.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
    byte[] decoded = Base64.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "base64Binary"});

    return new XBase64(decoded);
}