mirror of https://github.com/apache/maven.git
[MNG-8411][MNG-8412][MNG-8416] mvnenc fixes (#1959)
Cumulative mvnenc fixes: * make the 3 goals (sans init) work in batch mode * move the Maven DI SecDispatcher provider to test scope in maven-impl (duplicates components in Maven) * update to SecDisparcher 4.0.3 (contains fix for MNG-8416 and one other bug) --- https://issues.apache.org/jira/browse/MNG-8411 https://issues.apache.org/jira/browse/MNG-8412 https://issues.apache.org/jira/browse/MNG-8416
This commit is contained in:
parent
8706dd7edf
commit
6cb4482a98
|
@ -65,18 +65,6 @@ public class EncryptInvoker extends LookupInvoker<EncryptContext> {
|
|||
|
||||
protected int doExecute(EncryptContext context) throws Exception {
|
||||
try {
|
||||
if (!context.interactive) {
|
||||
context.terminal.writer().println("This tool works only in interactive mode!");
|
||||
context.terminal
|
||||
.writer()
|
||||
.println("Tool purpose is to configure password management on developer workstations.");
|
||||
context.terminal
|
||||
.writer()
|
||||
.println(
|
||||
"Note: Generated configuration can be moved/copied to headless environments, if configured as such.");
|
||||
return BAD_OPERATION;
|
||||
}
|
||||
|
||||
context.header = new ArrayList<>();
|
||||
context.style = new AttributedStyle();
|
||||
context.addInHeader(
|
||||
|
@ -89,12 +77,7 @@ public class EncryptInvoker extends LookupInvoker<EncryptContext> {
|
|||
Thread executeThread = Thread.currentThread();
|
||||
context.terminal.handle(Terminal.Signal.INT, signal -> executeThread.interrupt());
|
||||
ConsolePrompt.UiConfig config;
|
||||
if (context.terminal.getType().equals(Terminal.TYPE_DUMB)
|
||||
|| context.terminal.getType().equals(Terminal.TYPE_DUMB_COLOR)) {
|
||||
context.terminal.writer().println(context.terminal.getName() + ": " + context.terminal.getType());
|
||||
throw new IllegalStateException("Dumb terminal detected.\nThis tool requires real terminal to work!\n"
|
||||
+ "Note: On Windows Jansi or JNA library must be included in classpath.");
|
||||
} else if (OSUtils.IS_WINDOWS) {
|
||||
if (OSUtils.IS_WINDOWS) {
|
||||
config = new ConsolePrompt.UiConfig(">", "( )", "(x)", "( )");
|
||||
} else {
|
||||
config = new ConsolePrompt.UiConfig("❯", "◯ ", "◉ ", "◯ ");
|
||||
|
|
|
@ -54,7 +54,7 @@ import static org.apache.maven.cling.invoker.mvnenc.EncryptInvoker.OK;
|
|||
*/
|
||||
@Singleton
|
||||
@Named("init")
|
||||
public class Init extends GoalSupport {
|
||||
public class Init extends InteractiveGoalSupport {
|
||||
private static final String NONE = "__none__";
|
||||
|
||||
@Inject
|
||||
|
@ -63,7 +63,7 @@ public class Init extends GoalSupport {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int execute(EncryptContext context) throws Exception {
|
||||
public int doExecute(EncryptContext context) throws Exception {
|
||||
context.addInHeader(context.style.italic().bold().foreground(Colors.rgbColor("yellow")), "goal: init");
|
||||
context.addInHeader("");
|
||||
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF 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 org.apache.maven.cling.invoker.mvnenc.goals;
|
||||
|
||||
import org.apache.maven.api.services.MessageBuilderFactory;
|
||||
import org.apache.maven.cling.invoker.mvnenc.EncryptContext;
|
||||
import org.apache.maven.cling.invoker.mvnenc.EncryptInvoker;
|
||||
import org.codehaus.plexus.components.secdispatcher.SecDispatcher;
|
||||
|
||||
/**
|
||||
* The support class for interactive goal implementations.
|
||||
*/
|
||||
public abstract class InteractiveGoalSupport extends GoalSupport {
|
||||
protected InteractiveGoalSupport(MessageBuilderFactory messageBuilderFactory, SecDispatcher secDispatcher) {
|
||||
super(messageBuilderFactory, secDispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute(EncryptContext context) throws Exception {
|
||||
if (!context.interactive) {
|
||||
context.terminal.writer().println("This tool works only in interactive mode!");
|
||||
context.terminal
|
||||
.writer()
|
||||
.println("Tool purpose is to configure password management on developer workstations.");
|
||||
context.terminal
|
||||
.writer()
|
||||
.println(
|
||||
"Note: Generated configuration can be moved/copied to headless environments, if configured as such.");
|
||||
return EncryptInvoker.BAD_OPERATION;
|
||||
}
|
||||
|
||||
return doExecute(context);
|
||||
}
|
||||
|
||||
protected abstract int doExecute(EncryptContext context) throws Exception;
|
||||
}
|
|
@ -274,7 +274,7 @@ public class DefaultSettingsBuilder implements SettingsBuilder {
|
|||
}
|
||||
SecDispatcher secDispatcher = new DefaultSecDispatcher(dispatchers, getSecuritySettings(request.getSession()));
|
||||
Function<String, String> decryptFunction = str -> {
|
||||
if (secDispatcher.isAnyEncryptedString(str)) {
|
||||
if (str != null && !str.isEmpty() && !str.contains("${") && secDispatcher.isAnyEncryptedString(str)) {
|
||||
if (secDispatcher.isLegacyEncryptedString(str)) {
|
||||
// add a problem
|
||||
problems.add(new DefaultBuilderProblem(
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -163,7 +163,7 @@ under the License.
|
|||
<plexusTestingVersion>1.4.0</plexusTestingVersion>
|
||||
<plexusXmlVersion>4.0.4</plexusXmlVersion>
|
||||
<resolverVersion>2.0.4</resolverVersion>
|
||||
<securityDispatcherVersion>4.0.2</securityDispatcherVersion>
|
||||
<securityDispatcherVersion>4.0.3</securityDispatcherVersion>
|
||||
<sisuVersion>0.9.0.M3</sisuVersion>
|
||||
<slf4jVersion>2.0.16</slf4jVersion>
|
||||
<stax2ApiVersion>4.2.2</stax2ApiVersion>
|
||||
|
|
Loading…
Reference in New Issue