Search in sources :

Example 31 with SimpleMsg

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

the class JCESecurityModule method generateClearKeyComponent.

/**
 * Generates a random clear key component.<br>
 * Used by Console, that's why it is package protected.
 * @param keyLength
 * @return clear key componenet
 * @throws SMException
 */
String generateClearKeyComponent(short keyLength) throws SMException {
    String clearKeyComponenetHexString;
    SimpleMsg[] cmdParameters = { new SimpleMsg("parameter", "Key Length", keyLength) };
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Generate Clear Key Component", cmdParameters));
    try {
        Key clearKey = jceHandler.generateDESKey(keyLength);
        byte[] clearKeyData = jceHandler.extractDESKeyMaterial(keyLength, clearKey);
        clearKeyComponenetHexString = ISOUtil.hexString(clearKeyData);
        evt.addMessage(new SimpleMsg("result", "Generated Clear Key Componenet", clearKeyComponenetHexString));
    } catch (JCEHandlerException e) {
        evt.addMessage(e);
        throw e;
    } finally {
        Logger.log(evt);
    }
    return clearKeyComponenetHexString;
}
Also used : LogEvent(org.jpos.util.LogEvent) SimpleMsg(org.jpos.util.SimpleMsg) SecretKey(javax.crypto.SecretKey)

Example 32 with SimpleMsg

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

the class BaseSMAdapter method printPIN.

@Override
public void printPIN(String accountNo, EncryptedPIN pinUnderKd1, SecureDESKey kd1, String template, Map<String, String> fields) throws SMException {
    List<Loggeable> cmdParameters = new ArrayList<Loggeable>();
    cmdParameters.add(new SimpleMsg("parameter", "account number", accountNo == null ? "" : accountNo));
    cmdParameters.add(new SimpleMsg("parameter", "PIN under Key data 1", pinUnderKd1 == null ? "" : pinUnderKd1));
    if (kd1 != null)
        cmdParameters.add(new SimpleMsg("parameter", "Key data 1", kd1));
    cmdParameters.add(new SimpleMsg("parameter", "Template", template == null ? "" : template));
    if (fields != null)
        cmdParameters.add(new SimpleMsg("parameter", "Fields", fields));
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Print PIN", cmdParameters.toArray(new Loggeable[0])));
    try {
        printPINImpl(accountNo, pinUnderKd1, kd1, template, fields);
    } 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 33 with SimpleMsg

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

the class BaseSMAdapter method verifyARQCGenerateARPC.

@Override
public byte[] verifyARQCGenerateARPC(MKDMethod mkdm, SKDMethod skdm, SecureDESKey imkac, String accoutNo, String acctSeqNo, byte[] arqc, byte[] atc, byte[] upn, byte[] transData, ARPCMethod arpcMethod, byte[] arc, byte[] propAuthData) throws SMException {
    SimpleMsg[] cmdParameters = { new SimpleMsg("parameter", "mkd method", mkdm), new SimpleMsg("parameter", "skd method", skdm), new SimpleMsg("parameter", "imk-ac", imkac), new SimpleMsg("parameter", "account number", accoutNo), new SimpleMsg("parameter", "accnt seq no", acctSeqNo), new SimpleMsg("parameter", "arqc", arqc == null ? "" : ISOUtil.hexString(arqc)), new SimpleMsg("parameter", "atc", atc == null ? "" : ISOUtil.hexString(atc)), new SimpleMsg("parameter", "upn", upn == null ? "" : ISOUtil.hexString(upn)), new SimpleMsg("parameter", "trans. data", transData == null ? "" : ISOUtil.hexString(transData)), new SimpleMsg("parameter", "arpc gen. method", arpcMethod), new SimpleMsg("parameter", "auth. rc", arc == null ? "" : ISOUtil.hexString(arc)), new SimpleMsg("parameter", "prop auth. data", propAuthData == null ? "" : ISOUtil.hexString(propAuthData)) };
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Genarate ARPC", cmdParameters));
    try {
        byte[] result = verifyARQCGenerateARPCImpl(mkdm, skdm, imkac, accoutNo, acctSeqNo, arqc, atc, upn, transData, arpcMethod, arc, propAuthData);
        evt.addMessage(new SimpleMsg("result", "ARPC", result == null ? "" : ISOUtil.hexString(result)));
        return result;
    } 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 34 with SimpleMsg

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

the class BaseSMAdapter method verifydCVV.

@Override
public boolean verifydCVV(String accountNo, SecureDESKey imkac, String dcvv, Date expDate, String serviceCode, byte[] atc, MKDMethod mkdm) throws SMException {
    SimpleMsg[] cmdParameters = { new SimpleMsg("parameter", "account number", accountNo), new SimpleMsg("parameter", "imk-ac", imkac == null ? "" : imkac), new SimpleMsg("parameter", "dCVV", dcvv), new SimpleMsg("parameter", "Exp date", expDate), new SimpleMsg("parameter", "Service code", serviceCode), new SimpleMsg("parameter", "atc", atc == null ? "" : ISOUtil.hexString(atc)), new SimpleMsg("parameter", "mkd method", mkdm) };
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Verify dCVV", cmdParameters));
    try {
        boolean r = verifydCVVImpl(accountNo, imkac, dcvv, expDate, serviceCode, atc, mkdm);
        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)

Example 35 with SimpleMsg

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

the class BaseSMAdapter method verifyARQC.

@Override
public boolean verifyARQC(MKDMethod mkdm, SKDMethod skdm, SecureDESKey imkac, String accoutNo, String acctSeqNo, byte[] arqc, byte[] atc, byte[] upn, byte[] transData) throws SMException {
    SimpleMsg[] cmdParameters = { new SimpleMsg("parameter", "mkd method", mkdm), new SimpleMsg("parameter", "skd method", skdm), new SimpleMsg("parameter", "imk-ac", imkac), new SimpleMsg("parameter", "account number", accoutNo), new SimpleMsg("parameter", "accnt seq no", acctSeqNo), new SimpleMsg("parameter", "arqc", arqc == null ? "" : ISOUtil.hexString(arqc)), new SimpleMsg("parameter", "atc", atc == null ? "" : ISOUtil.hexString(atc)), new SimpleMsg("parameter", "upn", upn == null ? "" : ISOUtil.hexString(upn)), new SimpleMsg("parameter", "trans. data", transData == null ? "" : ISOUtil.hexString(transData)) };
    LogEvent evt = new LogEvent(this, "s-m-operation");
    evt.addMessage(new SimpleMsg("command", "Verify ARQC/TC/AAC", cmdParameters));
    try {
        boolean r = verifyARQCImpl(mkdm, skdm, imkac, accoutNo, acctSeqNo, arqc, atc, upn, transData);
        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)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