Search in sources :

Example 11 with Loggeable

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

the class BaseSMAdapter method calculateCAVV.

@Override
public String calculateCAVV(String accountNo, T cvk, String upn, String authrc, String sfarc) throws SMException {
    List<Loggeable> cmdParameters = new ArrayList<>();
    cmdParameters.add(new SimpleMsg("parameter", "account number", accountNo));
    cmdParameters.add(new SimpleMsg("parameter", "cvk", cvk == null ? "" : cvk));
    cmdParameters.add(new SimpleMsg("parameter", "unpredictable number", upn));
    cmdParameters.add(new SimpleMsg("parameter", "auth rc", authrc));
    cmdParameters.add(new SimpleMsg("parameter", "second factor auth rc", sfarc));
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Calculate CAVV/AAV", cmdParameters));
    String result = null;
    try {
        result = calculateCAVVImpl(accountNo, cvk, upn, authrc, sfarc);
        evt.addMessage(new SimpleMsg("result", "Calculated CAVV/AAV", 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 12 with Loggeable

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

the class BaseSMAdapter method calculatePVV.

@Override
public String calculatePVV(EncryptedPIN pinUnderLMK, T pvkA, T pvkB, int pvkIdx, List<String> excludes) throws SMException {
    List<Loggeable> cmdParameters = new ArrayList<>();
    cmdParameters.add(new SimpleMsg("parameter", "account number", pinUnderLMK.getAccountNumber()));
    cmdParameters.add(new SimpleMsg("parameter", "PIN under LMK", pinUnderLMK));
    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));
    String result = null;
    try {
        result = calculatePVVImpl(pinUnderLMK, 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 13 with Loggeable

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

the class BaseSMAdapter method encryptData.

@Override
public byte[] encryptData(SecureKey encKey, byte[] data, AlgorithmParameterSpec algspec, byte[] iv) throws SMException {
    List<Loggeable> cmdParameters = new ArrayList<>();
    cmdParameters.add(new SimpleMsg("parameter", "Encription Key", encKey));
    cmdParameters.add(new SimpleMsg("parameter", "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", "Encrypt Data", cmdParameters));
    byte[] result = null;
    try {
        result = encryptDataImpl(encKey, data, algspec, iv);
        List<Loggeable> r = new ArrayList<>();
        r.add(new SimpleMsg("result", "Encrypted 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)

Example 14 with Loggeable

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

the class BaseSMAdapter method translateKeyFromOldLMK.

@Override
public SecureKey translateKeyFromOldLMK(SecureKey key, SecureKeySpec keySpec) throws SMException {
    List<Loggeable> cmdParameters = new ArrayList<>();
    cmdParameters.add(new SimpleMsg("parameter", "Key under old LMK", key));
    cmdParameters.add(new SimpleMsg("parameter", "Key Specification", keySpec));
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Translate Key from old to new LMK", cmdParameters));
    SecureKey result = null;
    try {
        result = translateKeyFromOldLMKImpl(key, keySpec);
        evt.addMessage(new SimpleMsg("result", "Translated Key under new 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 15 with Loggeable

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

the class BaseSMAdapter method generateKey.

@Override
public SecureKey generateKey(SecureKeySpec keySpec) throws SMException {
    List<Loggeable> cmdParameters = new ArrayList<>();
    cmdParameters.add(new SimpleMsg("parameter", "Key Specification", keySpec));
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Generate Key", cmdParameters));
    SecureKey result = null;
    try {
        result = generateKeyImpl(keySpec);
        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) 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