Skip to content

Commit

Permalink
Merge pull request #5 from sentrysoftware/feature/issue-4-develop-snm…
Browse files Browse the repository at this point in the history
…p-library

Feature/issue 4 develop snmp library
  • Loading branch information
kawtarBK9 authored Dec 12, 2023
2 parents 344aa12 + cf94f4c commit 098b4b0
Show file tree
Hide file tree
Showing 143 changed files with 37,049 additions and 63 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar

# IntelliJ IDEA files
*.iml
.idea/
*.iws
*.ipr
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# oss-maven-template
# SNMP Java Client

![GitHub release (with filter)](https://img.shields.io/github/v/release/sentrysoftware/oss-maven-template)
![Build](https://img.shields.io/github/actions/workflow/status/sentrysoftware/oss-maven-template/deploy.yml)
![GitHub top language](https://img.shields.io/github/languages/top/sentrysoftware/oss-maven-template)
![License](https://img.shields.io/github/license/sentrysoftware/oss-maven-template)
![GitHub release (with filter)](https://img.shields.io/github/v/release/sentrysoftware/snmp)
![Build](https://img.shields.io/github/actions/workflow/status/sentrysoftware/snmp/deploy.yml)
![GitHub top language](https://img.shields.io/github/languages/top/sentrysoftware/snmp)
![License](https://img.shields.io/github/license/sentrysoftware/snmp)

Repository template for all Sentry open-source Java projects, published on Maven Central.
This project is a fork of the excellent [Westhawk's SNMP Library for Java](https://snmp.westhawk.co.uk/) ([see also](https://code.google.com/archive/p/snmp123)).

The SNMP Java client is designed to interact with remote hosts implementing SNMP v1, v2c, or v3 and allows to execute SNMP requests, including `Get` and `GetNext` requests as well as `Walk` and `Table` functionalities that represent an enhancements over traditional SNMP `Get` and `GetNext` methods.

See [Project Documentation](https://sentrysoftware.github.io/snmp/) and the [Javadoc](https://sentrysoftware.github.io/snmp/apidocs/) for more information on how to use this library in your code.

## Build instructions

Expand All @@ -31,8 +35,7 @@ But it is strongly recommended to only use [GitHub Actions "Release to Maven Cen

## License

License is Apache-2. Each source file must include the Apache-2 header (build will fail otherwise).
To update source files with the proper header, simply execute the below command:
License is GNU General Lesser Public License (LGPL) version 3.0. Each source file includes the LGPL-3 header (build will fail otherwise). To update source files with the proper header, simply execute the below command:

```bash
mvn license:update-file-header
Expand Down
56 changes: 39 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
<modelVersion>4.0.0</modelVersion>

<groupId>org.sentrysoftware</groupId>
<artifactId>MYARTIFACT</artifactId>
<name>MY PROJECT</name>
<version>0.1.00-SNAPSHOT</version>
<description>SOME DESCRIPTION</description>
<packaging>jar</packaging>
<artifactId>snmp</artifactId>
<name>SNMP Java Client</name>
<version>1.0.00-SNAPSHOT</version>
<description>SNMP Client Library for Java</description>
<packaging>jar</packaging>

<organization>
<name>Sentry Software</name>
<url>https://sentrysoftware.com</url>
</organization>

<url>https://github.com/sentrysoftware/MYREPO</url>
<url>https://sentrysoftware.github.io/snmp</url>
<inceptionYear>2023</inceptionYear>

<distributionManagement>
Expand All @@ -29,37 +29,56 @@

<licenses>
<license>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<name>LGPL-3.0</name>
<url>https://www.gnu.org/licenses/lgpl+gpl-3.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<issueManagement>
<system>GitHub</system>
<url>https://github.com/sentrysoftware/MYREPO/issues/</url>
<url>https://github.com/sentrysoftware/snmp/issues/</url>
</issueManagement>

<scm>
<connection>scm:git:https://github.com/sentrysoftware/MYREPO.git</connection>
<url>https://github.com/sentrysoftware/MYREPO</url>
<connection>scm:git:https://github.com/sentrysoftware/snmp.git</connection>
<url>https://sentrysoftware.github.io/snmp</url>
<tag>HEAD</tag>
</scm>

<developers>
<developer>
<name>MY NAME (@MY_ID)</name>
<email>MYNAME@sentrysoftware.com</email>
<name>Bertrand Martin (@bertysentry)</name>
<email>bertrand@sentrysoftware.com</email>
<roles>
<role>Project founder</role>
<role>maintainer</role>
</roles>
</developer>
<developer>
<name>Nassim Boutekedjiret (@NassimBtk)</name>
<email>[email protected]</email>
<roles>
<role>maintainer</role>
</roles>
</developer>
<developer>
<name>Kawtar Bakour (@KawtarBK9)</name>
<email>[email protected]</email>
<roles>
<role>maintainer</role>
</roles>
</developer>
<developer>
<name>Elyes Cherfa (@CherfaElyes)</name>
<email>[email protected]</email>
<roles>
<role>maintainer</role>
</roles>
</developer>
</developers>

<properties>
<!-- Java 11 -->
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>

<!-- UTF-8 -->
Expand Down Expand Up @@ -153,7 +172,7 @@
<artifactId>license-maven-plugin</artifactId>
<version>2.3.0</version>
<configuration>
<licenseName>apache_v2</licenseName>
<licenseName>lgpl_v3</licenseName>
<copyrightOwners>Sentry Software</copyrightOwners>
<copyrightStringFormat>Copyright %1$s %2$s</copyrightStringFormat>
<includes>
Expand Down Expand Up @@ -183,6 +202,9 @@
<!-- javadoc -->
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<doclint>all,-missing</doclint>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down
78 changes: 78 additions & 0 deletions src/main/java/org/bouncycastle/crypto/BlockCipher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package org.bouncycastle.crypto;

/*-
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
* SNMP Java Client
* ჻჻჻჻჻჻
* Copyright 2023 Sentry Software, Westhawk
* ჻჻჻჻჻჻
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
*/


/**
* Block cipher engines are expected to conform to this interface.
*/
public interface BlockCipher
{
/**
* Initialise the cipher.
*
* @param forEncryption if true the cipher is initialised for
* encryption, if false for decryption.
* @param params the key and other data required by the cipher.
* @exception IllegalArgumentException if the params argument is
* inappropriate.
*/
public void init(boolean forEncryption, CipherParameters params)
throws IllegalArgumentException;

/**
* Return the name of the algorithm the cipher implements.
*
* @return the name of the algorithm the cipher implements.
*/
public String getAlgorithmName();

/**
* Return the block size for this cipher (in bytes).
*
* @return the block size for this cipher in bytes.
*/
public int getBlockSize();

/**
* Process one block of input from the array in and write it to
* the out array.
*
* @param in the array containing the input data.
* @param inOff offset into the in array the data starts at.
* @param out the array the output data will be copied into.
* @param outOff the offset into the out array the output will start at.
* @exception DataLengthException if there isn't enough data in in, or
* space in out.
* @exception IllegalStateException if the cipher isn't initialised.
* @return the number of bytes processed and produced.
*/
public int processBlock(byte[] in, int inOff, byte[] out, int outOff)
throws DataLengthException, IllegalStateException;

/**
* Reset the cipher. After resetting the cipher is in the same state
* as it was after the last init (if there was one).
*/
public void reset();
}
60 changes: 60 additions & 0 deletions src/main/java/org/bouncycastle/crypto/CipherKeyGenerator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package org.bouncycastle.crypto;

/*-
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
* SNMP Java Client
* ჻჻჻჻჻჻
* Copyright 2023 Sentry Software, Westhawk
* ჻჻჻჻჻჻
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
*/

import java.security.SecureRandom;

/**
* The base class for symmetric, or secret, cipher key generators.
*/
public class CipherKeyGenerator
{
protected SecureRandom random;
protected int strength;

/**
* initialise the key generator.
*
* @param param the parameters to be used for key generation
*/
public void init(
KeyGenerationParameters param)
{
this.random = param.getRandom();
this.strength = (param.getStrength() + 7) / 8;
}

/**
* generate a secret key.
*
* @return a byte array containing the key value.
*/
public byte[] generateKey()
{
byte[] key = new byte[strength];

random.nextBytes(key);

return key;
}
}
30 changes: 30 additions & 0 deletions src/main/java/org/bouncycastle/crypto/CipherParameters.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.bouncycastle.crypto;

/*-
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
* SNMP Java Client
* ჻჻჻჻჻჻
* Copyright 2023 Sentry Software, Westhawk
* ჻჻჻჻჻჻
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
*/

/**
* all parameter classes implement this.
*/
public interface CipherParameters
{
}
51 changes: 51 additions & 0 deletions src/main/java/org/bouncycastle/crypto/DataLengthException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package org.bouncycastle.crypto;

/*-
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
* SNMP Java Client
* ჻჻჻჻჻჻
* Copyright 2023 Sentry Software, Westhawk
* ჻჻჻჻჻჻
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
*/

/**
* this exception is thrown if a buffer that is meant to have output
* copied into it turns out to be too short, or if we've been given
* insufficient input. In general this exception will get thrown rather
* than an ArrayOutOfBounds exception.
*/
public class DataLengthException
extends RuntimeCryptoException
{
/**
* base constructor.
*/
public DataLengthException()
{
}

/**
* create a DataLengthException with the given message.
*
* @param message the message to be carried with the exception.
*/
public DataLengthException(
String message)
{
super(message);
}
}
Loading

0 comments on commit 098b4b0

Please sign in to comment.