com.sun.org.apache.xerces.internal.impl.dv.util.HexBin Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.impl.dv.util.HexBin. 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: GenerateKeyImpl.java    From julongchain with Apache License 2.0 6 votes vote down vote up
public static byte[] readfile(String path) throws Exception{
    try {
        File file = new File(path);
        InputStream inputStream = new FileInputStream(file);//文件内容的字节流
        InputStreamReader inputStreamReader= new InputStreamReader(inputStream); //得到文件的字符流
        BufferedReader bufferedReader=new BufferedReader(inputStreamReader); //放入读取缓冲区
        String readd="";
        StringBuffer stringBuffer=new StringBuffer();
        while ((readd=bufferedReader.readLine())!=null) {
            stringBuffer.append(readd);
        }
        inputStream.close();
        String keystr=stringBuffer.toString();
        System.out.println(keystr+" -----> key读取成功");  //读取出来的key是编码之后的 要进行转码
        byte[] keybyte= HexBin.decode(keystr);
        return keybyte;
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
        throw e;
    }       
}
 
Example #2
Source File: HexBinaryDV.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 = HexBin.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "hexBinary"});

    return new XHex(decoded);
}
 
Example #3
Source File: HexBinaryDV.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 = HexBin.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "hexBinary"});

    return new XHex(decoded);
}
 
Example #4
Source File: HexBinaryDV.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 = HexBin.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "hexBinary"});

    return new XHex(decoded);
}
 
Example #5
Source File: HexBinaryDV.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 = HexBin.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "hexBinary"});

    return new XHex(decoded);
}
 
Example #6
Source File: Sign.java    From blockchain with Apache License 2.0 5 votes vote down vote up
public static boolean verify(PublicKey publicKey, String sign, String data) throws Exception {

		X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(publicKey.getEncoded());
		Security.addProvider(new BouncyCastleProvider());
		KeyFactory keyFactory = KeyFactory.getInstance(CryptoConstants.KEY_GEN_ALGORITHM, BouncyCastleProvider.PROVIDER_NAME);
		PublicKey x509PublicKey = keyFactory.generatePublic(x509EncodedKeySpec);
		Signature signature = Signature.getInstance(CryptoConstants.SIGN_ALGORITHM, BouncyCastleProvider.PROVIDER_NAME);
		signature.initVerify(x509PublicKey);
		signature.update(data.getBytes());
		return signature.verify(HexBin.decode(sign));
	}
 
Example #7
Source File: Sign.java    From blockchain with Apache License 2.0 5 votes vote down vote up
public static String sign(PrivateKey privateKey, String data) throws Exception {

		PKCS8EncodedKeySpec pkcs8EncodedKeySpec = new PKCS8EncodedKeySpec(privateKey.getEncoded());
		Security.addProvider(new BouncyCastleProvider());
		KeyFactory keyFactory = KeyFactory.getInstance(CryptoConstants.KEY_GEN_ALGORITHM, BouncyCastleProvider.PROVIDER_NAME);
		PrivateKey pkcs8PrivateKey = keyFactory.generatePrivate(pkcs8EncodedKeySpec);
		Signature signature = Signature.getInstance(CryptoConstants.SIGN_ALGORITHM, BouncyCastleProvider.PROVIDER_NAME);
		signature.initSign(pkcs8PrivateKey);
		signature.update(data.getBytes());
		byte[] res = signature.sign();
		return HexBin.encode(res);
	}
 
Example #8
Source File: HexBinaryDV.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 = HexBin.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "hexBinary"});

    return new XHex(decoded);
}
 
Example #9
Source File: GenerateKeyImpl.java    From julongchain with Apache License 2.0 5 votes vote down vote up
public static void writefile(byte[] raw, String path) throws CspException{
    try {
        String keyencode= HexBin.encode(raw);
        File file=new File(path);
        OutputStream outputStream=new FileOutputStream(file);
        outputStream.write(keyencode.getBytes());
        outputStream.close();
        System.out.println(keyencode+" -----> key保存成功");
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
        throw new CspException("[JC_PKCS_SOFT]:Writefile failed! ErrMessage: %s\", e.getMessage()");
    }
}
 
Example #10
Source File: HexBinaryDV.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 = HexBin.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "hexBinary"});

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

    return new XHex(decoded);
}
 
Example #12
Source File: HexBinaryDV.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 = HexBin.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "hexBinary"});

    return new XHex(decoded);
}
 
Example #13
Source File: HexBinaryDV.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 = HexBin.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "hexBinary"});

    return new XHex(decoded);
}
 
Example #14
Source File: HexBinaryDV.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 = HexBin.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "hexBinary"});

    return new XHex(decoded);
}
 
Example #15
Source File: HexBinaryDV.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 = HexBin.decode(content);
    if (decoded == null)
        throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "hexBinary"});

    return new XHex(decoded);
}
 
Example #16
Source File: HexBinaryDV.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public synchronized String toString() {
    if (canonical == null) {
        canonical = HexBin.encode(data);
    }
    return canonical;
}
 
Example #17
Source File: HexBinaryDV.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public synchronized String toString() {
    if (canonical == null) {
        canonical = HexBin.encode(data);
    }
    return canonical;
}
 
Example #18
Source File: HexBinaryDV.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public synchronized String toString() {
    if (canonical == null) {
        canonical = HexBin.encode(data);
    }
    return canonical;
}
 
Example #19
Source File: HexBinaryDV.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public synchronized String toString() {
    if (canonical == null) {
        canonical = HexBin.encode(data);
    }
    return canonical;
}
 
Example #20
Source File: HexBinaryDV.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public synchronized String toString() {
    if (canonical == null) {
        canonical = HexBin.encode(data);
    }
    return canonical;
}
 
Example #21
Source File: HexBinaryDV.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public synchronized String toString() {
    if (canonical == null) {
        canonical = HexBin.encode(data);
    }
    return canonical;
}
 
Example #22
Source File: HexBinaryDV.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public synchronized String toString() {
    if (canonical == null) {
        canonical = HexBin.encode(data);
    }
    return canonical;
}
 
Example #23
Source File: HexBinaryDV.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public synchronized String toString() {
    if (canonical == null) {
        canonical = HexBin.encode(data);
    }
    return canonical;
}
 
Example #24
Source File: HexBinaryDV.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public synchronized String toString() {
    if (canonical == null) {
        canonical = HexBin.encode(data);
    }
    return canonical;
}
 
Example #25
Source File: HexBinaryDV.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public synchronized String toString() {
    if (canonical == null) {
        canonical = HexBin.encode(data);
    }
    return canonical;
}
 
Example #26
Source File: HexBinaryDV.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public synchronized String toString() {
    if (canonical == null) {
        canonical = HexBin.encode(data);
    }
    return canonical;
}