/** * {@inheritDoc} */ public Object convert(final Object object) { return Base64Decoder.decode((String) object); }
/** * 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 characters(final char[] chars, final int offset, final int length) { if (_decoder != null) { _decoder.translate(new String(chars, offset, length)); } else if (_value != null) { _value.append(chars, offset, length); } } }
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)); } }
throw new SAXException(Messages.format("dsml.closingTagNotRecognized", tagName)); if (_decoder != null) { _attr.addValue(_decoder.getByteArray()); _decoder = null; } else {
public void characters(final char[] chars, final int offset, final int length) { if (_decoder != null) { _decoder.translate(new String(chars, offset, length)); } else if (_value != null) { _value.append(chars, offset, length); } } }
_decoder = new Base64Decoder(); } else { _value = new StringBuffer();
_attr.add(_decoder.getByteArray()); _decoder = null; } else {
/** * Decode binary data and return decoded value. * * @param descriptor {@link XMLFieldDescriptor} instance for the field whose value requires * decoding. * @param binaryData The binary data value to be decoded * @return Decode data. */ byte[] decodeBinaryData(final XMLFieldDescriptor descriptor, final String binaryData) { // -- Base64/HexBinary decoding byte[] decodedValue; if ((descriptor.isMultivalued() && HexDecoder.DATA_TYPE.equals(descriptor.getComponentType())) || HexDecoder.DATA_TYPE.equals(descriptor.getSchemaType())) { decodedValue = HexDecoder.decode(binaryData); } else { decodedValue = Base64Decoder.decode(binaryData); } return decodedValue; }
value = HexDecoder.decode(attValue); } else { value = Base64Decoder.decode(attValue);