Skip to content

Commit

Permalink
Fixes #714 - delay secure storage prompts
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Stryker <[email protected]>
  • Loading branch information
robstryker committed Nov 6, 2023
1 parent 544b7e9 commit c004268
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
package org.jboss.tools.rsp.server.spi.servertype;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

Expand All @@ -30,6 +32,7 @@
import org.jboss.tools.rsp.eclipse.core.runtime.IStatus;
import org.jboss.tools.rsp.eclipse.core.runtime.Status;
import org.jboss.tools.rsp.server.spi.SPIActivator;
import org.jboss.tools.rsp.server.spi.model.IServerModel;
import org.jboss.tools.rsp.server.spi.util.StatusConverter;

public abstract class AbstractServerType implements IServerType {
Expand Down Expand Up @@ -188,6 +191,19 @@ protected WorkflowResponse handleInitialCreateServerWorkflow(CreateServerWorkflo
return workflow;
}

public boolean hasSecureAttributes() {
Attributes a = getRequiredAttributes();
Attributes b = getOptionalAttributes();
Set<String> all = new HashSet<>();
all.addAll(a.getAttributes().keySet());
all.addAll(b.getAttributes().keySet());
for( Iterator<String> i = all.iterator(); i.hasNext(); ) {
if( i.next().startsWith(IServerModel.SECURE_ATTRIBUTE_PREFIX))
return true;
}
return false;
}

public ServerLaunchMode[] getLaunchModes() {
return new ServerLaunchMode[] {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public interface IServerType {
public IServerDelegate createServerDelegate(IServer server);
public Attributes getRequiredAttributes();
public Attributes getOptionalAttributes();
public boolean hasSecureAttributes();
public Attributes getRequiredLaunchAttributes();
public Attributes getOptionalLaunchAttributes();
public ServerLaunchMode[] getLaunchModes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,16 +575,7 @@ public ServerType[] getAccessibleServerTypes() {

@Override
public boolean hasSecureAttributes(IServerType type) {
Attributes a = type.getRequiredAttributes();
Attributes b = type.getOptionalAttributes();
Set<String> all = new HashSet<>();
all.addAll(a.getAttributes().keySet());
all.addAll(b.getAttributes().keySet());
for( Iterator<String> i = all.iterator(); i.hasNext(); ) {
if( i.next().startsWith(IServerModel.SECURE_ATTRIBUTE_PREFIX))
return true;
}
return false;
return type.hasSecureAttributes();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,5 +313,10 @@ public WorkflowResponse createServerWorkflow(RSPServer server, CreateServerWorkf
return null;
}

@Override
public boolean hasSecureAttributes() {
return false;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public class CDKServerType extends BaseMinishiftServerType {
public CDKServerType(String id, String name, String desc) {
super(id, name, desc);
}

public boolean hasSecureAttributes() {
return true;
}

private IServerManagementModel getServerManagementModel() {
if( LauncherSingleton.getDefault() == null )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public IServerDelegate createServerDelegate(IServer server) {
return new CRCServerDelegate(server);
}

public boolean hasSecureAttributes() {
return true;
}

@Override
protected void fillRequiredAttributes(CreateServerAttributesUtility attrs) {
attrs.addAttribute(IMinishiftServerAttributes.MINISHIFT_BINARY,
Expand Down

0 comments on commit c004268

Please sign in to comment.