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

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

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

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

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

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

/**
 * 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

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

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

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);
   }
 }
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 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

 /**
  * 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

private void writeAttribute(LDAPAttribute attr, StringBuffer buff) 
    throws java.io.IOException
{
  buff.append(ValueXMLhandler.newLine(1));
  buff.append("<attr name=\"");
  buff.append(attr.getName());
  buff.append("\">");

   String values[] = attr.getStringValueArray();
   byte bytevalues[][] = attr.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>");
     }

   }
   buff.append(ValueXMLhandler.newLine(1));
   buff.append("</attr>");        
}
origin: com.novell.ldap/jldap

private void writeAttribute(LDAPAttribute attr, StringBuffer buff) 
    throws java.io.IOException
{
  buff.append(ValueXMLhandler.newLine(2));
  buff.append("<attr name=\"");
  buff.append(attr.getName());
  buff.append("\">");
   String values[] = attr.getStringValueArray();
   byte bytevalues[][] = attr.getByteValueArray();
   for(int i=0; i<values.length; i++){
     buff.append(ValueXMLhandler.newLine(3));
     
     if (Base64.isValidUTF8(bytevalues[i], false)){
       buff.append("<value><![CDATA[");
       buff.append(values[i]);
       buff.append("]]></value>");
     } else {
       buff.append("<value xsi:type=\"xsd:base64Binary\"><![CDATA[");
       buff.append(Base64.encode(bytevalues[i]));
       buff.append("]]></value>");
     }
   }
   buff.append(ValueXMLhandler.newLine(2));
   buff.append("</attr>");        
}

origin: com.novell.ldap/jldap

private void writeAttribute(LDAPAttribute attr, StringBuffer buff) 
    throws java.io.IOException
{
  buff.append(ValueXMLhandler.newLine(1));
  buff.append("<attr name=\"");
  buff.append(attr.getName());
  buff.append("\">");
   String values[] = attr.getStringValueArray();
   byte bytevalues[][] = attr.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>");
     }
   }
   buff.append(ValueXMLhandler.newLine(1));
   buff.append("</attr>");        
}
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

/**
 * Writes a control in DSML.
 * <p>Used by writeResult and by the searchResponse case in writeMessage.
 * @param controls Controls to be written
 * @param indent  Size of indentation for writting.
 */
private void writeControls(LDAPControl[] controls, int indent)
    throws IOException
{
  for(int i=0; i<controls.length; i++){
    newLine(indent);
    out.write("<control type=\"");
    out.write(controls[i].getID());
    out.write("\" criticality=\""+controls[i].isCritical()+ "\"");
    byte value[] = controls[i].getValue();
    if (value == null){
      out.write(" / >");
    } else {
      out.write(">");
      newLine(indent+1);
      out.write("<controlValue xsi:type=\"xsd:base64Binary\">");
      out.write(Base64.encode(value));
      out.write("</controlValue>");
      newLine(indent);
      out.write("</control>");
    }
  }
  return;
}
origin: com.novell.ldap/jldap

private void writeAttribute(LDAPAttribute attr,java.io.Writer out) 
throws java.io.IOException
{
  newLine(2,out);
  out.write("<attr name=\"");
  out.write(attr.getName());
  out.write("\">");
  String values[] = attr.getStringValueArray();
  byte bytevalues[][] = attr.getByteValueArray();
  for(int i=0; i<values.length; i++){
    newLine(3,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>");
    }
  }
  newLine(2,out);
  out.write("</attr>");
  
}
origin: com.novell.ldap/jldap

private void writeAttribute(LDAPAttribute attr,java.io.Writer out) 
throws java.io.IOException
{
  newLine(1,out);
  out.write("<attr name=\"");
  out.write(attr.getName());
  out.write("\">");
  String values[] = attr.getStringValueArray();
  byte bytevalues[][] = attr.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>");
    }
  }
  newLine(1,out);
  out.write("</attr>");
  
}
origin: com.novell.ldap/jldap

/**
 * Used to write an attribute and its values.
 * @param attr Attribute to be written.
 */
private void writeAttribute(LDAPAttribute attr) throws IOException
{
  newLine(3);
  out.write("<attr name=\"");
  out.write(attr.getName());
  out.write("\">");
  String values[] = attr.getStringValueArray();
  byte bytevalues[][] = attr.getByteValueArray();
  for(int i=0; i<values.length; i++){
    newLine(4);
    
    if (Base64.isValidUTF8(bytevalues[i],true) && this.isXMLSafe(bytevalues[i])){
      out.write("<value>");
      String xmlvalue = makeAttributeSafe(values[i]);
      out.write(xmlvalue);
      out.write("</value>");
    } else {
      out.write("<value xsi:type=\"xsd:base64Binary\">");
      out.write(Base64.encode(bytevalues[i]));
      out.write("</value>");
    }
  }
  newLine(3);
  out.write("</attr>");
  return;
}
origin: com.novell.ldap/jldap

private void writeExtendedRequestEntry( LDAPExtendedRequest request,
                LDAPControl[] controls,
                String requestID)
    throws IOException, LDAPLocalException
{
  checkState(false);
  
  newLine(2);
  out.write("<requestName>");
  out.write(request.getExtendedOperation().getID());
  out.write("</requestName>");
  byte[] vals=request.getExtendedOperation().getValue();
  if( vals != null)
  {
    newLine(2);
    out.write("<requestValue xsi:type=\"xsd:base64Binary\">");
    out.write(Base64.encode(vals));
    out.write("</requestValue>");
  }
  
  //		  added this fix for OCT' 04 NDK
  if( (controls !=null) && (controls.length != 0)) {
    writeControls(controls, 3);
  }
      
  newLine(1);
  out.write("</extendedRequest>");
  return;
}    

origin: com.novell.ldap/jldap

/**
 * Write control line(s).
 *
 * @param ctrls LDAPControl array object
 */
private void writeControls(LDAPControl[] ctrls)
      throws IOException
{
  for ( int i = 0; i < ctrls.length; i++ ) {
    // get control value
    byte[] cVal = ctrls[i].getValue();
    // write control value
    writeLine( (cVal != null && cVal.length > 0)?
      "control: " + ctrls[i].getID() + " " + ctrls[i].isCritical()
            + ":: " + Base64.encode(cVal):
      "control: " + ctrls[i].getID() + " " + ctrls[i].isCritical() );
  }
  return;
}
com.novell.ldap.utilBase64encode

Javadoc

Encodes the specified String into a base64 encoded String object.

Popular methods of Base64

  • decode
    Decodes the input base64 encoded array of characters. The resulting binary data is returned as an ar
  • 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

  • Reactive rest calls using spring rest template
  • getSystemService (Context)
  • setScale (BigDecimal)
  • addToBackStack (FragmentTransaction)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • JPanel (javax.swing)
  • JTable (javax.swing)
  • Top plugins for WebStorm
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