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

[WIP] Add a new rest api (v2) and web UI #296

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
public interface AliasedCertificateFactory extends CertificateFactory {
X509Certificate getCertificate(String alias) throws OpenAS2Exception;

boolean hasPrivateKey(String alias) throws OpenAS2Exception;

Map<String, X509Certificate> getCertificates() throws OpenAS2Exception;

void addCertificate(String alias, X509Certificate cert, boolean overwrite) throws OpenAS2Exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ public X509Certificate getCertificate(String alias) throws OpenAS2Exception {
}
}

public boolean hasPrivateKey(String alias) throws OpenAS2Exception {
try{
return getKeyStore().isKeyEntry(alias);
} catch (GeneralSecurityException gse) {
throw new WrappedException(gse);
}
}

public Map<String, X509Certificate> getCertificates() throws OpenAS2Exception {
KeyStore ks = getKeyStore();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ScheduledExecutorService;
import java.util.logging.Level;
import java.util.logging.Logger;


public abstract class BaseCommandProcessor implements CommandProcessor, Component, HasSchedule {
Expand Down Expand Up @@ -89,7 +91,11 @@ public void schedule(ScheduledExecutorService executor) throws OpenAS2Exception
@Override
public Void call() throws Exception {
while (running) {
processCommand();
try {
processCommand();
} catch (Exception ex) {
Logger.getLogger(BaseCommandProcessor.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
}
}
return VOID;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
import org.openas2.cmd.Command;
import org.openas2.cmd.CommandResult;
import org.openas2.cmd.processor.restapi.ApiResource;
import org.openas2.cmd.processor.restapi.ApiV2Resource;
import org.openas2.cmd.processor.restapi.AuthenticationRequestFilter;
import org.openas2.cmd.processor.restapi.LoggerRequestFilter;
import org.openas2.partner.XMLPartnershipFactory;

import java.io.IOException;
import java.net.URI;
Expand Down Expand Up @@ -96,12 +98,13 @@ public void init(Session session, Map<String, String> parameters) throws OpenAS2
final String userId = parameters.getOrDefault("userid", "admin");
final String password = parameters.getOrDefault("password", "admin");
ApiResource.setProcessor(this);
ApiV2Resource.setSession(session);
LoggerRequestFilter.setLogger(logger);
AuthenticationRequestFilter.setCredentials(userId, password);
// Now needed to define packages in Jersey 3.0
final ResourceConfig rc = new ResourceConfig();
rc.packages("org.openas2.cmd.processor.restapi");
rc.packages("org.glassfish.jersey.jackson");
// rc.packages("org.glassfish.jersey.jackson");
rc.register(SecurityEntityFilteringFeature.class);
rc.register(EntityFilteringFeature.class);
rc.register(RolesAllowedDynamicFeature.class);
Expand Down
Loading