Showing posts with label encoder. Show all posts
Showing posts with label encoder. Show all posts

Thursday, July 30, 2009

Encoder 0.5.1

I'd like to announce the release of Encoder 0.5.1 with the fix of Issue 24 (thanks to Anton for pointing this out)

In addition I've finally moved the build of Encoder's distribution to maven, so 0.5.1 contains both the Eclipse plugin and the standalone version.

Enjoy :)

Tuesday, June 9, 2009

Encoder 0.5.0

It's was a long time, since the previous release of the Encoder. Actually I didn't work much on the Encoder's functionality, but I did a lot of enhancements to the Dynamic Dialogs functionality. Interesting if someone, but me, really uses it...

Anyway 0.5.0 version is ready. It requires Java 6 and Eclipse 3.4.2.
Apart of enhancement to the Dynamic Dialogs it includes the following features:
1. Hitting Ctrl+A in the text areas will perform "Select All".
2. The text areas now support different encodings when transforming from text to bytes.
3. The input text area was enhanced with "Import" functionality, which allows importing a binary file to the input text area.
4. Both input and output text areas were enhanced with the "Export" functionality that save the content of the area to a file. For text, the defined encoding will be used.

I didn't create a standalone distribution this time, but only an Eclipse plugin. If you want it as standalone, please let me know in the comments, and I'll create it for you.

Enjoy :)

Monday, November 24, 2008

Encoder's Downloads Statistics

You can call me bored, but here are some statistics of downloads of the Encoder Tool:
VersionAvailable (days)DownloadsDownloads per day
0.1.0 Plugin10161.6
0.1.0 Zip1010.1
0.2.0 Plugin20321.6
0.2.0+0.2.1 Zip20412.05
0.3.0 Plugin56440.78
0.3.0 Zip56571.02

Total: 191 downloads

Interesting how many people are continue to use it occasionally. And how many people are checking for the new versions.
Unlike the tarlog-plugins, I didn't receive any issues regarding the encoder. May be there are no bugs... Or may be nobody uses it... But there are 191 downloads.

Anyway, if you are using the encoder and you are reading this post, I will really appreciate your feedback. Any feedback.

Thanks for reading :-)

Sunday, November 23, 2008

Encoder 0.4.0

The new iteration of the Encoder was just released. Previously, I planned to release an iteration once a month, but I had almost nothing to release at the end of October and it took some more time to code new features.
And the new features are:

1. History of steps was added. So the user can restore the input and output of a specific step and start it over.
2. Enable flag was added to encoders and encoder groups. The flag can be changed from the Properties. Only the enabled encoders will appear in the UI.
3. "Escaping" encoder was added. This encoder performs the following escapings: Escape XML, Unescape XML, Escape HTML, Unescape HTML, Escape Java, Unescape Java, Escape Javascript, Unescape Javascript and Escape Sql. This encoder is based on the org.apache.commons.lang.StringEscapeUtils.

Enjoy!

Sunday, September 28, 2008

Encoder 0.3.0

A new iteration of the Encoder Tool was just released.

The major features are:

1. The standalone version was updated with the third parties jars of Eclipse 3.4.1.

2. Making validation of the input fields will be easy: "required" attribute was added to the InputField annotation. The fields marked as required will be automatically validated as not null.
In addition InputTextField annotation was enhanced with the following attributes: "validateNotEmpty", "validationPattern" and "validationMessage".
validateNotEmpty - validates that string is not empty
validationPattern - validates that string matches the pattern
validationMessage - is displayed to the user if the string doesn't match the pattern
(see Issue 9)

3. Adding jars to the encoder's classpath now supports adding multiple jars (Issue 12)

4. Paths that are saved in the plugin's classpath are now relative and not absolute (Issue 13)

5. In Preferences page, double clicking anything in tree will act as Edit, if Edit button at the right is enabled (Issue 14)

That's all. Hope you'll find these features useful.

Tuesday, September 16, 2008

Encoder 0.2.1

39 downloads to encoder-0.2.0.zip and only 40th person told me that the executable jar inside zip is broken.

Anyway, I have fixed the build script and now it should work. Download encoder-0.2.1.zip from now on.

Monday, September 8, 2008

Encoder 0.2.0

I have just released the second iteration of the Encoder.

Here are the main features:
   1. The Encoder is now customizable using the Preferences dialog. When using Eclipse, the preferences dialog appears under Windows -> Preferences. When standalone, the see File -> Preferences.
   2. The methods getName() and getGroup() should not be implemented by the encoders. Instead the encoder is defined in preferences under a group and must have a name.
   3. The input dialog now supports the ongoing validations. To use it, the encoder must implement tarlog.encoder.tool.api.fields.Validator interface. See tarlog.encoder.tool.encoders.X509CertificateEncoder if you need an example how to use it.
   4. The input fields now support arrays.

It probably has some bugs, so don't hesitate to open issues.

Tuesday, September 2, 2008

Implementing your own encoder in the Encoder Tool - Part 2

I the previous post I have explained how to create a custom encoder. The encoder that takes input and encodes it to output. But what happens, if the encoder needs an additional input to perform an encoding? E.g. the Inflate/Deflate encoders needs to know if they need to use gzip. The Digital Signatures encoders need access to the key stores with the keys and so on.
So how can the encoder receive the additional input?

Actually I tried to do it as simple as I could. To tell the Encoder Tool that your encoder needs input, you'll need to annotate the field with the InputField annotation.
So the Encoder Tool will know that prior to performing the actual encoding, it should pop-up the input dialog, get the input from user and populate the fields.

