Search in sources :

Example 56 with Loggeable

use of org.jpos.util.Loggeable 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

Loggeable (org.jpos.util.Loggeable)56 ArrayList (java.util.ArrayList)55 LogEvent (org.jpos.util.LogEvent)55 SimpleMsg (org.jpos.util.SimpleMsg)55 ConfigurationException (org.jpos.core.ConfigurationException)53 NotFoundException (org.jpos.util.NameRegistrar.NotFoundException)53 PublicKey (java.security.PublicKey)2 Iterator (java.util.Iterator)1 Map (java.util.Map)1 NameRegistrar (org.jpos.util.NameRegistrar)1