public static String base64encode(String inStr) { return base64encode(inStr.getBytes(Charsets.UTF_8)); }
@Override public String toString(){ StringBuilder sb = new StringBuilder(); sb.append("@Response["); sb.append(statusLine) .append(", ") .append(headers) .append(", ") .append(Util.base64encode(responseBody)) .append(", ") .append(testResult); sb.append("]"); return sb.toString(); } }
private void generate(){ // Check for null String in jtf_in final String inStr = jtf_in.getText(); if(StringUtil.isEmpty(inStr)){ JOptionPane.showMessageDialog(me, "No input entered.", "Error in input.", JOptionPane.ERROR_MESSAGE); return; } // Get if it is encode or decode final String result; if(jrb_encode.isSelected()){ result = Util.base64encode(inStr); } else{ try { result = Util.base64decode(inStr); } catch(Base64Exception ex) { JOptionPane.showMessageDialog(me, ex.getMessage(), "Error in input.", JOptionPane.ERROR_MESSAGE); return; } } jtf_out.setText(result); }
static void populateUsernamePasswordElement(Element eParent, UsernamePasswordAuth auth) { if(StringUtil.isNotEmpty(auth.getUsername())) { Element eUsername = new Element("username"); eUsername.appendChild(auth.getUsername()); eParent.appendChild(eUsername); } if(auth.getPassword() != null && auth.getPassword().length > 0) { Element ePassword = new Element("password"); ePassword.appendChild(Util.base64encode(new String(auth.getPassword()))); eParent.appendChild(ePassword); } }
e.addAttribute(new Attribute("type", req.getKeyStore().getType().name())); e.addAttribute(new Attribute("file", req.getKeyStore().getFile().getAbsolutePath())); e.addAttribute(new Attribute("password", Util.base64encode(new String(req.getKeyStore().getPassword())))); eSsl.appendChild(e); e.addAttribute(new Attribute("type", req.getTrustStore().getType().name())); e.addAttribute(new Attribute("file", req.getTrustStore().getFile().getAbsolutePath())); e.addAttribute(new Attribute("password", Util.base64encode(new String(req.getTrustStore().getPassword())))); eSsl.appendChild(e);
final String base64encodedBody = Util.base64encode(responseBody); respChildSubElement.appendChild(base64encodedBody); respElement.appendChild(respChildSubElement);
eByte.appendChild(Util.base64encode(entity.getBody()));