Search in sources :

Example 86 with LogEvent

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

the class BaseSMAdapter method generatePIN.

@Override
public EncryptedPIN generatePIN(String accountNumber, int pinLen, List<String> excludes) throws SMException {
    List<Loggeable> cmdParameters = new ArrayList<Loggeable>();
    cmdParameters.add(new SimpleMsg("parameter", "account number", accountNumber));
    cmdParameters.add(new SimpleMsg("parameter", "PIN length", pinLen));
    if (excludes != null && !excludes.isEmpty())
        cmdParameters.add(new SimpleMsg("parameter", "Excluded PINs list", excludes));
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Generate PIN", cmdParameters.toArray(new Loggeable[cmdParameters.size()])));
    EncryptedPIN result = null;
    try {
        result = generatePINImpl(accountNumber, pinLen, excludes);
        evt.addMessage(new SimpleMsg("result", "Generated PIN", 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) ArrayList(java.util.ArrayList) Loggeable(org.jpos.util.Loggeable) SimpleMsg(org.jpos.util.SimpleMsg) ConfigurationException(org.jpos.core.ConfigurationException) NotFoundException(org.jpos.util.NameRegistrar.NotFoundException)

Example 87 with LogEvent

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

the class BaseSMAdapter method generateKey.

@Override
public SecureDESKey generateKey(short keyLength, String keyType) throws SMException {
    SimpleMsg[] cmdParameters = { new SimpleMsg("parameter", "Key Length", keyLength), new SimpleMsg("parameter", "Key Type", keyType) };
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Generate Key", cmdParameters));
    SecureDESKey result = null;
    try {
        result = generateKeyImpl(keyLength, keyType);
        evt.addMessage(new SimpleMsg("result", "Generated Key", 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 88 with LogEvent

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

the class BaseSMAdapter method importKey.

@Override
public SecureDESKey importKey(short keyLength, String keyType, byte[] encryptedKey, SecureDESKey kek, boolean checkParity) throws SMException {
    SimpleMsg[] cmdParameters = { new SimpleMsg("parameter", "Key Length", keyLength), new SimpleMsg("parameter", "Key Type", keyType), new SimpleMsg("parameter", "Encrypted Key", encryptedKey), new SimpleMsg("parameter", "Key-Encrypting Key", kek), new SimpleMsg("parameter", "Check Parity", checkParity) };
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Import Key", cmdParameters));
    SecureDESKey result = null;
    try {
        result = importKeyImpl(keyLength, keyType, encryptedKey, kek, checkParity);
        evt.addMessage(new SimpleMsg("result", "Imported Key", 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 89 with LogEvent

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

the class BaseSMAdapter method eraseOldLMK.

@Override
public void eraseOldLMK() throws SMException {
    SimpleMsg[] cmdParameters = {};
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Erase the key change storage", cmdParameters));
    try {
        eraseOldLMKImpl();
    } 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 90 with LogEvent

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

the class BaseSMAdapter method verifyCVC3.

/**
 * @param imkcvc3 the issuer master key for generating and verifying CVC3
 * @param accountNo The account number including BIN and the check digit
 * @param acctSeqNo account sequence number, 2 decimal digits
 * @param atc application transactin counter. This is used for ICC Master
 *        Key derivation. A 2 byte value must be supplied.
 * @param upn  unpredictable number. This is used for Session Key Generation
 *        A 4 byte value must be supplied.
 * @param data track data
 * @param mkdm ICC Master Key Derivation Method. If {@code null} specified
 *        is assumed.
 * @param cvc3 dynamic Card Verification Code 3
 * @return true if cvc3 is valid false if not
 * @throws SMException
 */
@Override
public boolean verifyCVC3(SecureDESKey imkcvc3, String accountNo, String acctSeqNo, byte[] atc, byte[] upn, byte[] data, MKDMethod mkdm, String cvc3) throws SMException {
    SimpleMsg[] cmdParameters = { new SimpleMsg("parameter", "imk-cvc3", imkcvc3 == null ? "" : imkcvc3), 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", "upn", upn == null ? "" : ISOUtil.hexString(upn)), new SimpleMsg("parameter", "data", data == null ? "" : ISOUtil.hexString(data)), new SimpleMsg("parameter", "mkd method", mkdm), new SimpleMsg("parameter", "cvc3", cvc3) };
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Verify CVC3", cmdParameters));
    try {
        boolean r = verifyCVC3Impl(imkcvc3, accountNo, acctSeqNo, atc, upn, data, mkdm, cvc3);
        evt.addMessage(new SimpleMsg("result", "Verification status", r ? "valid" : "invalid"));
        return r;
    } 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)

Aggregations

LogEvent (org.jpos.util.LogEvent)189 Test (org.junit.Test)78 ConfigurationException (org.jpos.core.ConfigurationException)51 ISOMsg (org.jpos.iso.ISOMsg)41 SimpleMsg (org.jpos.util.SimpleMsg)40 NotFoundException (org.jpos.util.NameRegistrar.NotFoundException)38 ArrayList (java.util.ArrayList)24 IOException (java.io.IOException)18 SimpleConfiguration (org.jpos.core.SimpleConfiguration)14 CSChannel (org.jpos.iso.channel.CSChannel)12 Loggeable (org.jpos.util.Loggeable)11 Map (java.util.Map)9 ISOChannel (org.jpos.iso.ISOChannel)9 PostChannel (org.jpos.iso.channel.PostChannel)9 CTCSubFieldPackager (org.jpos.iso.packager.CTCSubFieldPackager)9 ISOFilter (org.jpos.iso.ISOFilter)8 BASE24TCPChannel (org.jpos.iso.channel.BASE24TCPChannel)8 PADChannel (org.jpos.iso.channel.PADChannel)8 ISOBaseValidatingPackager (org.jpos.iso.packager.ISOBaseValidatingPackager)8 EOFException (java.io.EOFException)7