use of org.jcryptool.core.operations.dataobject.classic.ClassicDataObject in project core by jcryptool.
the class AbstractAlgorithmHandler method addActionItem.
/**
* Adds the cryptographic action information as a new <code>ActionItem</code> to the <b>Actions view</b>. Adding the
* new ActionItem must be executed in an async way since a Job may be used to execute the cryptographic operation.
*
* @param algorithm The executed AbstractAlgorithm implementation
*/
private void addActionItem(AbstractAlgorithm algorithm) {
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
if ((Boolean) // $NON-NLS-1$
service.getCommand("org.jcryptool.actions.recordCommand").getState("org.jcryptool.actions.recordCommand.toggleState").getValue()) {
// $NON-NLS-1$
final ActionItem item = new ActionItem(output.getName(), algorithm.getAlgorithmName());
item.setPluginId(this.getId());
if (algorithm instanceof AbstractClassicAlgorithm) {
ClassicDataObject dataobject = (ClassicDataObject) dataObject;
if (dataobject.getOpmode() == 0) {
// $NON-NLS-1$
item.setActionType("encrypt");
} else if (dataobject.getOpmode() == 1) {
// $NON-NLS-1$
item.setActionType("decrypt");
}
item.setAlphabet(dataobject.getAlphabet().getName());
dataobject.setFilterNonAlphaChars(((AbstractClassicAlgorithm) algorithm).isFilter());
item.setParams(DataObjectConverter.propertiesToHashtable(dataobject));
item.setDataObjectType(dataobject.getClass().getName());
} else if (algorithm instanceof AbstractModernAlgorithm) {
ModernDataObject dataobject = (ModernDataObject) dataObject;
item.setParams(DataObjectConverter.propertiesToHashtable(dataobject));
item.setDataObjectType(dataobject.getClass().getName());
}
Display.getDefault().asyncExec(new Runnable() {
public void run() {
ActionCascadeService.getInstance().addItem(item);
}
});
}
}
use of org.jcryptool.core.operations.dataobject.classic.ClassicDataObject in project core by jcryptool.
the class StartHandler method convert.
public IDataObject convert(ActionItem actionItem) {
IDataObject dataobject = DataObjectConverter.hashtableToProperties(actionItem.getParams(), actionItem.getDataObjectType());
if (dataobject instanceof ClassicDataObject) {
AbstractAlphabet alphabet = AlphabetsManager.getInstance().getAlphabetByName(actionItem.getAlphabet());
((ClassicDataObject) dataobject).setAlphabet(alphabet);
if ("encrypt".equals(actionItem.getActionType())) {
// $NON-NLS-1$
((ClassicDataObject) dataobject).setOpmode(AbstractAlgorithm.ENCRYPT_MODE);
} else if ("decrypt".equals(actionItem.getActionType())) {
// $NON-NLS-1$
((ClassicDataObject) dataobject).setOpmode(AbstractAlgorithm.DECRYPT_MODE);
}
}
return dataobject;
}
use of org.jcryptool.core.operations.dataobject.classic.ClassicDataObject in project core by jcryptool.
the class AbstractClassicAlgorithm method init.
/**
* Initializes the Algorithm with its key parameters
*
* @param opmode encrypt or decrypt (mode)
* @param input input text
* @param alphabet filter alphabet
* @param key the operation's key
* @param key2 the second key
* @param transformData the transformation data used to transform the text before the real operation, may be
* <code>null</code> in case no transformation should be applied
*/
public void init(int opmode, String input, AbstractAlphabet alphabet, char[] key, char[] key2, TransformData transformData) {
this.dataObject = new ClassicDataObject();
this.dataObject.setTransformData(transformData);
this.dataObject.setPlain(filterTextByTransformData(input, transformData));
this.dataObject.setAlphabet(alphabet);
this.dataObject.setKey(key);
this.dataObject.setOpmode(opmode);
this.dataObject.setKey2(key2);
}
use of org.jcryptool.core.operations.dataobject.classic.ClassicDataObject in project core by jcryptool.
the class AbstractClassicAlgorithm method init.
/**
* Initializes the Algorithm with its key parameters
*
* @param opmode encrypt or decrypt (mode)
* @param input input text
* @param alphabet filter alphabet
* @param key the operation's key
* @param nullchar the char (in some algorithms) that is the one to replace a missing character in the
* 26-char-alphabet
* @param transformData the transformation data used to transform the text before the real operation, may be
* <code>null</code> in case no transformation should be applied
*/
public void init(int opmode, InputStream input, AbstractAlphabet alphabet, char[] key, char nullchar, TransformData transformData) {
this.dataObject = new ClassicDataObject();
this.dataObject.setTransformData(transformData);
try {
this.dataObject.setInputStream(filterStreamByTransformData(input, transformData));
} catch (Exception e) {
LogUtil.logError(OperationsPlugin.PLUGIN_ID, e);
this.dataObject.setInputStream(input);
}
this.dataObject.setAlphabet(alphabet);
this.dataObject.setKey(key);
this.dataObject.setOpmode(opmode);
this.dataObject.setNullchar(nullchar);
}
use of org.jcryptool.core.operations.dataobject.classic.ClassicDataObject in project core by jcryptool.
the class AbstractClassicAlgorithm method init.
/**
* Initializes the Algorithm with its key parameters
*
* @param opmode encrypt or decrypt (mode)
* @param input input text
* @param alphabet filter alphabet
* @param key the operation's key
* @param nullchar the char (in some algorithms) that is the one to replace a missing character in the
* 26-char-alphabet
* @param transformData the transformation data used to transform the text before the real operation, may be
* <code>null</code> in case no transformation should be applied
*/
public void init(int opmode, String input, AbstractAlphabet alphabet, char[] key, char nullchar, TransformData transformData) {
this.dataObject = new ClassicDataObject();
this.dataObject.setTransformData(transformData);
this.dataObject.setPlain(filterTextByTransformData(input, transformData));
this.dataObject.setAlphabet(alphabet);
this.dataObject.setKey(key);
this.dataObject.setOpmode(opmode);
this.dataObject.setNullchar(nullchar);
}
Aggregations