Search in sources :

Example 36 with SimpleMsg

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

the class BaseSMAdapter method generateCBC_MAC.

@Override
public byte[] generateCBC_MAC(byte[] data, SecureDESKey kd) throws SMException {
    SimpleMsg[] cmdParameters = { new SimpleMsg("parameter", "data", data), new SimpleMsg("parameter", "data key", kd) };
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Generate CBC-MAC", cmdParameters));
    byte[] result = null;
    try {
        result = generateCBC_MACImpl(data, kd);
        evt.addMessage(new SimpleMsg("result", "CBC-MAC", result));
    } catch (Exception e) {
        evt.addMessage(e);
        throw e instanceof SMException ? (SMException) e : new SMException(e);
    } finally {
        Logger.log(evt);
    }
    return result;
}
Also used : LogEvent(org.jpos.util.LogEvent) SimpleMsg(org.jpos.util.SimpleMsg) ConfigurationException(org.jpos.core.ConfigurationException) NotFoundException(org.jpos.util.NameRegistrar.NotFoundException)

Example 37 with SimpleMsg

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

the class BaseSMAdapter method exportPIN.

@Override
public EncryptedPIN exportPIN(EncryptedPIN pinUnderLmk, SecureDESKey kd2, byte destinationPINBlockFormat) throws SMException {
    SimpleMsg[] cmdParameters = { new SimpleMsg("parameter", "PIN under LMK", pinUnderLmk), new SimpleMsg("parameter", "Data Key 2", kd2), new SimpleMsg("parameter", "Destination PIN Block Format", destinationPINBlockFormat) };
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Export PIN", cmdParameters));
    EncryptedPIN result = null;
    try {
        result = exportPINImpl(pinUnderLmk, kd2, destinationPINBlockFormat);
        evt.addMessage(new SimpleMsg("result", "PIN under Data Key 2", result));
    } catch (Exception e) {
        evt.addMessage(e);
        throw e instanceof SMException ? (SMException) e : new SMException(e);
    } finally {
        Logger.log(evt);
    }
    return result;
}
Also used : LogEvent(org.jpos.util.LogEvent) SimpleMsg(org.jpos.util.SimpleMsg) ConfigurationException(org.jpos.core.ConfigurationException) NotFoundException(org.jpos.util.NameRegistrar.NotFoundException)

Example 38 with SimpleMsg

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

the class BaseSMAdapter method generateKeyCheckValue.

@Override
public byte[] generateKeyCheckValue(SecureDESKey kd) throws SMException {
    SimpleMsg[] cmdParameters = { new SimpleMsg("parameter", "Key with untrusted check value", kd) };
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Generate Key Check Value", cmdParameters));
    byte[] result = null;
    try {
        result = generateKeyCheckValueImpl(kd);
        evt.addMessage(new SimpleMsg("result", "Generated Key Check Value", ISOUtil.hexString(result)));
    } catch (Exception e) {
        evt.addMessage(e);
        throw e instanceof SMException ? (SMException) e : new SMException(e);
    } finally {
        Logger.log(evt);
    }
    return result;
}
Also used : LogEvent(org.jpos.util.LogEvent) SimpleMsg(org.jpos.util.SimpleMsg) ConfigurationException(org.jpos.core.ConfigurationException) NotFoundException(org.jpos.util.NameRegistrar.NotFoundException)

Example 39 with SimpleMsg

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

the class BaseSMAdapter method generateSM_MAC.

@Override
public byte[] generateSM_MAC(MKDMethod mkdm, SKDMethod skdm, SecureDESKey imksmi, String accountNo, String acctSeqNo, byte[] atc, byte[] arqc, byte[] data) throws SMException {
    SimpleMsg[] cmdParameters = { new SimpleMsg("parameter", "mkd method", mkdm), new SimpleMsg("parameter", "skd method", skdm), new SimpleMsg("parameter", "imk-smi", imksmi), new SimpleMsg("parameter", "account number", accountNo), new SimpleMsg("parameter", "accnt seq no", acctSeqNo), new SimpleMsg("parameter", "atc", atc == null ? "" : ISOUtil.hexString(atc)), new SimpleMsg("parameter", "arqc", arqc == null ? "" : ISOUtil.hexString(arqc)), new SimpleMsg("parameter", "data", data == null ? "" : ISOUtil.hexString(data)) };
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Generate Secure Messaging MAC", cmdParameters));
    try {
        byte[] mac = generateSM_MACImpl(mkdm, skdm, imksmi, accountNo, acctSeqNo, atc, arqc, data);
        evt.addMessage(new SimpleMsg("result", "Generated MAC", mac != null ? ISOUtil.hexString(mac) : ""));
        return mac;
    } catch (Exception e) {
        evt.addMessage(e);
        throw e instanceof SMException ? (SMException) e : new SMException(e);
    } finally {
        Logger.log(evt);
    }
}
Also used : LogEvent(org.jpos.util.LogEvent) SimpleMsg(org.jpos.util.SimpleMsg) ConfigurationException(org.jpos.core.ConfigurationException) NotFoundException(org.jpos.util.NameRegistrar.NotFoundException)

Example 40 with SimpleMsg

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

the class BaseSMAdapter method importPIN.

@Override
public EncryptedPIN importPIN(EncryptedPIN pinUnderDuk, KeySerialNumber ksn, SecureDESKey bdk, boolean tdes) throws SMException {
    SimpleMsg[] cmdParameters = { new SimpleMsg("parameter", "PIN under Derived Unique Key", pinUnderDuk), new SimpleMsg("parameter", "Key Serial Number", ksn), new SimpleMsg("parameter", "Base Derivation Key", bdk) };
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Import PIN", cmdParameters));
    EncryptedPIN result = null;
    try {
        result = importPINImpl(pinUnderDuk, ksn, bdk, tdes);
        evt.addMessage(new SimpleMsg("result", "PIN under LMK", result));
    } catch (Exception e) {
        evt.addMessage(e);
        throw e instanceof SMException ? (SMException) e : new SMException(e);
    } finally {
        Logger.log(evt);
    }
    return result;
}
Also used : LogEvent(org.jpos.util.LogEvent) SimpleMsg(org.jpos.util.SimpleMsg) ConfigurationException(org.jpos.core.ConfigurationException) NotFoundException(org.jpos.util.NameRegistrar.NotFoundException)

Aggregations

LogEvent (org.jpos.util.LogEvent)40 SimpleMsg (org.jpos.util.SimpleMsg)40 ConfigurationException (org.jpos.core.ConfigurationException)38 NotFoundException (org.jpos.util.NameRegistrar.NotFoundException)38 ArrayList (java.util.ArrayList)11 Loggeable (org.jpos.util.Loggeable)11 SecretKey (javax.crypto.SecretKey)2 PublicKey (java.security.PublicKey)1