Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow runCmds to change user. #1772

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Reenabled sec dispatcher code.
Signed-off-by: Jens Andersen <jega@dbc.dk>
  • Loading branch information
JensGroenborgAndersen committed Jun 4, 2024
commit 7d89991b7d85d07f2857c78f671b7575fb15e959
25 changes: 12 additions & 13 deletions src/main/java/io/fabric8/maven/docker/util/AuthConfigFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -663,19 +663,18 @@ private Server checkForServer(Server server, String id, String registry, String
}

private String decrypt(String password) throws MojoExecutionException {
// try {
// // Done by reflection since I have classloader issues otherwise
// Object secDispatcher = container.lookup(SecDispatcher.ROLE, "maven");
// Method method = secDispatcher.getClass().getMethod("decrypt",String.class);
// synchronized(secDispatcher) {
// return (String) method.invoke(secDispatcher, password);
// }
// } catch (ComponentLookupException e) {
// throw new MojoExecutionException("Error looking security dispatcher",e);
// } catch (ReflectiveOperationException e) {
// throw new MojoExecutionException("Cannot decrypt password: " + e.getCause(),e);
// }
return password;
try {
// Done by reflection since I have classloader issues otherwise
Object secDispatcher = container.lookup(SecDispatcher.ROLE, "maven");
Method method = secDispatcher.getClass().getMethod("decrypt",String.class);
synchronized(secDispatcher) {
return (String) method.invoke(secDispatcher, password);
}
} catch (ComponentLookupException e) {
throw new MojoExecutionException("Error looking security dispatcher",e);
} catch (ReflectiveOperationException e) {
throw new MojoExecutionException("Cannot decrypt password: " + e.getCause(),e);
}
}

private AuthConfig createAuthConfigFromServer(Server server) throws MojoExecutionException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public String decrypt(String password) {

@BeforeEach
void containerSetup() throws ComponentLookupException, SecDispatcherException {
// Mockito.lenient().when(container.lookup(SecDispatcher.ROLE, "maven")).thenReturn(secDispatcher);
Mockito.lenient().when(container.lookup(SecDispatcher.ROLE, "maven")).thenReturn(secDispatcher);
Mockito.lenient().when(secDispatcher.decrypt(Mockito.anyString())).thenAnswer(invocation -> invocation.getArguments()[0]);

factory = new AuthConfigFactory(container);
Expand Down
Loading