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
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.