com.sun.org.apache.xerces.internal.impl.dv.util.Base64 Java Examples
The following examples show how to use
com.sun.org.apache.xerces.internal.impl.dv.util.Base64.
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: CodeController.java From sanshanblog with Apache License 2.0 | 6 votes |
/** * 验证码 base64输出 很慢 并且会生成大量的对象 * @param response * @throws IOException */ @GetMapping("/codeValidate") public ResponseMsgVO getCode(HttpServletResponse response) throws IOException { ResponseMsgVO msgVO = new ResponseMsgVO(); String capText = captchaProducer.createText(); BufferedImage buffImg = captchaProducer.createImage(capText); response.setHeader("Pragma", "no-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); response.setContentType("image/png"); //生成一个codeID对应 在三分钟内有效 Long codeId=atomicLong.incrementAndGet(); redisTemplate.opsForValue().set(ConstanceCacheKey.CODE_ID_PREFIX+String.valueOf(codeId), capText,3, TimeUnit.MINUTES); //将图片转换为BASE64编码 ByteArrayOutputStream os = new ByteArrayOutputStream(); ImageIO.write(buffImg, "png", os); byte[] bytes = os.toByteArray(); String imageCode = "data:image/png;base64,"+Base64.encode(bytes); CodeValidateVO codeValidateVO = new CodeValidateVO(imageCode, codeId); return msgVO.buildOKWithData(codeValidateVO); }
Example #2
Source File: PasswordHashTest.java From development with Apache License 2.0 | 6 votes |
/** * Not actully a test case, just to calculate the initial password hash: */ @Test public void calculateInitialPasswordHash() { final int salt = 0; final String password = "admin123"; final byte[] hash = PasswordHash.calculateHash(salt, password); System.out.println("Salt: " + salt); System.out.println("Password: " + password); System.out.printf("Hash Base64: %s", Base64.encode(hash)); System.out.printf("Hash: 0x%x%n", new BigInteger(hash)); System.out.print("Hash: "); for (int i = 0; i < hash.length; i++) { System.out.printf("\\\\%03o", Integer.valueOf(0xFF & hash[i])); } System.out.println(""); System.out.println(Arrays.toString(hash)); }
Example #3
Source File: Base64BinaryDV.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
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 hottub with GNU General Public License v2.0 | 5 votes |
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: LdapUtils.java From spring-boot-demo with MIT License | 5 votes |
/** * 校验密码 * * @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 #6
Source File: Base64BinaryDV.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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 openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 Bytecoder with Apache License 2.0 | 5 votes |
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: Base64BinaryDV.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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 #10
Source File: Base64BinaryDV.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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-jdk8u with GNU General Public License v2.0 | 5 votes |
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 JDKSourceCode1.8 with MIT License | 5 votes |
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 #13
Source File: Signer.java From galaxy-sdk-java with Apache License 2.0 | 5 votes |
/** * A handy version of {@link #sign(HttpMethod, java.net.URI, LinkedListMultimap, * String, SignAlgorithm)}, generates base64 encoded sign result. */ public static String signToBase64(HttpMethod httpMethod, URI uri, LinkedListMultimap<String, String> httpHeaders, String secretAccessKeyId, SignAlgorithm algorithm) throws NoSuchAlgorithmException, InvalidKeyException { return Base64.encode(sign(httpMethod, uri, httpHeaders, secretAccessKeyId, algorithm)); }
Example #14
Source File: Base64BinaryDV.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 #15
Source File: Base64BinaryDV.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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 #16
Source File: Base64BinaryDV.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example #17
Source File: Base64BinaryDV.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example #18
Source File: Image.java From galaxy-sdk-java with Apache License 2.0 | 4 votes |
public void setContent(byte[] content) throws IOException { checkContentLength(content == null ? 0 : content.length); this.rawContent = content; this.content = Base64.encode(content); }
Example #19
Source File: PNGInfo.java From mil-sym-java with Apache License 2.0 | 4 votes |
/** * * @param drawMode 0 - normal, 1 - center, 2 - square * @return */ public String toSVG(int drawMode) { String svg = "<svg></svg>"; if(_image != null) { int x = 0; int y = 0; int width = _image.getWidth(); int height = _image.getHeight(); int svgWidth = width; int svgHeight = height; if(width > 0 && height > 0) { String b64 = "data:image/png;base64," + Base64.encode(getImageAsByteArray()); if(drawMode == 0)//normal { svg = "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" " + "width=\"" + width + "\" height=\"" + height + "\"><image x=\"0\" y=\"0\"" + " width=\"" + width + "\" height=\"" + height + "\" xlink:href=\"" + b64 + "\" /></svg>"; } else if(drawMode == 1)//center { if(_centerPoint.getY() > svgHeight - _centerPoint.getY()) { svgHeight = (int)(_centerPoint.getY() * 2.0); y=0; } else { svgHeight = (int)((svgHeight - _centerPoint.getY()) * 2); y = (int)((svgHeight / 2) - _centerPoint.getY()); } if(_centerPoint.getX() > svgWidth - _centerPoint.getX()) { svgWidth = (int)(_centerPoint.getX() * 2.0); x=0; } else { svgWidth = (int)((svgWidth - _centerPoint.getX()) * 2); x = (int)((svgWidth / 2) - _centerPoint.getX()); } svg = "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" " + "width=\"" + svgWidth + "\" height=\"" + svgHeight + "\"><image x=\"" + x + "\" y=\"" + y + "\"" + " width=\"" + width + "\" height=\"" + height + "\" xlink:href=\"" + b64 + "\" /></svg>"; } else if(drawMode == 2)//square { int newSize = svgHeight; if(svgWidth > svgHeight) newSize = width; if(svgWidth < newSize) x = (int)((newSize - svgWidth)/2.0); if(svgHeight < newSize) y = (int)((newSize - svgHeight)/2.0); svg = "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" " + "width=\"" + newSize + "\" height=\"" + newSize + "\"><image x=\"" + x + "\" y=\"" + y + "\"" + " width=\"" + width + "\" height=\"" + height + "\" xlink:href=\"" + b64 + "\" /></svg>"; } } } return svg; }
Example #20
Source File: Base64BinaryDV.java From hottub with GNU General Public License v2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example #21
Source File: Base64BinaryDV.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example #22
Source File: Base64BinaryDV.java From Bytecoder with Apache License 2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example #23
Source File: Base64BinaryDV.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example #24
Source File: Base64BinaryDV.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example #25
Source File: Base64BinaryDV.java From JDKSourceCode1.8 with MIT License | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example #26
Source File: Base64BinaryDV.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example #27
Source File: Base64BinaryDV.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }
Example #28
Source File: Base64BinaryDV.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
public synchronized String toString() { if (canonical == null) { canonical = Base64.encode(data); } return canonical; }