Search in sources :

Example 36 with Loggeable

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

the class BaseSMAdapter method translatePIN.

@Override
public EncryptedPIN translatePIN(EncryptedPIN pinUnderKd1, T kd1, T kd2, byte destinationPINBlockFormat) throws SMException {
    List<Loggeable> cmdParameters = new ArrayList<>();
    cmdParameters.add(new SimpleMsg("parameter", "PIN under Data Key 1", pinUnderKd1));
    cmdParameters.add(new SimpleMsg("parameter", "Data Key 1", kd1));
    cmdParameters.add(new SimpleMsg("parameter", "Data Key 2", kd2));
    cmdParameters.add(new SimpleMsg("parameter", "Destination PIN Block Format", destinationPINBlockFormat));
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Translate PIN from Data Key 1 to Data Key 2", cmdParameters));
    EncryptedPIN result = null;
    try {
        result = translatePINImpl(pinUnderKd1, kd1, 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) 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 37 with Loggeable

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

the class BaseSMAdapter method importPIN.

@Override
public EncryptedPIN importPIN(EncryptedPIN pinUnderDuk, KeySerialNumber ksn, T bdk, boolean tdes) throws SMException {
    List<Loggeable> cmdParameters = new ArrayList<>();
    cmdParameters.add(new SimpleMsg("parameter", "PIN under Derived Unique Key", pinUnderDuk));
    cmdParameters.add(new SimpleMsg("parameter", "Key Serial Number", ksn));
    cmdParameters.add(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) 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 38 with Loggeable

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

the class BaseSMAdapter method verifyCVV.

@Override
public boolean verifyCVV(String accountNo, T cvkA, T cvkB, String cvv, Date expDate, String serviceCode) throws SMException {
    List<Loggeable> cmdParameters = new ArrayList<>();
    cmdParameters.add(new SimpleMsg("parameter", "account number", accountNo));
    cmdParameters.add(new SimpleMsg("parameter", "cvk-a", cvkA == null ? "" : cvkA));
    cmdParameters.add(new SimpleMsg("parameter", "cvk-b", cvkB == null ? "" : cvkB));
    cmdParameters.add(new SimpleMsg("parameter", "CVV/CVC", cvv));
    cmdParameters.add(new SimpleMsg("parameter", "Exp date", expDate));
    cmdParameters.add(new SimpleMsg("parameter", "Service code", serviceCode));
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Verify CVV/CVC", cmdParameters));
    try {
        boolean r = verifyCVVImpl(accountNo, cvkA, cvkB, cvv, expDate, serviceCode);
        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) 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 39 with Loggeable

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

the class BaseSMAdapter method verifyIBMPINOffset.

@Override
public boolean verifyIBMPINOffset(EncryptedPIN pinUnderKd1, T kd1, T pvk, String offset, String decTab, String pinValData, int minPinLen) throws SMException {
    List<Loggeable> cmdParameters = new ArrayList<>();
    cmdParameters.add(new SimpleMsg("parameter", "account number", pinUnderKd1.getAccountNumber()));
    cmdParameters.add(new SimpleMsg("parameter", "PIN under Data Key 1", pinUnderKd1));
    cmdParameters.add(new SimpleMsg("parameter", "Data Key 1", kd1));
    cmdParameters.add(new SimpleMsg("parameter", "PVK", pvk));
    cmdParameters.add(new SimpleMsg("parameter", "Pin block format", pinUnderKd1.getPINBlockFormat()));
    cmdParameters.add(new SimpleMsg("parameter", "decimalisation table", decTab));
    cmdParameters.add(new SimpleMsg("parameter", "PIN validation data", pinValData));
    cmdParameters.add(new SimpleMsg("parameter", "minimum PIN length", minPinLen));
    cmdParameters.add(new SimpleMsg("parameter", "offset", offset));
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Verify PIN offset", cmdParameters));
    try {
        boolean r = verifyIBMPINOffsetImpl(pinUnderKd1, kd1, pvk, offset, decTab, pinValData, minPinLen);
        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) 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 40 with Loggeable

use of org.jpos.util.Loggeable 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(T imkcvc3, String accountNo, String acctSeqNo, byte[] atc, byte[] upn, byte[] data, MKDMethod mkdm, String cvc3) throws SMException {
    List<Loggeable> cmdParameters = new ArrayList<>();
    cmdParameters.add(new SimpleMsg("parameter", "imk-cvc3", imkcvc3 == null ? "" : imkcvc3));
    cmdParameters.add(new SimpleMsg("parameter", "account number", accountNo));
    cmdParameters.add(new SimpleMsg("parameter", "accnt seq no", acctSeqNo));
    cmdParameters.add(new SimpleMsg("parameter", "atc", atc == null ? "" : ISOUtil.hexString(atc)));
    cmdParameters.add(new SimpleMsg("parameter", "upn", upn == null ? "" : ISOUtil.hexString(upn)));
    cmdParameters.add(new SimpleMsg("parameter", "data", data == null ? "" : ISOUtil.hexString(data)));
    cmdParameters.add(new SimpleMsg("parameter", "mkd method", mkdm));
    cmdParameters.add(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) 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)

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