From 95cac2658c4aa94aa744e77379bed0dad00cbff9 Mon Sep 17 00:00:00 2001 From: madness-inc Date: Tue, 13 Aug 2019 11:42:10 +0200 Subject: [PATCH] AUTH-17 utility class for generating digest URLs --- .../digest/Digestgenerator.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/test/java/org/appng/application/authentication/digest/Digestgenerator.java diff --git a/src/test/java/org/appng/application/authentication/digest/Digestgenerator.java b/src/test/java/org/appng/application/authentication/digest/Digestgenerator.java new file mode 100644 index 0000000..af97915 --- /dev/null +++ b/src/test/java/org/appng/application/authentication/digest/Digestgenerator.java @@ -0,0 +1,39 @@ +/* + * Copyright 2011-2019 the original author or authors. + * + * Licensed 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 org.appng.application.authentication.digest; + +import java.awt.Desktop; +import java.net.URI; +import java.net.URLEncoder; + +import org.appng.core.security.DigestUtil; + +public class Digestgenerator { + + public static void main(String[] args) throws Exception { + String user = "admin"; + String sharedSecret = "thisisreallysecret"; + String digest = URLEncoder.encode(DigestUtil.getDigest(user, sharedSecret), "UTF-8"); + String domain = "http://localhost:8080"; + String site = "manager"; + String forwardTo = String.format("/manager/%s/appng-manager/sites", site); + String uri = String.format("%s/manager/%s/appng-authentication/digestlogin?digest=%s&forward=%s", domain, site, + digest, forwardTo); + System.err.println(uri); + Desktop.getDesktop().browse(new URI(uri)); + } + +}