[java-identity-provider] branch master updated: IDP-1522 - Support for encrypted attributes in the resolver
Scott Cantor
cantor.2 at osu.edu
Wed Jul 1 17:32:34 UTC 2020
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=78e0b960d99bb1976fbeb9329f5258bf72f3fffb
The following commit(s) were added to refs/heads/master by this push:
new 78e0b960d IDP-1522 - Support for encrypted attributes in the resolver
78e0b960d is described below
commit 78e0b960d99bb1976fbeb9329f5258bf72f3fffb
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jul 1 13:31:51 2020 -0400
IDP-1522 - Support for encrypted attributes in the resolver
https://issues.shibboleth.net/jira/browse/IDP-1522
Add CLI for DataSealer via Spring wrapper.
---
.../shibboleth/idp/cli/DataSealerArguments.java | 101 +++++++++++++++++++
.../java/net/shibboleth/idp/cli/DataSealerCLI.java | 110 +++++++++++++++++++++
idp-distribution/src/main/resources/bin/sealer.bat | 4 +
idp-distribution/src/main/resources/bin/sealer.sh | 7 ++
4 files changed, 222 insertions(+)
diff --git a/idp-core/src/main/java/net/shibboleth/idp/cli/DataSealerArguments.java b/idp-core/src/main/java/net/shibboleth/idp/cli/DataSealerArguments.java
new file mode 100644
index 000000000..90f359ebf
--- /dev/null
+++ b/idp-core/src/main/java/net/shibboleth/idp/cli/DataSealerArguments.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.idp.cli;
+
+import java.io.PrintStream;
+
+import javax.annotation.Nullable;
+
+import com.beust.jcommander.Parameter;
+
+import net.shibboleth.utilities.java.support.security.DataSealer;
+
+/**
+ * Arguments for DataSealer CLI.
+ */
+public class DataSealerArguments extends net.shibboleth.ext.spring.cli.AbstractCommandLineArguments {
+
+ /**
+ * Name of a specific {@link DataSealer}, if one has been requested.
+ */
+ @Parameter(names = "--dataSealer")
+ @Nullable private String dataSealerName;
+
+ /** Operation enum. */
+ public enum OperationType {
+ /** Wrap/encrypt. */
+ WRAP,
+ /** Unwrap/decrypt. */
+ UNWRAP,
+ }
+
+ /** Requested operation. */
+ @Nullable private OperationType operation;
+
+ /**
+ * Get name of {@link DataSealer} bean to access.
+ *
+ * @return bean name
+ */
+ @Nullable public String getDataSealerName() {
+ return dataSealerName;
+ }
+
+ /**
+ * Get operation to perform.
+ *
+ * @return operation
+ */
+ @Nullable public OperationType getOperation() {
+ return operation;
+ }
+
+ /** {@inheritDoc} */
+ public void validate() throws IllegalArgumentException {
+ super.validate();
+
+ if (getOtherArgs().size() < 3) {
+ throw new IllegalArgumentException("Missing one or more required arguments");
+ }
+
+ if ("enc".equals(getOtherArgs().get(1))) {
+ operation = OperationType.WRAP;
+ } else if ("dec".equals(getOtherArgs().get(1))) {
+ operation = OperationType.UNWRAP;
+ } else {
+ throw new IllegalArgumentException("Invalid operation requested, must be one of enc|dec");
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void printHelp(final PrintStream out) {
+ out.println("DataSealerCLI");
+ out.println("Provides a command line interface for DataSealer wrap/unwrap operations.");
+ out.println();
+ out.println(" DataSealerCLI [options] springConfiguration encrypt|decrypt string");
+ out.println();
+ out.println(" springConfiguration name of Spring configuration resource to use");
+ out.println(" enc|dec encrypt or decrypt operation");
+ out.println(" string value to encrypt or decrypt");
+ super.printHelp(out);
+ out.println();
+ out.println(String.format(" --%-20s %s", "dataSealer", "Specifies a non-default DataSealer bean to use."));
+ out.println();
+ }
+
+}
\ No newline at end of file
diff --git a/idp-core/src/main/java/net/shibboleth/idp/cli/DataSealerCLI.java b/idp-core/src/main/java/net/shibboleth/idp/cli/DataSealerCLI.java
new file mode 100644
index 000000000..d073304d9
--- /dev/null
+++ b/idp-core/src/main/java/net/shibboleth/idp/cli/DataSealerCLI.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.idp.cli;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.shibboleth.ext.spring.cli.AbstractCommandLine;
+import net.shibboleth.idp.Version;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.security.DataSealer;
+
+/**
+ * Command line utility for {@link DataSealer}.
+ */
+public class DataSealerCLI extends AbstractCommandLine<DataSealerArguments> {
+
+ /** Class logger. */
+ @Nullable private Logger log;
+
+ /** {@inheritDoc} */
+ @Override
+ @Nonnull protected Logger getLogger() {
+ if (log == null) {
+ log = LoggerFactory.getLogger(DataSealerCLI.class);
+ }
+ return log;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nonnull protected Class<DataSealerArguments> getArgumentClass() {
+ return DataSealerArguments.class;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nonnull @NotEmpty protected String getVersion() {
+ return Version.getVersion();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected int doRun(@Nonnull final DataSealerArguments args) {
+ final int ret = super.doRun(args);
+ if (ret != RC_OK) {
+ return ret;
+ }
+
+ try {
+ final DataSealer sealer;
+ if (args.getDataSealerName() != null) {
+ sealer = getApplicationContext().getBean(args.getDataSealerName(), DataSealer.class);
+ } else {
+ sealer = getApplicationContext().getBean(DataSealer.class);
+ }
+
+ switch (args.getOperation()) {
+ case WRAP:
+ System.out.println(sealer.wrap(args.getOtherArgs().get(2)));
+ break;
+ case UNWRAP:
+ System.out.println(sealer.unwrap(args.getOtherArgs().get(2)));
+ break;
+
+ default:
+ getLogger().error("Invalid operation");
+ return RC_IO;
+ }
+
+ } catch (final Exception e) {
+ if (args.isVerboseOutput()) {
+ getLogger().error("Unable to access DataSealer from Spring context", e);
+ } else {
+ getLogger().error("Unable to access DataSealer from Spring context", e.getMessage());
+ }
+ return RC_UNKNOWN;
+ }
+
+ return RC_OK;
+ }
+
+ /**
+ * CLI entry point.
+ *
+ * @param args arguments
+ */
+ public static void main(@Nonnull final String[] args) {
+ System.exit(new DataSealerCLI().run(args));
+ }
+
+}
\ No newline at end of file
diff --git a/idp-distribution/src/main/resources/bin/sealer.bat b/idp-distribution/src/main/resources/bin/sealer.bat
new file mode 100644
index 000000000..0cd3f7970
--- /dev/null
+++ b/idp-distribution/src/main/resources/bin/sealer.bat
@@ -0,0 +1,4 @@
+ at echo off
+setlocal
+
+"%~dp0\runclass.bat" net.shibboleth.idp.cli.DataSealerCLI %*
diff --git a/idp-distribution/src/main/resources/bin/sealer.sh b/idp-distribution/src/main/resources/bin/sealer.sh
new file mode 100644
index 000000000..1f09ed04d
--- /dev/null
+++ b/idp-distribution/src/main/resources/bin/sealer.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+declare LOCATION
+
+LOCATION=$(dirname $0)
+
+$LOCATION/runclass.sh net.shibboleth.idp.cli.DataSealerCLI "$@"
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list