Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh(as400): add ssl connection option #5476

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ RUN bash -e <<EOF

dnf install -y \
git \
java-17-openjdk-devel \
wget \
zstd \
java-17-openjdk-devel
zstd

cd /usr/local/src
wget https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ RUN bash -e <<EOF

dnf install -y \
git \
java-17-openjdk-devel \
wget \
zstd \
java-17-openjdk-devel
zstd

cd /usr/local/src
wget https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ apt-get update
apt-get install -y \
ca-certificates \
git \
zstd \
maven=3.8.7-1 \
openjdk-17-jdk
openjdk-17-jdk \
zstd

echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ apt-get update
apt-get install -y \
ca-certificates \
git \
zstd \
maven=3.6.3-5 \
openjdk-17-jdk
openjdk-17-jdk \
zstd

echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ apt-get update
apt-get install -y \
ca-certificates \
git \
openjdk-17-jdk \
wget \
zstd \
openjdk-17-jdk
zstd

cd /usr/local/src
wget https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/as400.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
with:
version_file: as400/packaging/centreon-as400-daemon.yaml
version_file: as400/connector.as400/pom.xml

package:
needs: [get-environment]
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/get-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,11 @@ jobs:
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const { execSync } = require('child_process');
let version = '';

if ('${{ steps.get_stability.outputs.stability }}' === 'testing') {
if ('${{ inputs.version_file }}'.match(/pom\.xml$/)) {
version = execSync(`grep -m 1 "<version>.*</version>" ${{ inputs.version_file }} | sed 's/.*<version>\\(.*\\)<\\/version>.*/\\1/'`).toString().trim();
} else if ('${{ steps.get_stability.outputs.stability }}' === 'testing') {
const branchName = "${{ github.head_ref || github.ref_name }}";
const matches = branchName.match(/^(?:release|hotfix)-(\d{8})$/);
if (matches) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Locale;

import com.ibm.as400.access.AS400;
import com.ibm.as400.access.SecureAS400;
import com.ibm.as400.access.AS400SecurityException;
import com.ibm.as400.access.ConnectionEvent;
import com.ibm.as400.access.ConnectionListener;
Expand All @@ -44,11 +45,13 @@ public abstract class AbstractHandler {
protected String host = null;
protected String login = null;
protected String password = null;
protected Integer ssl = 0;

public AbstractHandler(final String host, final String login, final String password) {
public AbstractHandler(final String host, final String login, final String password, final Integer ssl) {
this.host = host;
this.login = login;
this.password = password;
this.ssl = ssl;
}

static {
Expand Down Expand Up @@ -77,7 +80,28 @@ protected AS400 getNewAs400() throws AS400SecurityException, IOException {
properties.setLoginTimeout(Conf.as400LoginTimeout);
properties.setSoTimeout(Conf.as400ReadTimeout);

final AS400 system = new AS400(this.host, this.login, this.password);
if (this.ssl == 1) {
SecureAS400 system = new SecureAS400(this.host, this.login, this.password);
system.setSocketProperties(properties);
system.addConnectionListener(new ConnectionListener() {
@Override
public void connected(final ConnectionEvent event) {
ConnectorLogger.getInstance().getLogger().debug("Connect event service : " + event.getService());
}

@Override
public void disconnected(final ConnectionEvent event) {
ConnectorLogger.getInstance().getLogger().debug("Disconnect event service : " + event.getService());
}
});

system.validateSignon();

return (AS400)system;
}

AS400 system = new AS400(this.host, this.login, this.password);

system.setSocketProperties(properties);
system.addConnectionListener(new ConnectionListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
*/
public class CommandHandler extends AbstractHandler implements ICommandHandler {

public CommandHandler(final String host, final String login, final String password) {
super(host, login, password);
public CommandHandler(final String host, final String login, final String password, final Integer ssl) {
super(host, login, password, ssl);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public class DiskHandler extends AbstractHandler implements IDiskHandler {

private QyaspolYasp0300PcmlHandler qyaspolPcmlHandler = null;

public DiskHandler(final String host, final String login, final String password)
public DiskHandler(final String host, final String login, final String password, final Integer ssl)
throws AS400SecurityException, IOException {
super(host, login, password);
this.qyaspolPcmlHandler = new QyaspolYasp0300PcmlHandler(host, login, password);
super(host, login, password, ssl);
this.qyaspolPcmlHandler = new QyaspolYasp0300PcmlHandler(host, login, password, ssl);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
public class JobHandler extends AbstractHandler implements IJobHandler {
private final JobCache jobCache;

public JobHandler(final String host, final String login, final String password) {
super(host, login, password);
public JobHandler(final String host, final String login, final String password, final Integer ssl) {
super(host, login, password, ssl);
this.jobCache = new JobCache(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
*/
public class JobQueueHandler extends AbstractHandler implements IJobQueueHandler {

public JobQueueHandler(final String host, final String login, final String password) {
super(host, login, password);
public JobQueueHandler(final String host, final String login, final String password, final Integer ssl) {
super(host, login, password, ssl);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
*/
public class SubSystemHandler extends AbstractHandler implements ISubSystemHandler {

public SubSystemHandler(final String host, final String login, final String password)
public SubSystemHandler(final String host, final String login, final String password, final Integer ssl)
throws AS400SecurityException, IOException {
super(host, login, password);
super(host, login, password, ssl);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
public class SystemHandler extends AbstractHandler implements ISystemHandler {
private SystemStatus status = null;

public SystemHandler(final String host, final String login, final String password)
public SystemHandler(final String host, final String login, final String password, final Integer ssl)
throws AS400SecurityException, IOException {
this(host, login, password, null);
this(host, login, password, null, ssl);
}

public SystemHandler(final String host, final String login, final String password, SystemStatus as400Status)
public SystemHandler(final String host, final String login, final String password, SystemStatus as400Status, final Integer ssl)
throws AS400SecurityException, IOException {
super(host, login, password);
super(host, login, password, ssl);
this.status = as400Status == null ? new SystemStatus(getNewAs400()) : as400Status;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.List;

import com.ibm.as400.access.AS400;
import com.ibm.as400.access.SecureAS400;
import com.ibm.as400.access.AS400Message;
import com.ibm.as400.access.AS400SecurityException;
import com.ibm.as400.access.ConnectionEvent;
Expand Down Expand Up @@ -61,11 +62,13 @@ public class QyaspolYasp0300PcmlHandler {
String host = null;
String login = null;
String password = null;
Integer ssl = 0;

public QyaspolYasp0300PcmlHandler(final String host, final String login, final String password) {
public QyaspolYasp0300PcmlHandler(final String host, final String login, final String password, final Integer ssl) {
this.host = host;
this.login = login;
this.password = password;
this.ssl = ssl;
}

public void addYasp0300Data(final Yasp0300Data data) {
Expand Down Expand Up @@ -238,7 +241,27 @@ protected AS400 getNewAs400() throws AS400SecurityException, IOException {
properties.setLoginTimeout(Conf.as400LoginTimeout);
properties.setSoTimeout(Conf.as400ReadTimeout);

final AS400 system = new AS400(this.host, this.login, this.password);
if (this.ssl == 1) {
SecureAS400 system = new SecureAS400(this.host, this.login, this.password);
system.setSocketProperties(properties);
system.addConnectionListener(new ConnectionListener() {
@Override
public void connected(final ConnectionEvent event) {
ConnectorLogger.getInstance().getLogger().debug("Connect event service : " + event.getService());
}

@Override
public void disconnected(final ConnectionEvent event) {
ConnectorLogger.getInstance().getLogger().debug("Disconnect event service : " + event.getService());
}
});

system.validateSignon();

return (AS400)system;
}

AS400 system = new AS400(this.host, this.login, this.password);
system.setSocketProperties(properties);
system.addConnectionListener(new ConnectionListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public static String dumpMessage(QueuedMessage m) {
return sb.toString();
}

public CachedMessageQueueHandler(final String host, final String login, final String password) {
super(host, login, password);
public CachedMessageQueueHandler(final String host, final String login, final String password, final Integer ssl) {
super(host, login, password, ssl);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
*/
public class MessageQueueHandler extends AbstractHandler implements IMessageQueueHandler {

public MessageQueueHandler(final String host, final String login, final String password) {
super(host, login, password);
public MessageQueueHandler(final String host, final String login, final String password, final Integer ssl) {
super(host, login, password, ssl);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public class WorkWithProblemHandler extends AbstractHandler {
private final boolean SSL = false;
private final String logPrefix;

public WorkWithProblemHandler(final String host, final String login, final String password) {
super(host, login, password);
public WorkWithProblemHandler(final String host, final String login, final String password, final Integer ssl) {
super(host, login, password, ssl);
this.logPrefix = "[" + WorkWithProblemHandler.INSTANCE_ID++ + "]";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,7 @@ public interface IClient {

String getAs400CheckType();

Integer getAs400Ssl();

Object getAs400Arg(String key);
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ abstract class AbstractClient implements IClient {
private String as400Password = null;
private String as400CheckType = null;
private String as400Args = null;
private Integer as400Ssl = 0;
private List<Map<String, String>> argList = new ArrayList<Map<String, String>>();

@Override
Expand Down Expand Up @@ -77,6 +78,11 @@ public Object getAs400Arg(String key) {
return this.input.getArg(key);
}

@Override
public Integer getAs400Ssl() {
return this.input.getSsl();
}

public List<Map<String , String>> getAs400ArgList(String key) {
Object arg = this.input.getArg(key);
if (arg == null) {
Expand Down
Loading
Loading