Zetect Connector Guide Back to zetect.inSwitch portal ⇄

Preparing Your Environment

Set up the tools and access you need before you write a connector. A connector is a standalone Maven project that compiles against the published Connector API. You don't need the agent's source code.

Prerequisite

A GitHub account that has been granted read access to the package that hosts the Connector API.

Required permission

Administrator access to the console, to issue the agent API key and to onboard a test application. A developer can work with an administrator instead.

Installing the toolchain

RequirementNeeded for
JDK 17The Connector API, the agent and every connector target Java 17.
Maven 3.9 or laterBuilding the connector JAR with mvn clean package.
Docker with BuildxOptional. Only needed if you package the connector as an installer image for an agent that runs in Docker.
Network access to the target systemFrom the machine that runs the agent, not from Zetect.

Configuring access to the Connector API

Your connector depends on io.cyiam:cyiam-connector-api, published to GitHub Packages. GitHub Packages asks for credentials on every download, even for reads, so Maven needs a token. You only read the package, so a read-only token is enough.

To configure Maven:

  1. In GitHub, create a personal access token (classic) with the read:packages scope.
  2. Copy settings.xml.example from the agent repository to ~/.m2/settings.xml. If you already have a settings file, copy only its <server> block into yours.
  3. In the <server> block, replace the username with your GitHub username and the password with the token.
  4. Keep the server <id> as github. Maven matches it to the <repository> with the same id in your connector's pom.xml.
<settings>
  <servers>
    <server>
      <id>github</id>
      <username>your-github-username</username>
      <password>your-read-packages-token</password>
    </server>
  </servers>
</settings>

The connector template's pom.xml already declares the matching repository. Keep that block when you copy the template.

Getting an agent to test with

You test a connector by running it inside a real agent registered to a Zetect tenant, ideally a test tenant.

To prepare a test agent:

  1. Ask an administrator for the tenant identifier and the agent API key. Administrators generate the key under Configuration → Agent API Key; it is shown only once. See Deploying Agents.
  2. Install the agent on a machine that can reach the target system, with Java 17 and outbound access to Zetect and the broker.
  3. Set the agent's environment variables:
    • CYIAM_API_KEY – the agent API key. Required.
    • CYIAM_BASE_URL – your Zetect address, without a trailing slash. Required.
    • CYIAM_TENANT_SLUG – the tenant identifier. Required.
    • CYIAM_CONNECTORS_DIR – the folder the agent loads connectors from. Defaults to ./connectors, and to /opt/cyiam-agent/connectors in the agent's container image.
    • CYIAM_AGENT_NAME and CYIAM_LOG_LEVEL – optional. Set CYIAM_LOG_LEVEL=DEBUG while you develop.
  4. Start the agent and confirm it shows as Online under Configuration → Agents.

Project structure

Every connector follows the same layout. The fastest way to get it is to copy the connector-template folder, as described in Building a Connector.

cyiam-connector-<name>/
├── pom.xml
└── src/main/
    ├── java/<your/package>/
    │   └── <Name>Connector.java            implements Connector
    └── resources/
        └── META-INF/services/
            └── io.cyiam.connector.api.Connector   one line: your class name

Troubleshooting

ProblemWhat to check
Maven can't resolve cyiam-connector-api (401 or 403)The token is missing the read:packages scope, or the server id in settings.xml isn't github.
Agent stops with "Registration rejected"The API key or tenant identifier is wrong. The agent doesn't retry after this error; fix the variables and restart it.
Agent logs "Connectors directory does not exist"Create the folder that CYIAM_CONNECTORS_DIR points to.