congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Base64
Code IndexAdd Tabnine to your IDE (free)

How to use
Base64
in
com.novell.ldap.util

Best Java code snippets using com.novell.ldap.util.Base64 (Showing top 20 results out of 315)

origin: com.novell.ldap/jldap

/**
 * Decodes the input base64 encoded String.
 * The resulting binary data is returned as an array of bytes.
 *
 * @param encodedString The base64 encoded String object.
 *
 * @return The decoded byte array.
 */
public static final byte[] decode(String encodedString)
{
  char[] c = new char[encodedString.length()];
  encodedString.getChars(0, encodedString.length(), c, 0);
  return decode(c);
}
origin: com.novell.ldap/jldap

private String byte2String(byte[] value)
{
  String text = null;
  if (Base64.isValidUTF8(value, false)){
    try {
      text = new String(value, "UTF-8");
    } catch (UnsupportedEncodingException uee) {
      throw new RuntimeException(
          "UTF-8 not supported by JVM" + uee);
    }
  } else {
    text = Base64.encode(value);
  }
  return text;
}
origin: com.novell.ldap/jldap

int count = getByteCount(array[index]);
if (count == 0){
origin: com.novell.ldap/jldap

/**
 * Write the DN to the outputStream.  If the DN characters are unsafe,
 * the DN is encoded.
 *
 * @param dn the DN to write
 */
private void writeDN(String dn)
      throws IOException
{
  writeLine(Base64.isLDIFSafe(dn)? "dn: "+dn: "dn:: "+ Base64.encode(dn));
  return;
}
origin: com.novell.ldap/jldap

/**
 * Encodes the specified String into a base64 encoded String object.
 *
 * @param inputString  The String object to be encoded.
 *
 * @return a String containing the encoded value of the input.
 */
public static final String encode(String inputString)
{
  try {
    return encode(inputString.getBytes("UTF-8"));
  } catch( UnsupportedEncodingException ue) {
    throw new RuntimeException(
        "US-ASCII String encoding not supported by JVM");
  }
}
origin: com.novell.ldap/jldap

if (com.novell.ldap.util.Base64.isValidUTF8(value, true)) {
  try {
    toReturn = new String(value, "UTF-8");
origin: com.novell.ldap/jldap

  return( isLDIFSafe(str.getBytes("UTF-8")));
} catch( UnsupportedEncodingException ue) {
  throw new RuntimeException(
origin: com.novell.ldap/jldap

/**
 * Write attribute name and value into outputStream.
 *
 * <p>Check if attrVal starts with NUL, LF, CR, ' ', ':', or '<'
 * or contains any NUL, LF, or CR, and then write it out</p>
 */
private void writeAttribute(String attrName, String attrVal)
      throws IOException
{
  if (attrVal != null) {
    writeLine( Base64.isLDIFSafe(attrVal)?
      attrName + ": "  + attrVal :
      attrName + ":: " + Base64.encode(attrVal) );
  }
  return;
}
origin: com.novell.ldap/jldap

private void writeControls(Element e, LDAPControl[] controls)
{
  for (int i=0; i< controls.length; i++){
    Element el = doc.createElement("control");
    el.setAttribute("NumericOID", controls[i].getID());
    el.setAttribute("criticality", ""+controls[i].isCritical());
    byte byteValue[] = controls[i].getValue();
    if (byteValue!= null){
      Element value = doc.createElement("controlValue");
      value.setAttribute("xsi:type", "base64Binary");
      Text text = doc.createTextNode( Base64.encode(byteValue));
      value.appendChild(text);
      el.appendChild(value);
    }
    e.appendChild( el );
  }
}
origin: com.novell.ldap/jldap

private static String byteString(byte[] value) {
  String toReturn = null;
  if (com.novell.ldap.util.Base64.isValidUTF8(value, true)) {
    try {
      toReturn = new String(value, "UTF-8");
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(
          "Default JVM does not support UTF-8 encoding" + e);
    }
  } else {
    StringBuffer binary = new StringBuffer();
    for (int i=0; i<value.length; i++){
      //TODO repair binary output
      //Every octet needs to be escaped
      if (value[i] >=0) {
        //one character hex string
        binary.append("\\0");
        binary.append(Integer.toHexString(value[i]));
      } else {
        //negative (eight character) hex string
        binary.append("\\"+
            Integer.toHexString(value[i]).substring(6));
      }
    }
    toReturn = binary.toString();
  }
  return toReturn;
}

origin: com.novell.ldap/jldap

protected void writeValue(java.io.Writer out) throws IOException {
    String values[] = getStringValueArray();
   byte bytevalues[][] = getByteValueArray();
   for(int i=0; i<values.length; i++){
     newLine(2,out);
     if (Base64.isValidUTF8(bytevalues[i], false)){
       out.write("<value>");
       out.write(values[i]);
       out.write("</value>");
     } else {
       out.write("<value xsi:type=\"xsd:base64Binary\">");
       out.write(Base64.encode(bytevalues[i]));
       out.write("</value>");
     }
   }
}        
  
origin: com.novell.ldap/jldap

/**
 * Write attribute name and value into outputStream.
 *
 * <p>Check if attribute value contains NON-SAFE-INIT-CHAR or
 * NON-SAFE-CHAR. if it does, it needs to be base64 encoded and then
 * write it out</p>
 */
private void writeAttribute(String attrName, byte[] attrVal)
      throws IOException
{
  if (attrVal != null) {
    writeLine( (Base64.isLDIFSafe(attrVal) && isPrintable(attrVal))?
      attrName + ": " + new String(attrVal, "UTF-8"):
      attrName + ":: " + Base64.encode(attrVal) );
  }
  return;
}
origin: com.novell.ldap/jldap

private void writeControl(LDAPControl control, StringBuffer buff) 
throws java.io.IOException
 {
    buff.append("<control type=\"");
   buff.append(control.getID());
   buff.append("\" criticality=\""+ control.isCritical()+ "\"");
   byte value[] = control.getValue();
   if (value == null){
     buff.append("/>");
   } else {
     buff.append(">");
     buff.append(ValueXMLhandler.newLine(2));
     buff.append("<controlValue xsi:type=\"xsd:base64Binary\">");
     buff.append(Base64.encode(value));
     buff.append("</controlValue>");
     buff.append(ValueXMLhandler.newLine(1));
     buff.append("</control>");
   }
   buff.append(ValueXMLhandler.newLine(0));
 }
origin: com.novell.ldap/jldap

/**
 * Adds a base64 encoded value to the attribute.
 * The value will be decoded and stored as bytes.  String
 * data encoded as a base64 value must be UTF-8 characters.
 *
 * @param attrString The base64 value of the attribute as a String.
 *
 * @throws IllegalArgumentException if attrString is null
 */
public void addBase64Value(String attrString)
{
  if( attrString == null) {
    throw new IllegalArgumentException("Attribute value cannot be null");
  }
  this.add( Base64.decode(attrString));
  return;
}
origin: com.novell.ldap/jldap

if (com.novell.ldap.util.Base64.isValidUTF8(value, true)) {
  try {
    toReturn = new String(value, "UTF-8");
origin: com.novell.ldap/jldap

protected void writeValue(StringBuffer buff){
  
 String values[] = getStringValueArray();
 byte bytevalues[][] = getByteValueArray();
 for(int i=0; i<values.length; i++){
   buff.append(ValueXMLhandler.newLine(2));
   if (Base64.isValidUTF8(bytevalues[i], false)){
     buff.append("<value>");
     buff.append(values[i]);
     buff.append("</value>");
   } else {
     buff.append("<value xsi:type=\"xsd:base64Binary\">");
     buff.append(Base64.encode(bytevalues[i]));
     buff.append("</value>");
   }
 }

}
 
origin: com.novell.ldap/jldap

writeLine( Base64.isLDIFSafe(newRDN)?
  "newrdn: "  + newRDN:
  "newrdn:: " + Base64.encode(newRDN));
  writeLine( Base64.isLDIFSafe(newSuperior)?
    "newsuperior: "  + newSuperior:
    "newsuperior:: " +  Base64.encode(newSuperior));
origin: com.novell.ldap/jldap

 /**
  * This method does DSML serialization of the instance.
  *
  * @param oout Outputstream where the serialzed data has to be written
  *
  * @throws IOException if write fails on OutputStream 
  */    
 public void writeDSML(java.io.OutputStream  oout) throws java.io.IOException
 {
   java.io.Writer out=new java.io.OutputStreamWriter(oout,"UTF-8");
   out.write("<LDAPExtendedOperation>");
   newLine(1,out);
   out.write("<requestName>");
   out.write(getID());
   out.write("</requestName>");
   byte[] vals=getValue();
   if( vals != null)
   {
     newLine(1,out);
     out.write("<requestValue xsi:type=\"xsd:base64Binary\">");
     out.write(Base64.encode(vals));
     out.write("</requestValue>");
   }
   newLine(0,out);
   out.write("</LDAPExtendedOperation>");
   out.close();
 }
/**
origin: com.novell.ldap/jldap

/**
 * Adds a base64 encoded value to the attribute.
 * The value will be decoded and stored as bytes.  Character
 * data encoded as a base64 value must be UTF-8 characters.
 *
 * @param attrChars The base64 value of the attribute as an array of
 * characters.
 *
 * @throws IllegalArgumentException if attrString is null
 */
public void addBase64Value(char[] attrChars)
{
  if( attrChars == null) {
    throw new IllegalArgumentException("Attribute value cannot be null");
  }
  this.add( Base64.decode(attrChars));
  return;
}
origin: com.novell.ldap/jldap

private void writeAttribute(Element attribute, LDAPAttribute attr)
{
   attribute.setAttribute("name", attr.getName());
   String values[] = attr.getStringValueArray();
   byte bytevalues[][] = attr.getByteValueArray();
   for(int i=0; i<values.length; i++){
     Element value = doc.createElement("value");
     if (Base64.isValidUTF8(bytevalues[i], false)){
       value.appendChild(doc.createTextNode(values[i]));
     } else {
       value.setAttribute("xsi:type", "base64Binary");
       value.appendChild(doc.createTextNode(
           Base64.encode(bytevalues[i])));
     }
     attribute.appendChild(value);
   }
 }
com.novell.ldap.utilBase64

Javadoc

The Base64 utility class performs base64 encoding and decoding. The Base64 Content-Transfer-Encoding is designed to represent arbitrary sequences of octets in a form that need not be humanly readable. The encoding and decoding algorithms are simple, but the encoded data are consistently only about 33 percent larger than the unencoded data. The base64 encoding algorithm is defined by RFC 2045.

Most used methods

  • decode
    Decodes the input base64 encoded array of characters. The resulting binary data is returned as an ar
  • encode
    Encodes the specified bytes into a base64 array of bytes. Each byte in the return array represents a
  • getByteCount
    Given the first byte in a sequence, getByteCount returns the number of additional bytes in a UTF-8 c
  • isLDIFSafe
    Checks if the input byte array contains only safe values, that is, the data does not need to be enco
  • isValidUTF8
    Determines if an array of bytes contains only valid UTF-8 characters. UTF-8 is the standard encoding

Popular in Java

  • Parsing JSON documents to java classes using gson
  • compareTo (BigDecimal)
  • getSystemService (Context)
  • getSharedPreferences (Context)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • Menu (java.awt)
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now