Search in sources :

Example 31 with LogEvent

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

the class StatefulFilterTest method testFilterThrowsNullPointerException9.

@Test
public void testFilterThrowsNullPointerException9() throws Throwable {
    ISOMsg m = new ISOMsg(100);
    m.setDirection(100);
    int[] key = new int[0];
    StatefulFilter statefulFilter = new StatefulFilter();
    statefulFilter.setKey(key);
    statefulFilter.setSpace((Space) null);
    statefulFilter.setMatchDirection(100);
    statefulFilter.setSavedFields(null);
    try {
        statefulFilter.filter(new PostChannel("testStatefulFilterHost", 100, new GenericSubFieldPackager()), m, new LogEvent());
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
    }
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) PostChannel(org.jpos.iso.channel.PostChannel) GenericSubFieldPackager(org.jpos.iso.packager.GenericSubFieldPackager) Test(org.junit.Test)

Example 32 with LogEvent

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

the class BaseSMAdapter method calculatePVV.

@Override
public String calculatePVV(EncryptedPIN pinUnderKd1, SecureDESKey kd1, SecureDESKey pvkA, SecureDESKey pvkB, int pvkIdx, List<String> excludes) throws SMException {
    List<Loggeable> cmdParameters = new ArrayList<Loggeable>();
    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-A", pvkA == null ? "" : pvkA));
    cmdParameters.add(new SimpleMsg("parameter", "PVK-B", pvkB == null ? "" : pvkB));
    cmdParameters.add(new SimpleMsg("parameter", "PVK index", pvkIdx));
    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", "Calculate PVV", cmdParameters.toArray(new Loggeable[cmdParameters.size()])));
    String result = null;
    try {
        result = calculatePVVImpl(pinUnderKd1, kd1, pvkA, pvkB, pvkIdx, excludes);
        evt.addMessage(new SimpleMsg("result", "Calculated PVV", 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 33 with LogEvent

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

the class BaseSMAdapter method translatePIN.

@Override
public EncryptedPIN translatePIN(EncryptedPIN pinUnderKd1, SecureDESKey kd1, SecureDESKey kd2, byte destinationPINBlockFormat) throws SMException {
    SimpleMsg[] cmdParameters = { new SimpleMsg("parameter", "PIN under Data Key 1", pinUnderKd1), new SimpleMsg("parameter", "Data Key 1", kd1), 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", "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) SimpleMsg(org.jpos.util.SimpleMsg) ConfigurationException(org.jpos.core.ConfigurationException) NotFoundException(org.jpos.util.NameRegistrar.NotFoundException)

Example 34 with LogEvent

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

the class BaseSMAdapter method calculateCVV.

@Override
public String calculateCVV(String accountNo, SecureDESKey cvkA, SecureDESKey cvkB, Date expDate, String serviceCode) throws SMException {
    SimpleMsg[] cmdParameters = { new SimpleMsg("parameter", "account number", accountNo), new SimpleMsg("parameter", "cvk-a", cvkA == null ? "" : cvkA), new SimpleMsg("parameter", "cvk-b", cvkB == null ? "" : cvkB), new SimpleMsg("parameter", "Exp date", expDate), new SimpleMsg("parameter", "Service code", serviceCode) };
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Calculate CVV/CVC", cmdParameters));
    String result = null;
    try {
        result = calculateCVVImpl(accountNo, cvkA, cvkB, expDate, serviceCode);
        evt.addMessage(new SimpleMsg("result", "Calculated CVV/CVC", 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 35 with LogEvent

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

the class BaseSMAdapter method translatePIN.

@Override
public EncryptedPIN translatePIN(EncryptedPIN pinUnderDuk, KeySerialNumber ksn, SecureDESKey bdk, SecureDESKey kd2, byte destinationPINBlockFormat, 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), 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", "Translate PIN", cmdParameters));
    EncryptedPIN result = null;
    try {
        result = translatePINImpl(pinUnderDuk, ksn, bdk, kd2, destinationPINBlockFormat, tdes);
        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)

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