Let's take a look on the example:
package tarlog.encoder.tool.encoders;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.zip.Deflater;
import java.util.zip.DeflaterOutputStream;

import tarlog.encoder.tool.api.AbstractEncoder;
import tarlog.encoder.tool.api.fields.InputField;

public class DeflateEncoder extends AbstractEncoder {

@InputField(name = "GZIP compatible compression")
private boolean nowrap = true;

@Override
public Object encode(byte[] source) {

try {
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
Deflater deflater = new Deflater(Deflater.DEFLATED, nowrap);
DeflaterOutputStream deflaterStream = new DeflaterOutputStream(
bytesOut, deflater);
deflaterStream.write(source);
deflaterStream.finish();
return bytesOut.toByteArray();
} catch (IOException e) {
showException(e);
return null;
}
}
}


The field nowrap is annotated with the InputField. So when the user invokes the encoder, the following dialog will pop-up:



I guess that the idea is clear. So let's just mention what java types are supported as input fields:
  • String - can be a single line, a text box or a combo box. See TextField annotation for more details.
  • Boolean - check box
  • Integer - spinner
  • Enum - combo box
  • File - input dialog for a file or a directory. See InputFileField and InputDirectoryField annoations for more details.
  • Properties - table of properties
  • Arrays - list. See InputListField for more details.


The input dialog supports on going validations. To do so, the encoder must implement the tarlog.encoder.tool.api.fields.Validator interface. Let's take a look on the example:

public class X509CertificateEncoder extends AbstractEncoder implements
Validator {

private X509Certificate cert;

@InputField(name = "Certificate File", order = -300)
private File file;

@InputField(name = "Algorithm", readonly = true)
private SignatureAlgorithms algorithm = SignatureAlgorithms.SHA1withDSA;

@InputField(name = "Signature")
@InputTextField(multiline = true)
private String signature;

public String isValid() {
if (file == null || file.equals("")) {
return "Certificate File cannot be empty";
}
if (signature == null || signature.equals("")) {
return "Signature cannot be empty";
}
return null;
}

...


The method isValid() will be invoked each time the user changes input.

Sunday, August 31, 2008

Implementing your own encoder in the Encoder Tool

As I already mentioned in the Encoder's introduction post, the main feature of the Encoder Tool is an extensibility. Meaning that you can implement your own encoders and plug them to the Encoder Tool.

In this guide, I'll explain how to create a custom encoder and plug it into the Encoder Tool. This guide applies to the current Encoder's version (0.2.0).

Create Java Project


Download the distribution of the Encoder (zip file) and create a java project. Add an encoder's jar and third-parties jars from the lib folder to the project's classpath.

Create an Encoder's Class


Create a new class that extends tarlog.encoder.tool.api.AbstractEncoder.

Implement encode() Method


This is the most important method to implement, the method that is responsible to the encoder's logic. First, you'll need to pay attention that there are two encode methods that you can override:
* Object encode(String source)
and
* Object encode(byte[] source)
You must override at least one of these methods, but usually you will override only one.

So what is the difference?
Object encode(String source) is invoked when the input is a text.
Object encode(byte[] source) is invoked when the input is a byte array.
Simple, isn't it?

The default implementation of these methods is to call each other, which leads to endless recursion if you don't implement one of the methods. The Encoder Tool asserts that you implement one of the methods and will throw an exception if you don't.

The result of the encode method should be either a String or a byte array. If other object is returned, its toString() method will be invoked. If null is returned, the output will remain unchanged.

Example


package tarlog.encoder.tool.encoders;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import tarlog.encoder.tool.api.AbstractEncoder;

public class MyUrlEncoder extends AbstractEncoder {

@Override
public Object encode(String source) {
try {
return URLEncoder.encode(source, "UTF-8");
} catch (UnsupportedEncodingException e) {
showException(e);
return null;
}
}
}


Plug in a Customer Encoder to the Encoder Tool


To plugin in a custom encoder to the Encoder Tool do the following:
1. Open preferences page and add a new encoder. You can add it either to the existing group or you can create a new group.
2. When you add the encoder, you should provide a name, a class name and a classpath.
3. Define classpath of the encoder, it may contain class folders or jars.
4. Press OK and start using your encoder.

Conclusion


In this post I have described how to create custom encoders to the Encoder Tool. As you could see, it's very very simple. However, you may say, what happens if the custom encoder needs an additional input? Just like the "Digital Signatures" encoders. So there is solution for this, but it will have to wait for the next post.

Friday, August 29, 2008

Encoder 0.1.0

And here just another neat tool I have developed for my personal needs and decided to make it public. Meet the Encoder!

So what is it used for?


It is used to encode things from one format to another. The input can be either text or bytes and the same about output. The tool is easily extendable: if you need to perform some special encoding you can implement encoder yourself and plug it into the tool. I'll expand about this functionality in the later post.

Built-in Encoders


Currently the build-in encoders are:
  • To/From Base64
  • Url Encoder/Decoder
  • Inflate/Deflate (optionally uses gzip)
  • Create signature using a private key
  • Verify signature using a public key
  • Verify signature using a certificate


Running the tool


The tool can be run either as an eclipse plugin or as a standalone application. UI is implemented in SWT, which makes it cross-platform. To run the Encoder standalone, download the distribution zip and execute "javaw -jar encoder-0.1.0.jar". You'll need at least Java 5.

I guess that all for now. I'll be happy to get any feedback about the Encoder and see people using it.

Enjoy!