forked from openthread/ot-registrar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removal of ACE, doc updates, src format updates, and new generic-main…
… function WIP.
- Loading branch information
Showing
12 changed files
with
314 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,15 +12,15 @@ Help us keep OpenThread open and inclusive. Please read and follow our [Code of | |
|
||
## Bugs | ||
|
||
If you find a bug in the source code, you can help us by [submitting a GitHub Issue](https://github.com/openthread/ot-registrar/issues/new). Even better, you can [submit a Pull Request](#submitting-a-pull-request) with a fix. | ||
If you find a bug in the source code, you can help us by [submitting a GitHub Issue](https://github.com/EskoDijk/ot-registrar/issues/new). Even better, you can [submit a Pull Request](#submitting-a-pull-request) with a fix. | ||
|
||
## New features | ||
|
||
You can request a new feature by [submitting a GitHub Issue](https://github.com/openthread/ot-registrar/issues/new). | ||
You can request a new feature by [submitting a GitHub Issue](https://github.com/EskoDijk/ot-registrar/issues/new). | ||
|
||
If you would like to implement a new feature, please consider the scope of the new feature: | ||
|
||
* *Large feature* — [Submit a GitHub Issue](https://github.com/openthread/ot-registrar/issues/new) with your proposal so that the community can review and provide feedback first. Early feedback helps to ensure your proposal is accepted by the community, better coordinate our efforts, and minimize duplicated work. | ||
* *Large feature* — [Submit a GitHub Issue](https://github.com/EskoDijk/ot-registrar/issues/new) with your proposal so that the community can review and provide feedback first. Early feedback helps to ensure your proposal is accepted by the community, better coordinate our efforts, and minimize duplicated work. | ||
|
||
* *Small feature* — Can be implemented and directly [submitted as a Pull Request](#submitting-a-pull-request) without a proposal. | ||
|
||
|
@@ -32,17 +32,17 @@ The OpenThread Project follows the "Fork-and-Pull" model for accepting contribut | |
|
||
Setup your GitHub fork and continuous integration services: | ||
|
||
1. Fork the [OT Registrar repository](https://github.com/openthread/ot-registrar) by clicking **Fork** on the web UI. | ||
2. Enable [Travis CI](https://travis-ci.org/) by logging into the respective service with your GitHub account and enabling your newly created fork. We use Travis CI for Linux-based continuous integration checks. All contributions must pass these checks to be accepted. | ||
1. Fork the [OT Registrar repository](https://github.com/EskoDijk/ot-registrar) by clicking **Fork** on the web UI. | ||
2. Enable GitHub CI by logging into your GitHub account and enabling it on your newly created fork. We use CI for Linux-based continuous integration checks. All contributions must pass these checks to be accepted. | ||
|
||
Setup your local development environment: | ||
|
||
```bash | ||
# Clone your fork | ||
git clone [email protected]:<username>/ot-registrar.git | ||
git clone https://<username>@github.com/EskoDijk/ot-registrar.git | ||
|
||
# Configure upstream alias | ||
git remote add upstream git@github.com:openthread/ot-registrar.git | ||
git remote add upstream https://<username>@github.com/EskoDijk/ot-registrar.git | ||
``` | ||
|
||
### Submitting a pull request | ||
|
@@ -99,11 +99,7 @@ This will open up a text editor where you can specify which commits to squash. | |
|
||
#### Coding conventions and style | ||
|
||
OT Registrar uses and enforces the [Google Java Style](https://google.github.io/styleguide/javaguide.html) on all code. OT Registrar will automatically reformat the code when building the project with [maven](https://maven.apache.org). Use command `mvn com.coveo:fmt-maven-plugin:format` and `mvn com.coveo:fmt-maven-plugin:check` to explicitly reformat code and check for code-style compliance, respectively. | ||
|
||
As part of the cleanup process, also run `mvn com.coveo:fmt-maven-plugin:check` to ensure that your code passes the baseline code style checks. | ||
|
||
Make sure to include any code format changes in your commits. | ||
OT Registrar does not use the [Google Java Style](https://google.github.io/styleguide/javaguide.html) at this moment. The reason is that it introduces a very narrow line width, which makes code hard to read on normal-size desktop monitors that can handle long line lengths. | ||
|
||
#### Push and test | ||
|
||
|
@@ -115,8 +111,8 @@ git checkout <branch-name> | |
git push origin <branch-name> | ||
``` | ||
|
||
This will trigger the Travis Continuous Integration (CI) checks. You can view the results in the respective services. Note that the integration checks will report failures on occasion. If a failure occurs, you may try rerunning the test using the Travis web UI. | ||
This will trigger Github Continuous Integration (CI) checks. You can view the results in the respective services. | ||
|
||
#### Submit the pull request | ||
|
||
Once you've validated the Travis CI results, go to the page for your fork on GitHub, select your development branch, and click the **Pull Request** button. If you need to make any adjustments to your pull request, push the updates to GitHub. Your pull request will automatically track the changes on your development branch and update. | ||
Once you've validated the CI results, go to the page for your fork on GitHub, select your development branch, and click the **Pull Request** button. If you need to make any adjustments to your pull request, push the updates to GitHub. Your pull request will automatically track the changes on your development branch and update. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2024, The OpenThread Registrar Authors. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# 1. Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# 3. Neither the name of the copyright holder nor the | ||
# names of its contributors may be used to endorse or promote products | ||
# derived from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
|
||
readonly JAR_FILE=./target/ot-registrar-0.2-jar-with-dependencies.jar | ||
|
||
# test if Registrar JAR exists | ||
if [ ! -f "${JAR_FILE}" ]; then | ||
echo "Please build using 'mvn -DskipTests package' before running." | ||
exit 1 | ||
fi | ||
|
||
java -jar $JAR_FILE $@ |
164 changes: 164 additions & 0 deletions
164
src/main/java/com/google/openthread/main/OtRegistrarMain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
/* | ||
* Copyright (c) 2024, The OpenThread Registrar Authors. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. Neither the name of the copyright holder nor the | ||
* names of its contributors may be used to endorse or promote products | ||
* derived from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
package com.google.openthread.main; | ||
|
||
import com.google.openthread.Credentials; | ||
import com.google.openthread.LoggerInitializer; | ||
import com.google.openthread.domainca.DomainCA; | ||
import com.google.openthread.registrar.Registrar; | ||
import com.google.openthread.registrar.RegistrarBuilder; | ||
import com.google.openthread.tools.CredentialGenerator; | ||
import java.security.KeyStoreException; | ||
import org.apache.commons.cli.CommandLine; | ||
import org.apache.commons.cli.CommandLineParser; | ||
import org.apache.commons.cli.DefaultParser; | ||
import org.apache.commons.cli.HelpFormatter; | ||
import org.apache.commons.cli.Option; | ||
import org.apache.commons.cli.Options; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public final class OtRegistrarMain { | ||
|
||
private static Logger logger = LoggerFactory.getLogger(OtRegistrarMain.class); | ||
|
||
public static void main(String args[]) { | ||
|
||
final String HELP_FORMAT = "[-registrar | -masa | -pledge] [-h] [-v] [-d <domain-name>] [-f <keystore-file>] [-p <udp-port>]"; | ||
|
||
HelpFormatter helper = new HelpFormatter(); | ||
Options options = new Options(); | ||
|
||
Option registrarOpt = | ||
Option.builder("registrar") | ||
.desc("start as cBRSKI Registrar") | ||
.build(); | ||
|
||
Option masaOpt = | ||
Option.builder("masa") | ||
.desc("start as cBRSKI/BRSKI MASA") | ||
.build(); | ||
|
||
Option pledgeOpt = | ||
Option.builder("pledge") | ||
.desc("start as cBRSKI Pledge") | ||
.build(); | ||
|
||
Option domainNameOpt = | ||
Option.builder("d") | ||
.longOpt("domainname") | ||
.hasArg() | ||
.argName("domain-name") | ||
.desc("the domain name") | ||
.build(); | ||
|
||
Option fileOpt = | ||
Option.builder("f") | ||
.longOpt("file") | ||
.hasArg() | ||
.argName("keystore-file") | ||
.desc("the keystore file in PKCS#12 format") | ||
.build(); | ||
|
||
Option optPort = | ||
Option.builder("p") | ||
.longOpt("port") | ||
.hasArg() | ||
.argName("udp-port") | ||
.desc("the port to listen on") | ||
.build(); | ||
|
||
Option optVerbose = | ||
Option.builder("v") | ||
.longOpt("verbose") | ||
.desc("verbose mode with many logs") | ||
.build(); | ||
|
||
Option optForceMasaUri = | ||
Option.builder("m") | ||
.longOpt("masa") | ||
.hasArg() | ||
.argName("force-masa-uri") | ||
.desc("force the given MASA URI instead of the default one") | ||
.build(); | ||
|
||
Option helpOpt = | ||
Option.builder("h").longOpt("help").hasArg(false).desc("print this message").build(); | ||
|
||
options | ||
.addOption(registrarOpt) | ||
.addOption(masaOpt) | ||
.addOption(pledgeOpt) | ||
.addOption(domainNameOpt) | ||
.addOption(fileOpt) | ||
.addOption(optPort) | ||
.addOption(optVerbose) | ||
.addOption(optForceMasaUri) | ||
.addOption(helpOpt); | ||
|
||
try { | ||
CommandLineParser parser = new DefaultParser(); | ||
CommandLine cmd = parser.parse(options, args); | ||
|
||
LoggerInitializer.Init(cmd.hasOption('v')); | ||
|
||
if (cmd.hasOption('h')) { | ||
helper.printHelp(HELP_FORMAT, options); | ||
return; | ||
} | ||
|
||
String keyStoreFile = cmd.getOptionValue('f'); | ||
if (keyStoreFile == null) { | ||
keyStoreFile = "credentials/default.p12"; | ||
} | ||
|
||
String port = cmd.getOptionValue('p'); | ||
if (port == null) { | ||
port = "5683"; | ||
} | ||
|
||
String domainName = cmd.getOptionValue('d'); | ||
if (domainName == null) { | ||
domainName = "DefaultDomain"; | ||
} | ||
|
||
if (cmd.hasOption('m')) { | ||
// FIXME registrar.setForcedMasaUri(cmd.getOptionValue('m')); | ||
} | ||
|
||
logger.info("using keystore: {}", keyStoreFile); | ||
|
||
} catch (Exception e) { | ||
logger.error(e.getMessage(), e); | ||
helper.printHelp(HELP_FORMAT, options); | ||
return; | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.