Search in sources :

Example 76 with SimpleMsg

use of org.jpos.util.SimpleMsg in project jPOS by jpos.

the class BaseSMAdapter method decryptData.

@Override
public byte[] decryptData(SecureKey privKey, byte[] data, AlgorithmParameterSpec algspec, byte[] iv) throws SMException {
    List<Loggeable> cmdParameters = new ArrayList<>();
    cmdParameters.add(new SimpleMsg("parameter", "Decription Key", privKey));
    cmdParameters.add(new SimpleMsg("parameter", "Encrypted Data", ISOUtil.hexString(data)));
    if (algspec != null)
        cmdParameters.add(new SimpleMsg("parameter", "Algorithm Spec", algspec));
    if (iv != null)
        cmdParameters.add(new SimpleMsg("parameter", "Initialization Vector", ISOUtil.hexString(iv)));
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Decrypt Data", cmdParameters));
    byte[] result = null;
    try {
        result = decryptDataImpl(privKey, data, algspec, iv);
        List<Loggeable> r = new ArrayList<>();
        r.add(new SimpleMsg("result", "Decrypted Data", result));
        if (iv != null)
            r.add(new SimpleMsg("result", "Initialization Vector", iv));
        evt.addMessage(new SimpleMsg("results", r));
    } catch (SMException ex) {
        evt.addMessage(ex);
        throw ex;
    } catch (RuntimeException ex) {
        evt.addMessage(ex);
        throw new SMException(ex);
    } finally {
        Logger.log(evt);
    }
    return result;
}
Also used : LogEvent(org.jpos.util.LogEvent) ArrayList(java.util.ArrayList) Loggeable(org.jpos.util.Loggeable) SimpleMsg(org.jpos.util.SimpleMsg)

Aggregations

LogEvent (org.jpos.util.LogEvent)76 SimpleMsg (org.jpos.util.SimpleMsg)76 ConfigurationException (org.jpos.core.ConfigurationException)72 NotFoundException (org.jpos.util.NameRegistrar.NotFoundException)72 ArrayList (java.util.ArrayList)55 Loggeable (org.jpos.util.Loggeable)55 PublicKey (java.security.PublicKey)2 SecretKey (javax.crypto.SecretKey)2