use of com.ibm.as400.access.AS400Bin4 in project DCM-tools by ThePrez.
the class DcmApiCaller method callQycdRenewCertificate_RNWC0300.
public void callQycdRenewCertificate_RNWC0300(final AppLogger _logger, final String _file) throws PropertyVetoException, AS400SecurityException, ErrorCompletingRequestException, IOException, InterruptedException, ObjectDoesNotExistException {
final ProgramCall program = new ProgramCall(m_conn);
// Initialize the name of the program to run.
final String programName = "/QSYS.LIB/QYCDRNWC.PGM";
final String apiFormat = "RNWC0300";
final AS400Structure arg0 = new AS400Structure(new AS400DataType[] { // 0 0 Binary (4) Offset to certificate path and file name
new AS400Bin4(), // 4 4 Binary (4) Length of certificate path and file name
new AS400Bin4(), // Char (*) Certificate path and file name
new AS400Text(// TODO
_file.length()) });
// Set up the parms
final ProgramParameter[] parameterList = new ProgramParameter[14];
// 1 Certificate request data Input Char(*)
parameterList[0] = new ProgramParameter(arg0.toBytes(new Object[] { 8, _file.length(), _file }));
// 2 Length of certificate request data Input Binary(4)
parameterList[1] = new ProgramParameter(new AS400Bin4().toBytes(arg0.getByteLength()));
// 3 Format name Input Char(8)
parameterList[2] = new ProgramParameter(new AS400Text(8).toBytes(apiFormat));
// 4 Error Code I/O Char(*)
final ErrorCodeParameter ec = new ErrorCodeParameter(true, true);
parameterList[3] = ec;
program.setProgram(programName, parameterList);
// Run the program.
runProgram(_logger, program, ec);
}
use of com.ibm.as400.access.AS400Bin4 in project DCM-tools by ThePrez.
the class DcmApiCaller method callQycdRemoveCertUsage.
public void callQycdRemoveCertUsage(final AppLogger _logger, final String _dcmStore, final String _dcmStorePw, final String _appId, final String _alias) throws PropertyVetoException, AS400SecurityException, ErrorCompletingRequestException, IOException, InterruptedException, ObjectDoesNotExistException {
final ServiceProgramCall program = new ServiceProgramCall(m_conn);
// Initialize the name of the program to run.
final String programName = "/QSYS.LIB/QICSS.LIB/QYCDCUSG.SRVPGM";
final ProgramParameter[] parameterList = new ProgramParameter[7];
// 1 Application ID Input Char(*)
parameterList[0] = new ProgramParameter(new AS400Text(_appId.length()).toBytes(_appId));
// 2 Length of application ID Input Binary(4)
parameterList[1] = new ProgramParameter(new AS400Bin4().toBytes(_appId.length()));
// 3 Certificate store name Input Char(*)
parameterList[2] = new ProgramParameter(new AS400Text(_dcmStore.length()).toBytes(_dcmStore));
// 4 Length of certificate store name Input Binary(4)
parameterList[3] = new ProgramParameter(new AS400Bin4().toBytes(_dcmStore.length()));
// 5 Certificate ID Input Char(*)
parameterList[4] = new ProgramParameter(new AS400Text(_alias.length()).toBytes(_alias));
// 6 Length of certificate ID Input Binary(4)
parameterList[5] = new ProgramParameter(new AS400Bin4().toBytes(_alias.length()));
// 7 Error code I/O Char(*)
final ErrorCodeParameter ec = new ErrorCodeParameter(true, true);
parameterList[6] = ec;
program.setProgram(programName, parameterList);
program.setProcedureName("QycdRemoveCertUsage");
// Run the program.
runProgram(_logger, program, ec);
}
use of com.ibm.as400.access.AS400Bin4 in project DCM-tools by ThePrez.
the class DcmApiCaller method callQykmImportKeyStore.
// QykmImportKeyStore
public void callQykmImportKeyStore(final AppLogger _logger, final String _dcmStore, final String _dcmStorePw, final String _dcmImportFile, final String _importFilePw) throws PropertyVetoException, AS400SecurityException, ErrorCompletingRequestException, IOException, InterruptedException, ObjectDoesNotExistException {
final ProgramCall program = new ProgramCall(m_conn);
// Initialize the name of the program to run.
final String programName = "/QSYS.LIB/QYKMIMPK.PGM";
// Set up the parms
final ProgramParameter[] parameterList = new ProgramParameter[14];
// 1 Certificate store path and file Name Input Char(*)
parameterList[0] = new ProgramParameter(new AS400Text(_dcmStore.length()).toBytes(_dcmStore));
// 2 Length of certificate store path and file Name Input Binary(4)
parameterList[1] = new ProgramParameter(new AS400Bin4().toBytes(_dcmStore.length()));
// 3 Format of certificate store path and file Name Input Char(8)
parameterList[2] = new ProgramParameter(new AS400Text(8).toBytes("OBJN0100"));
// 4 Certificate store password Input Char(*)
parameterList[3] = new ProgramParameter(new AS400Text(_dcmStorePw.length(), 1208).toBytes(_dcmStorePw));
// 5 Length of certificate store password Input Binary(4)
parameterList[4] = new ProgramParameter(new AS400Bin4().toBytes(_dcmStorePw.length()));
// 6 CCSID of certificate store password Input Binary(4)
parameterList[5] = new ProgramParameter(new AS400Bin4().toBytes(1208));
// 7 Import path and file name Input Char(*)
parameterList[6] = new ProgramParameter(new AS400Text(_dcmImportFile.length()).toBytes(_dcmImportFile));
// 8 Length of import path and file name Input Binary(4)
parameterList[7] = new ProgramParameter(new AS400Bin4().toBytes(_dcmImportFile.length()));
// 9 Format of import path and file name Input Char(8)
parameterList[8] = new ProgramParameter(new AS400Text(8).toBytes("OBJN0100"));
// 10 Version of import file Input Char(10)
parameterList[9] = new ProgramParameter(new AS400Text(10).toBytes("*PKCS12V3 "));
// 11 Import file password Input Char(*)
parameterList[10] = new ProgramParameter(new AS400Text(_importFilePw.length(), 1208).toBytes(_importFilePw));
// 12 Length of import file password Input Binary(4)
parameterList[11] = new ProgramParameter(new AS400Bin4().toBytes(_importFilePw.length()));
// 13 CCSID of import file password Input Binary(4)
parameterList[12] = new ProgramParameter(new AS400Bin4().toBytes(1208));
// 14 Error code I/O Char(*)
final ErrorCodeParameter ec = new ErrorCodeParameter(true, true);
parameterList[13] = ec;
program.setProgram(programName, parameterList);
// Run the program.
runProgram(_logger, program, ec);
}
use of com.ibm.as400.access.AS400Bin4 in project DCM-tools by ThePrez.
the class DcmApiCaller method callQykmExportKeyStore.
public void callQykmExportKeyStore(final AppLogger _logger, final String _dcmStore, final String _dcmStorePw, final String _exportFile, final String _exportFilePw) throws PropertyVetoException, AS400SecurityException, ErrorCompletingRequestException, IOException, InterruptedException, ObjectDoesNotExistException {
final ProgramCall program = new ProgramCall(m_conn);
// Initialize the name of the program to run.
final String programName = "/QSYS.LIB/QYKMEXPK.PGM";
final ProgramParameter[] parameterList = new ProgramParameter[14];
// 1 Certificate store path and file Name Input Char(*)
parameterList[0] = new ProgramParameter(new AS400Text(_dcmStore.length()).toBytes(_dcmStore));
// 2 Length of certificate store path and file Name Input Binary(4)
parameterList[1] = new ProgramParameter(new AS400Bin4().toBytes(_dcmStore.length()));
// 3 Format of certificate store path and file Name Input Char(8)
parameterList[2] = new ProgramParameter(new AS400Text(8).toBytes("OBJN0100"));
// 4 Certificate store password Input Char(*)
parameterList[3] = new ProgramParameter(new AS400Text(_dcmStorePw.length(), 1208).toBytes(_dcmStorePw));
// 5 Length of certificate store password Input Binary(4)
parameterList[4] = new ProgramParameter(new AS400Bin4().toBytes(_dcmStorePw.length()));
// 6 CCSID of certificate store password Input Binary(4)
parameterList[5] = new ProgramParameter(new AS400Bin4().toBytes(1208));
// 7 Export path and file name Input Char(*)
parameterList[6] = new ProgramParameter(new AS400Text(_exportFile.length()).toBytes(_exportFile));
// 8 Length of export path and file name Input Binary(4)
parameterList[7] = new ProgramParameter(new AS400Bin4().toBytes(_exportFile.length()));
// 9 Format of import path and file name Input Char(8)
parameterList[8] = new ProgramParameter(new AS400Text(8).toBytes("OBJN0100"));
// 10 Version of export file Input Char(10)
parameterList[9] = new ProgramParameter(new AS400Text(10).toBytes("*PKCS12V3 "));
// 11 Export file password Input Char(*)
parameterList[10] = new ProgramParameter(new AS400Text(_exportFilePw.length(), 1208).toBytes(_exportFilePw));
// 12 Length of export file password Input Binary(4)
parameterList[11] = new ProgramParameter(new AS400Bin4().toBytes(_exportFilePw.length()));
// 13 CCSID of export file password Input Binary(4)
parameterList[12] = new ProgramParameter(new AS400Bin4().toBytes(1208));
// 14 Error code I/O Char(*)
final ErrorCodeParameter ec = new ErrorCodeParameter(true, true);
parameterList[13] = ec;
program.setProgram(programName, parameterList);
// Run the program.
runProgram(_logger, program, ec);
}
use of com.ibm.as400.access.AS400Bin4 in project sirius-biz by scireum.
the class Transformer method transform.
private int transform(Entry<Field, Transform> e, Object object, int ccsid, byte[] data, int offset) {
Transform info = e.getValue();
Field field = e.getKey();
AtomicInteger nextIndex = new AtomicInteger(offset);
try {
if (info.targetType() == AS400Bin4.class) {
AS400Bin4 mapper = new AS400Bin4();
nextIndex.addAndGet(mapper.getByteLength());
field.set(object, mapper.toObject(data, offset));
} else if (info.targetType() == AS400Text.class) {
AS400Text mapper = new AS400Text(info.length(), ccsid);
nextIndex.addAndGet(mapper.getByteLength());
field.set(object, ((String) mapper.toObject(data, offset)).trim());
} else if (info.targetType() == AS400ZonedDecimal.class) {
AS400ZonedDecimal mapper = new AS400ZonedDecimal(info.length(), info.decimal());
nextIndex.addAndGet(mapper.getByteLength());
field.set(object, mapper.toObject(data, offset));
} else if (info.targetType() == AS400PackedDecimal.class) {
AS400PackedDecimal mapper = new AS400PackedDecimal(info.length(), info.decimal());
nextIndex.addAndGet(mapper.getByteLength());
field.set(object, mapper.toObject(data, offset));
} else if (info.targetType() == Byte.class) {
nextIndex.addAndGet(info.length());
field.set(object, Arrays.copyOfRange(data, offset, info.length()));
} else {
throw Exceptions.handle().to(I5Connector.LOG).withSystemErrorMessage("Cannot transform a field to type: %s (%s.%s)", info.targetType().getName(), object.getClass().getName(), field.getName()).handle();
}
} catch (Exception ex) {
if (info.ignoreErrors()) {
I5Connector.LOG.FINE("Ignoring a conversion error for %s of %s: %s (%s)", field.getName(), object.getClass().getName(), ex.getMessage(), ex.getClass().getName());
Exceptions.ignore(ex);
} else {
throw Exceptions.handle().to(I5Connector.LOG).error(ex).withSystemErrorMessage("Error while transforming '%s.%s' to %s: %s (%s)", object.getClass().getName(), field.getName(), info.targetType().getName()).handle();
}
}
return nextIndex.get();
}
Aggregations