List of usage examples for org.apache.commons.net.util Base64 decodeBase64
public static byte[] decodeBase64(byte[] base64Data)
From source file:eagle.common.EagleBase64Wrapper.java
public static byte[] decode(String input) { return Base64.decodeBase64(input); }
From source file:mysynopsis.ImageProcess.java
public static BufferedImage toBufferedImage() throws IOException { BufferedImage bufferedImage = null; try {/*w w w . j a v a 2 s . c om*/ byte[] byteArray = Base64.decodeBase64(Variables.imgString); try (InputStream in = new ByteArrayInputStream(byteArray)) { bufferedImage = ImageIO.read(in); } } catch (IOException iOException) { return null; } return bufferedImage; }
From source file:com.os.util.PasswordDecoderEncoder.java
public static String decrypt(String encryptPassword) throws Exception { Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); key = convertHexToBytes(keyst);//from w w w.jav a 2 s . co m final SecretKeySpec secretKey = new SecretKeySpec(key, "AES"); cipher.init(Cipher.DECRYPT_MODE, secretKey); String encryptedString = new String(cipher.doFinal(Base64.decodeBase64(encryptPassword.getBytes())), "UTF-8"); System.out.println(encryptedString); String passwordDecrypted = encryptedString.trim(); return passwordDecrypted; }
From source file:com.qubit.solution.fenixedu.bennu.webservices.services.server.SecurityHeader.java
private String decryptWithSessionKey(String content) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, UnsupportedEncodingException, IllegalBlockSizeException, BadPaddingException { SecretKey originalKey = new SecretKeySpec(this.sessionKey, 0, this.sessionKey.length, "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, originalKey); return new String(cipher.doFinal(Base64.decodeBase64(content)), "UTF-8"); }
From source file:com.qubit.solution.fenixedu.bennu.webservices.services.server.SecurityHeader.java
private byte[] decryptWithPrivateKey(String cipherText, PrivateKey privateKey) throws IOException, GeneralSecurityException { Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.DECRYPT_MODE, privateKey); return cipher.doFinal(Base64.decodeBase64(cipherText)); }
From source file:com.mss.msp.util.DataUtility.java
/** * ************************************* * * @decrypted()/*from w w w. j ava 2s . co m*/ * * @Author:Jagan Chukkala<jchukkala@miraclesoft.com> * * @Created Date:11/18/2015 * * For USe:To Decrypt the string that is encrypted already * * ************************************* */ public static String decrypted(String texto) { return new String(Base64.decodeBase64(texto.getBytes())); }
From source file:eionet.webq.converter.CdrRequestConverter.java
/** * Decodes and parses basic authentication header to username and password. * * @param authHeader authentication header * @return username and password or empty array in case of error. *///from www.j a v a 2 s. c om private String[] extractCredentialsFromBasicAuthorization(String authHeader) throws UnsupportedEncodingException { String encodedCredentials = authHeader.substring(BASIC_AUTHORIZATION_PREFIX.length()); String credentials = new String(Base64.decodeBase64(encodedCredentials), "UTF-8"); return credentials.split(":"); }
From source file:Comman.Tool.java
/** * Decodes the base64 string into byte array * * @param imageDataString - a {@link java.lang.String} * @return byte array/*from w ww .jav a 2 s .c om*/ */ public static byte[] decodeImage(String imageDataString) { return Base64.decodeBase64(imageDataString); }
From source file:com.qubit.solution.fenixedu.bennu.webservices.services.server.BennuWebServiceHandler.java
@Override public boolean handleMessage(SOAPMessageContext context) { Boolean isRequest = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); //for response message only, true for outbound messages, false for inbound if (!isRequest) { try {/*from w w w . ja v a2 s . c om*/ WebServiceServerConfiguration configuration = getWebServiceServerConfiguration( ((com.sun.xml.ws.api.server.WSEndpoint) context.get("com.sun.xml.ws.api.server.WSEndpoint")) .getImplementationClass().getName()); SOAPMessage soapMsg = context.getMessage(); SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope(); SOAPHeader soapHeader = soapEnv.getHeader(); if (!configuration.isActive()) { generateSOAPErrorMessage(soapMsg, "Sorry webservice is disabled at application level!"); } if (configuration.isAuthenticatioNeeded()) { if (configuration.isUsingWSSecurity()) { if (soapHeader == null) { generateSOAPErrorMessage(soapMsg, "No header in message, unabled to validate security credentials"); } String username = null; String password = null; String nonce = null; String created = null; Iterator<SOAPElement> childElements = soapHeader.getChildElements(QNAME_WSSE_SECURITY); if (childElements.hasNext()) { SOAPElement securityElement = childElements.next(); Iterator<SOAPElement> usernameTokens = securityElement .getChildElements(QNAME_WSSE_USERNAME_TOKEN); if (usernameTokens.hasNext()) { SOAPElement usernameToken = usernameTokens.next(); username = ((SOAPElement) usernameToken.getChildElements(QNAME_WSSE_USERNAME) .next()).getValue(); password = ((SOAPElement) usernameToken.getChildElements(QNAME_WSSE_PASSWORD) .next()).getValue(); nonce = ((SOAPElement) usernameToken.getChildElements(QNAME_WSSE_NONCE).next()) .getValue(); created = ((SOAPElement) usernameToken.getChildElements(QNAME_WSSE_CREATED).next()) .getValue(); } } if (username == null || password == null || nonce == null || created == null) { generateSOAPErrorMessage(soapMsg, "Missing information, unabled to validate security credentials"); } SecurityHeader securityHeader = new SecurityHeader(configuration, username, password, nonce, created); if (!securityHeader.isValid()) { generateSOAPErrorMessage(soapMsg, "Invalid credentials"); } else { context.put(BennuWebService.SECURITY_HEADER, securityHeader); context.setScope(BennuWebService.SECURITY_HEADER, Scope.APPLICATION); } } else { com.sun.xml.ws.transport.Headers httpHeader = (Headers) context .get(MessageContext.HTTP_REQUEST_HEADERS); String username = null; String password = null; List<String> list = httpHeader.get("authorization"); if (list != null) { for (String value : list) { if (value.startsWith("Basic")) { String[] split = value.split(" "); try { String decoded = new String(Base64.decodeBase64(split[1]), "UTF-8"); String[] split2 = decoded.split(":"); if (split2.length == 2) { username = split2[0]; password = split2[1]; } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } } } if (username == null || password == null) { generateSOAPErrorMessage(soapMsg, "Missing information, unabled to validate security credentials"); } if (!configuration.validate(username, password)) { generateSOAPErrorMessage(soapMsg, "Invalid credentials"); } } } } catch (SOAPException e) { System.err.println(e); } } //continue other handler chain return true; }
From source file:com.adaptris.security.StdOutput.java
/** * Split this encrypted payload into it's constituent parts. * // w ww . j av a 2 s . com * @see #readEncryptedMesage(byte[]) * @throws IOException if we can't read the message * @throws Base64Exception if the message is not correctly encoded */ private void split() throws IOException { ByteArrayInputStream byteStream = new ByteArrayInputStream(Base64.decodeBase64(message)); DataInputStream in = new DataInputStream(byteStream); setSessionVector(read(in)); setSessionKey(read(in)); setEncryptedData(read(in)); setSignature(read(in)); in.close(); byteStream.close(); }