Skip to content
Merged
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
2 changes: 1 addition & 1 deletion OpenICF-java-framework/connector-server-jetty/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<!-- maven-compiler-plugin -->
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
<jetty.version>9.2.24.v20180105</jetty.version>
<jetty.version>9.4.51.v20230217</jetty.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,20 @@

package org.forgerock.openicf.framework.server.jetty;

import org.eclipse.jetty.websocket.common.SessionListener;
import org.eclipse.jetty.websocket.common.WebSocketSessionFactory;
import org.eclipse.jetty.websocket.common.events.EventDriver;
import org.eclipse.jetty.websocket.common.events.JettyAnnotatedEventDriver;
import org.eclipse.jetty.websocket.common.events.JettyListenerEventDriver;
import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;

public class OpenICFWebSocketSessionFactory extends WebSocketSessionFactory {
public OpenICFWebSocketSessionFactory(WebSocketContainerScope containerScope) {
super(containerScope);
}

public OpenICFWebSocketSessionFactory(SessionListener... sessionListeners) {
/*public OpenICFWebSocketSessionFactory(SessionListener... sessionListeners) {
super(sessionListeners);
}
}*/

@Override
public boolean supports(final EventDriver websocket) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void sendPong(byte[] applicationData) throws Exception {
}

protected void tryClose() {
WebSocketListenerBridge.this.terminateConnection(StatusCode.NORMAL, "TEST003");
WebSocketListenerBridge.this.session.close(StatusCode.NORMAL, "TEST003");
}

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
import java.util.concurrent.TimeUnit;

import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.MappedLoginService;
import org.eclipse.jetty.security.SecurityHandler;
import org.eclipse.jetty.security.*;
import org.eclipse.jetty.security.authentication.BasicAuthenticator;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConfiguration;
Expand All @@ -41,6 +38,7 @@
import org.eclipse.jetty.servlet.BaseHolder;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.servlet.Source;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Credential;
import org.eclipse.jetty.util.ssl.SslContextFactory;
Expand Down Expand Up @@ -114,23 +112,15 @@ private SecurityHandler getSecurityHandler() throws IOException {
sh.setAuthenticator(new BasicAuthenticator());
sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[] { cm }));

MappedLoginService loginService = new MappedLoginService() {

@Override
protected UserIdentity loadUser(String username) {
return null;
}

@Override
protected void loadUsers() throws IOException {
Credential credential = Credential.getCredential(DEFAULT_PASSWORD);
String[] roles = new String[] { "websocket" };
putUser("plain", credential, roles);
putUser("secure", credential, roles);
putUser("proxy", credential, roles);
putUser("anonymous", credential, roles);
}
};
HashLoginService loginService = new HashLoginService();
UserStore us=new UserStore();
String[] roles = new String[] { "websocket" };
Credential credential = Credential.getCredential(DEFAULT_PASSWORD);
us.addUser("plain", credential, roles);
us.addUser("secure", credential, roles);
us.addUser("proxy", credential, roles);
us.addUser("anonymous", credential, roles);
loginService.setUserStore(us);
loginService.setName("OpenICF-Service");
sh.setLoginService(loginService);
sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[] { cm }));
Expand Down Expand Up @@ -191,7 +181,7 @@ protected void setupTest(ITestContext context) throws Exception {
| ServletContextHandler.SECURITY);

ServletHolder holder =
handler.getServletHandler().newServletHolder(BaseHolder.Source.EMBEDDED);
handler.getServletHandler().newServletHolder(Source.EMBEDDED);

serverConnectorFramework = serverConnectorFrameworkFactory.acquire();
localConnectorFramework = localConnectorFrameworkFactory.acquire();
Expand Down Expand Up @@ -250,16 +240,12 @@ private SslContextFactory createSsllContextFactory(boolean clientContext) {
"truststore.jks");
Assert.assertNotNull(truststoreURL);
String truststoreFile = null;
try {
truststoreFile = URLDecoder.decode(truststoreURL.getFile(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
truststoreFile = truststoreURL.getFile();//URLDecoder.decode(truststoreURL.getFile(), "UTF-8");

sslContextFactory.setTrustStorePath(truststoreFile);
sslContextFactory.setTrustStorePath("file://"+truststoreFile);
sslContextFactory.setTrustStorePassword(JSK_PASSWORD);

sslContextFactory.setKeyStorePath(serverKeystoreFile);
sslContextFactory.setKeyStorePath("file://"+serverKeystoreFile);
sslContextFactory.setKeyStorePassword(JSK_PASSWORD);

sslContextFactory.setIncludeProtocols("TLSv1.2", "TLSv1.1", "TLSv1");
Expand Down