Package org.exist.util

Examples of org.exist.util.Base64Encoder


    if (o instanceof Date) {
      return toDateTime((Date) o).toString();
    } else if (o instanceof Calendar) {
      return toDateTime(((Calendar) o).getTimeInMillis()).toString();
    } else if (o instanceof byte[]) {
      Base64Encoder encoder = new Base64Encoder();
      encoder.translate((byte[]) o);
      return String.valueOf(encoder.getCharArray());
    } else {
      return o;
    }
  }
View Full Code Here


     * @param str  The String to encode
     * @return    The encoded String
     */
    private String encode64 (String str) throws java.io.UnsupportedEncodingException
    {
        Base64Encoder enc = new Base64Encoder();
        enc.translate(str.getBytes(charset));
        String result = new String(enc.getCharArray());

        result = result.replaceAll("\n","?=\n =?" + charset + "?B?");
        result = "=?" + charset + "?B?" + result + "?=";
        return(result);
    }
View Full Code Here

    private String generateSeriesToken() {
        byte[] newSeries = new byte[DEFAULT_SERIES_LENGTH];
        random.nextBytes(newSeries);

        Base64Encoder encoder = new Base64Encoder();
        encoder.translate(newSeries);
        return new String(encoder.getCharArray());
    }
View Full Code Here

    private String generateToken() {
        byte[] newSeries = new byte[DEFAULT_TOKEN_LENGTH];
        random.nextBytes(newSeries);

        Base64Encoder encoder = new Base64Encoder();
        encoder.translate(newSeries);
        return new String(encoder.getCharArray());
    }
View Full Code Here

    private static String badCredentials;
   
   
    @BeforeClass
    public final static void createCredentials() {
        Base64Encoder enc = new Base64Encoder();
        enc.translate("admin:".getBytes());
        credentials = new String(enc.getCharArray());

        enc.reset();
        enc.translate("johndoe:this pw should fail".getBytes());
        badCredentials = new String(enc.getCharArray());
    }
View Full Code Here

            md5.update( message.getBytes() );
            final byte[] digestData = md5.digest();
           
            if(base64)
            {
              final Base64Encoder enc = new Base64Encoder();
              enc.translate(digestData);
              digest = new String(enc.getCharArray());
            }
            else
            {
               digest = byteArrayToHex( digestData );
            }
View Full Code Here

        // Write digest as string
        String digest = null;
        if(base64)
        {
            final Base64Encoder enc = new Base64Encoder();
            enc.translate(digestData);
            digest = new String(enc.getCharArray());

        } else {
           digest = byteArrayToHex( digestData );
        }
View Full Code Here

      if( args.length == 2 ) {
        trim = args[1].effectiveBooleanValue();
      }
 
          if( isCalledAs( "base64-encode" ) ) {
               final Base64Encoder enc = new Base64Encoder();
         
            enc.translate( str.getBytes()  );
       
        if( trim ) {
              value = new StringValue( new String( enc.getCharArray() ).trim() );
        } else {
          value = new StringValue( new String( enc.getCharArray() ) );
        }
          } else {
              final Base64Decoder dec = new Base64Decoder();
       
              dec.translate( str );
View Full Code Here

                      "encoding=\"base64\" " +
                        "transaction_id=\""+transactionID+"\"><![CDATA[";
            String tail =
              "]]></response>";

            Base64Encoder enc = new Base64Encoder();
            enc.translate(source);

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            baos.write(head.getBytes());
            baos.write(new String(enc.getCharArray()).getBytes());
            baos.write(tail.getBytes());
            response = baos.toByteArray();
          } catch (IOException e) {
            response = errorBytes("source");
          }
View Full Code Here

          "<property>";
      String tail =
          "</property>" +
        "</response>";
 
      Base64Encoder enc = new Base64Encoder();
      enc.translate(result.getBytes());
 
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      try {
        baos.write(head.getBytes());
        baos.write(new String(enc.getCharArray()).getBytes());
        baos.write(tail.getBytes());
      } catch (IOException e) {
      }
      response = baos.toByteArray();
      }
View Full Code Here

TOP

Related Classes of org.exist.util.Base64Encoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.