[java-idp-oidc] branch main updated: Basic-auth support refactored into core.
Scott Cantor
cantor.2 at osu.edu
Fri Mar 18 13:17:05 UTC 2022
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-idp-oidc.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-oidc.git;a=commit;h=f7fc7a1f784ca25db42096f8dca580c0d342cbab
The following commit(s) were added to refs/heads/main by this push:
new f7fc7a1f Basic-auth support refactored into core.
f7fc7a1f is described below
commit f7fc7a1f784ca25db42096f8dca580c0d342cbab
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Mar 18 09:17:03 2022 -0400
Basic-auth support refactored into core.
---
.../cli/IssueRegistrationAccessTokenArguments.java | 26 +----
.../op/cli/IssueRegistrationAccessTokenCLI.java | 114 ---------------------
.../idp/plugin/oidc/op/bin/issue-access-token.sh | 5 +-
3 files changed, 4 insertions(+), 141 deletions(-)
diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/cli/IssueRegistrationAccessTokenArguments.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/cli/IssueRegistrationAccessTokenArguments.java
index 63c7d81d..94a6ade9 100644
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/cli/IssueRegistrationAccessTokenArguments.java
+++ b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/cli/IssueRegistrationAccessTokenArguments.java
@@ -19,8 +19,6 @@ package net.shibboleth.idp.plugin.oidc.op.cli;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
-import java.util.Base64;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -28,7 +26,6 @@ import javax.annotation.Nullable;
import com.beust.jcommander.Parameter;
import net.shibboleth.idp.cli.AbstractCommandLineArguments;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
/** Command line processing for issue-registration-access-token flow. */
public class IssueRegistrationAccessTokenArguments extends AbstractCommandLineArguments {
@@ -68,15 +65,6 @@ public class IssueRegistrationAccessTokenArguments extends AbstractCommandLineAr
@Parameter(names = {"-r", "--replacement"}, required = false,
description = "Flag to request the ability to re-register the same client ID for the life of the token")
@Nullable private boolean replacement;
-
- /** Username to be used in the HTTP-Basic authentication. */
- @Parameter(names = {"-u", "--username"}, required = false, description = "Username to be used in HTTP-Basic Auth")
- @Nullable private String username;
-
- /** Password to be used in the HTTP-Basic authentication. */
- @Parameter(names = {"-p", "--password"}, required = false, password = true,
- description = "Password to be used in HTTP-Basic Auth")
- @Nullable private String password;
/** {@inheritDoc} */
@Override
@@ -150,16 +138,4 @@ public class IssueRegistrationAccessTokenArguments extends AbstractCommandLineAr
return builder;
}
- /**
- * Builds the HTTP-Basic value to be used in the Authorization -header, containing username and password.
- *
- * @return The value to be used in the Authorization -header, or null if username or password didn't have a value.
- */
- public String getBasicAuthHeader() {
- if (StringSupport.trimOrNull(username) == null || StringSupport.trimOrNull(password) == null) {
- return null;
- }
- final String rawHeader = username + ":" + password;
- return "Basic " + Base64.getEncoder().encodeToString(rawHeader.getBytes(StandardCharsets.UTF_8));
- }
-}
+}
\ No newline at end of file
diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/cli/IssueRegistrationAccessTokenCLI.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/cli/IssueRegistrationAccessTokenCLI.java
deleted file mode 100644
index a2bf9213..00000000
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/cli/IssueRegistrationAccessTokenCLI.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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.plugin.oidc.op.cli;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import javax.annotation.Nonnull;
-
-import com.beust.jcommander.JCommander;
-
-/**
- * Entry point for command line tool interacting with the registration access token issuance flow.
- *
- * Based on <pre>net.shibboleth.idp.cli.CLI</pre>, adding a feature to inject authorization-header for HTTP-Basic auth.
- */
-public final class IssueRegistrationAccessTokenCLI {
-
- /** Constructor. */
- private IssueRegistrationAccessTokenCLI() {
-
- }
-
- /**
- * Command line entry point.
- *
- * @param args command line arguments
- * @throws SecurityException from the object construction
- * @throws ReflectiveOperationException from the object construction
- * @throws IllegalArgumentException from the object construction
- */
- public static void main(@Nonnull final String[] args) throws ReflectiveOperationException,
- SecurityException, IllegalArgumentException {
-
- final IssueRegistrationAccessTokenArguments arguments = new IssueRegistrationAccessTokenArguments();
-
- final JCommander jc = new JCommander(arguments);
- jc.parse(args);
- if (arguments.isUsage()) {
- jc.usage();
- return;
- }
- try {
- arguments.validate();
- } catch (final IllegalArgumentException e) {
- errorAndExit(e.getMessage());
- }
-
- doRequest(arguments);
- }
-
- /**
- * Make a request using the arguments established.
- *
- * @param args the populated command line arguments
- */
- private static void doRequest(@Nonnull final IssueRegistrationAccessTokenArguments args) {
- URL url = null;
- try {
- url = args.buildURL();
- final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- final String authorization = args.getBasicAuthHeader();
- if (authorization != null) {
- System.out.println("Using HTTP-Basic authentication");
- connection.setRequestProperty("Authorization", authorization);
- }
- try (final InputStream stream = connection.getInputStream()) {
- try (final InputStreamReader reader = new InputStreamReader(stream)) {
- try (final BufferedReader in = new BufferedReader(reader)) {
- String line;
- while((line = in.readLine()) != null) {
- System.out.println(line);
- }
- }
- }
- }
- } catch (final MalformedURLException e) {
- errorAndExit(e.getMessage());
- } catch (final IOException e) {
- errorAndExit((url != null ? "(" + url.toString() + ") " : "") + e.getMessage());
- }
- }
-
- /**
- * Logs, as an error, the error message and exits the program.
- *
- * @param errorMessage error message
- */
- private static void errorAndExit(@Nonnull final String errorMessage) {
- System.err.println(errorMessage);
- System.exit(1);
- }
-
-}
\ No newline at end of file
diff --git a/idp-oidc-extension-impl/src/main/resources/net/shibboleth/idp/plugin/oidc/op/bin/issue-access-token.sh b/idp-oidc-extension-impl/src/main/resources/net/shibboleth/idp/plugin/oidc/op/bin/issue-access-token.sh
index ac97a617..2419aabd 100644
--- a/idp-oidc-extension-impl/src/main/resources/net/shibboleth/idp/plugin/oidc/op/bin/issue-access-token.sh
+++ b/idp-oidc-extension-impl/src/main/resources/net/shibboleth/idp/plugin/oidc/op/bin/issue-access-token.sh
@@ -4,5 +4,6 @@ declare LOCATION
LOCATION=$(dirname $0)
-$LOCATION/runclass.sh -Dnet.shibboleth.idp.cli.arguments=net.shibboleth.idp.plugin.oidc.op.cli.IssueRegistrationAccessTokenArguments \
- net.shibboleth.idp.plugin.oidc.op.cli.IssueRegistrationAccessTokenCLI "$@"
+$LOCATION/runclass.sh \
+ -Dnet.shibboleth.idp.cli.arguments=net.shibboleth.idp.plugin.oidc.op.cli.IssueRegistrationAccessTokenArguments \
+ net.shibboleth.idp.cli.CLI "$@"
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list