Search in sources :

Example 1 with AlgorithmParameters

use of de.flexiprovider.api.parameters.AlgorithmParameters in project core by jcryptool.

the class AlgorithmParameterSpecElement method getAlgorithmParameterSpec.

private AlgorithmParameterSpec getAlgorithmParameterSpec(String algorithmName, String encoded) {
    if (encoded != null) {
        // $NON-NLS-1$
        LogUtil.logInfo("getAlgorithmParameterSpec");
        try {
            byte[] encodedParams = Base64Coder.decode(encoded);
            AlgorithmParameters params = Registry.getAlgParams(algorithmName);
            params.init(encodedParams);
            return params.getParameterSpec(Registry.getAlgParamSpecClass(algorithmName));
        } catch (IOException e) {
            LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "IOException while decoding AlgorithmParameterParameters", e, true);
        } catch (NoSuchAlgorithmException e) {
            LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "NoSuchAlgorithmException while decoding AlgorithmParameterParameters", e, true);
        } catch (InvalidParameterSpecException e) {
            LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "InvalidParameterSpecException while decoding AlgorithmParameterParameters", e, true);
        }
    }
    return null;
}
Also used : IOException(java.io.IOException) NoSuchAlgorithmException(de.flexiprovider.api.exceptions.NoSuchAlgorithmException) InvalidParameterSpecException(de.flexiprovider.api.exceptions.InvalidParameterSpecException) AlgorithmParameters(de.flexiprovider.api.parameters.AlgorithmParameters)

Example 2 with AlgorithmParameters

use of de.flexiprovider.api.parameters.AlgorithmParameters in project core by jcryptool.

the class AlgorithmParameterSpecElement method setAlgorithmParameters.

private void setAlgorithmParameters(String algorithmName, AlgorithmParameterSpec spec) {
    if (spec != null) {
        try {
            AlgorithmParameters params = Registry.getAlgParams(algorithmName);
            params.init(spec);
            setText(String.valueOf(Base64Coder.encode(params.getEncoded())));
        } catch (IOException e) {
            LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "IOException while encoding AlgorithmParameterParameters", e, true);
        } catch (NoSuchAlgorithmException e) {
            LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "NoSuchAlgorithmException while encoding AlgorithmParameterParameters", e, true);
        } catch (InvalidParameterSpecException e) {
            LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "InvalidParameterSpecException while encoding AlgorithmParameterParameters", e, true);
        }
    }
}
Also used : IOException(java.io.IOException) NoSuchAlgorithmException(de.flexiprovider.api.exceptions.NoSuchAlgorithmException) InvalidParameterSpecException(de.flexiprovider.api.exceptions.InvalidParameterSpecException) AlgorithmParameters(de.flexiprovider.api.parameters.AlgorithmParameters)

Example 3 with AlgorithmParameters

use of de.flexiprovider.api.parameters.AlgorithmParameters in project core by jcryptool.

the class ModeParameterSpecElement method setModeParameters.

private void setModeParameters(AlgorithmParameterSpec modeSpec) {
    if (modeSpec != null) {
        try {
            // $NON-NLS-1$
            AlgorithmParameters params = Registry.getAlgParams("Mode");
            params.init(modeSpec);
            setText(String.valueOf(Base64Coder.encode(params.getEncoded())));
        } catch (IOException e) {
            LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "IOException while encoding ModeParameters", e, true);
        } catch (NoSuchAlgorithmException e) {
            LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "NoSuchAlgorithmException while encoding ModeParameters", e, true);
        } catch (InvalidParameterSpecException e) {
            LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "InvalidParameterSpecException while encoding ModeParameters", e, true);
        }
    }
}
Also used : IOException(java.io.IOException) NoSuchAlgorithmException(de.flexiprovider.api.exceptions.NoSuchAlgorithmException) InvalidParameterSpecException(de.flexiprovider.api.exceptions.InvalidParameterSpecException) AlgorithmParameters(de.flexiprovider.api.parameters.AlgorithmParameters)

Example 4 with AlgorithmParameters

use of de.flexiprovider.api.parameters.AlgorithmParameters in project core by jcryptool.

the class ModeParameterSpecElement method getModeParameterSpec.

private ModeParameterSpec getModeParameterSpec(String encoded) {
    if (encoded != null) {
        // $NON-NLS-1$
        LogUtil.logInfo("getModeParameterSpec");
        try {
            byte[] encodedParams = Base64Coder.decode(encoded);
            // $NON-NLS-1$
            AlgorithmParameters params = Registry.getAlgParams("Mode");
            params.init(encodedParams);
            return (ModeParameterSpec) params.getParameterSpec(ModeParameterSpec.class);
        } catch (IOException e) {
            LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "IOException while decoding ModeParameters", e, false);
        } catch (NoSuchAlgorithmException e) {
            LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "NoSuchAlgorithmException while decoding ModeParameters", e, true);
        } catch (InvalidParameterSpecException e) {
            LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "InvalidParameterSpecException while decoding ModeParameters", e, true);
        }
    }
    return null;
}
Also used : IOException(java.io.IOException) NoSuchAlgorithmException(de.flexiprovider.api.exceptions.NoSuchAlgorithmException) InvalidParameterSpecException(de.flexiprovider.api.exceptions.InvalidParameterSpecException) AlgorithmParameters(de.flexiprovider.api.parameters.AlgorithmParameters) ModeParameterSpec(de.flexiprovider.common.mode.ModeParameterSpec)

Aggregations

InvalidParameterSpecException (de.flexiprovider.api.exceptions.InvalidParameterSpecException)4 NoSuchAlgorithmException (de.flexiprovider.api.exceptions.NoSuchAlgorithmException)4 AlgorithmParameters (de.flexiprovider.api.parameters.AlgorithmParameters)4 IOException (java.io.IOException)4 ModeParameterSpec (de.flexiprovider.common.mode.ModeParameterSpec)1