/** * Decode given string into a decoded byte array. * * @param str Base64 String to be decoded. * @return All decoded octets as byte array. */ public static byte[] decode(final String str) { Base64Decoder dec = new Base64Decoder(); dec.translate(str); return dec.getByteArray(); }
public void startElement(String tagName, AttributeList attr) throws SAXException { if (tagName.equals(XML.Entries.ELEMENT)) { // Do nothing } else if (tagName.equals(XML.Entries.Elements.ENTRY)) { if (_attrSet != null) throw new SAXException(Messages.format("dsml.openingTagNotRecognized", tagName)); _attrSet = new LDAPAttributeSet(); _entryDN = attr.getValue(XML.Entries.Attributes.DN); } else if (tagName.equals(XML.Entries.Elements.OBJECT_CLASS)) { if (_attrSet == null || _attr != null) throw new SAXException(Messages.format("dsml.openingTagNotRecognized", tagName)); _attr = new LDAPAttribute("objectclass"); } else if (tagName.equals(XML.Entries.Elements.ATTRIBUTE)) { if (_attrSet == null || _attr != null) throw new SAXException(Messages.format("dsml.openingTagNotRecognized", tagName)); _attr = new LDAPAttribute(attr.getValue(XML.Entries.Attributes.NAME)); } else if (tagName.equals(XML.Entries.Elements.VALUE) || tagName.equals(XML.Entries.Elements.OBJECT_CLASS_VALUE)) { if (_attrSet == null || _attr == null || _value != null) throw new SAXException(Messages.format("dsml.openingTagNotRecognized", tagName)); if (XML.Entries.Attributes.Encodings.BASE64 .equals(attr.getValue(XML.Entries.Attributes.ENCODING))) { _decoder = new Base64Decoder(); } else { _value = new StringBuffer(); } } else { throw new SAXException(Messages.format("dsml.openingTagNotRecognized", tagName)); } }
_decoder = new Base64Decoder(); } else { _value = new StringBuffer();