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

Upgrade Felix, OSGi and JRE. #56 #79

Merged
merged 2 commits into from
Dec 8, 2020
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,6 @@ node_modules

# ctags index
tags

# TestNG
*/test-output
4 changes: 1 addition & 3 deletions custom-scripted-connector-bundler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright (c) 2015 ForgeRock AS. All rights reserved.
Portions Copyright 2017-2018 Wren Security.
Portions Copyright 2017-2020 Wren Security.
The contents of this file are subject to the terms
of the Common Development and Distribution License
Expand Down Expand Up @@ -34,7 +34,6 @@

<groupId>org.forgerock.openidm.tools</groupId>
<artifactId>custom-scripted-connector-bundler</artifactId>
<version>6.0.0-SNAPSHOT</version>

<name>Wren:IDM - Custom Groovy Connector Bundler</name>
<description>
Expand Down Expand Up @@ -102,7 +101,6 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2015 ForgeRock AS. All Rights Reserved
* Portions Copyright 2020 Wren Security
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
Expand All @@ -24,18 +25,19 @@

package org.forgerock.openidm.tools.scriptedbundler;

import org.apache.commons.cli.BasicParser;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.ParseException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
* This is the main class for this project. It accepts a JSON configuration file and attempts to generate a set of
Expand Down Expand Up @@ -69,7 +71,7 @@ public static void main(String[] args) {
.append(ScriptedBundler.class.getPackage().getImplementationVersion());
System.out.println(str);

CommandLineParser parser = new BasicParser();
CommandLineParser parser = new DefaultParser();
CommandLine cmdline = null;
try {
cmdline = parser.parse(options, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2015 ForgeRock AS. All Rights Reserved
* Portions Copyright 2020 Wren Security
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
Expand Down Expand Up @@ -35,6 +36,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -125,7 +127,7 @@ public CharSequence apply(String context, Options options) throws IOException {
hbtemplate = hb.compileInline(out.toString());
String contents = hbtemplate.apply(config);

FileUtils.write(new File(outputPath + outputFilename), contents);
FileUtils.write(new File(outputPath + outputFilename), contents, StandardCharsets.UTF_8);
} catch (Exception e) {
throw new IOException("Failed to read contents of " + template.getInputName(), e);
}
Expand Down Expand Up @@ -162,7 +164,7 @@ public CharSequence apply(String context, Options options) throws IOException {
}
contents += out.toString();

FileUtils.write(new File(outputPath + outputFilename), contents);
FileUtils.write(new File(outputPath + outputFilename), contents, StandardCharsets.UTF_8);
} catch (IOException e) {
throw new IOException("Failed to read contents of " + uiTemplate.getInputName(), e);
}
Expand Down
23 changes: 1 addition & 22 deletions openidm-api-servlet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
~ information: "Portions copyright [year] [name of copyright owner]".
~
~ Copyright 2013-2016 ForgeRock AS.
~ Portions Copyright 2017-2018 Wren Security.
~ Portions Copyright 2017-2020 Wren Security.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -108,12 +108,6 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
<scope>provided</scope>
</dependency>

<!-- Test Dependencies -->
<dependency>
<groupId>org.testng</groupId>
Expand Down Expand Up @@ -175,21 +169,6 @@
</pluginManagement>

<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>

<executions>
<execution>
<id>generate-scr-scrdescriptor</id>

<goals>
<goal>scr</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,41 @@
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2016 ForgeRock AS.
* Portions Copyright 2020 Wren Security
*/

package org.forgerock.openidm.servlet.internal;

import java.io.IOException;
import java.util.Dictionary;
import java.util.Hashtable;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.Dictionary;
import java.util.Hashtable;

import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.ConfigurationPolicy;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
import org.forgerock.openidm.jetty.JettyErrorHandler;
import org.forgerock.openidm.servletregistration.ServletRegistration;
import org.ops4j.pax.web.service.WebContainer;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ConfigurationPolicy;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.http.NamespaceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* A component to create and register a Jetty error-handler servlet.
*/
@Component(name = ErrorServletComponent.PID, policy = ConfigurationPolicy.IGNORE, immediate = true)
@Component(
name = ErrorServletComponent.PID,
configurationPolicy = ConfigurationPolicy.IGNORE,
immediate = true)
public class ErrorServletComponent {

static final String PID = "org.forgerock.openidm.error-servlet";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,24 @@
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2013-2016 ForgeRock AS.
* Portions Copyright 2020 Wren Security
*/
package org.forgerock.openidm.servlet.internal;

import static org.forgerock.openidm.servletregistration.ServletRegistration.SERVLET_FILTER_AUGMENT_SECURITY_CONTEXT;
import static org.forgerock.openidm.servletregistration.ServletRegistration.SERVLET_FILTER_SCRIPT_EXTENSIONS;

import java.util.Dictionary;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;

import javax.script.ScriptException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import io.swagger.models.Info;
import io.swagger.models.Swagger;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.ConfigurationPolicy;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.ReferenceStrategy;
import org.apache.felix.scr.annotations.Service;
import org.forgerock.http.ApiProducer;
import org.forgerock.http.DescribedHttpApplication;
import org.forgerock.http.Filter;
Expand All @@ -63,13 +52,25 @@
import org.forgerock.util.Factory;
import org.osgi.framework.Constants;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ConfigurationPolicy;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
import org.osgi.service.component.propertytypes.ServiceDescription;
import org.osgi.service.component.propertytypes.ServiceVendor;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventConstants;
import org.osgi.service.event.EventHandler;
import org.osgi.service.event.propertytypes.EventTopics;
import org.osgi.service.http.NamespaceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.swagger.models.Info;
import io.swagger.models.Swagger;

/**
* A component to create and register the "API" Servlet; that is, the CHF Servlet that
*
Expand All @@ -80,13 +81,14 @@
* i) converts CHF Requests to CREST requests, and
* ii) routes them on the CREST router using the external ConnectionFactory.
*/
@Component(name = ServletComponent.PID, policy = ConfigurationPolicy.IGNORE, immediate = true)
@Service
@Properties({
@Property(name = Constants.SERVICE_VENDOR, value = ServerConstants.SERVER_VENDOR_NAME),
@Property(name = Constants.SERVICE_DESCRIPTION, value = "OpenIDM Common REST HttpServlet"),
@Property(name = EventConstants.EVENT_TOPIC, value = { "org/forgerock/openidm/servlet/*" })
})
@Component(
name = ServletComponent.PID,
configurationPolicy = ConfigurationPolicy.IGNORE,
immediate = true,
property = Constants.SERVICE_PID + "=" + ServletComponent.PID)
@ServiceVendor(ServerConstants.SERVER_VENDOR_NAME)
@ServiceDescription("OpenIDM Common REST HttpServlet")
@EventTopics("org/forgerock/openidm/servlet/*")
public class ServletComponent implements EventHandler {

static final String PID = "org.forgerock.openidm.api-servlet";
Expand Down Expand Up @@ -118,17 +120,15 @@ public class ServletComponent implements EventHandler {
private List<ScriptEntry> augmentSecurityScripts = new CopyOnWriteArrayList<>();

// Register script extensions configured
private Map<ServletFilterRegistrator, ScriptEntry> filterRegistratorMap = new ConcurrentHashMap<>();

@Reference(
name = "reference_Servlet_ServletFilterRegistrator",
referenceInterface = ServletFilterRegistrator.class,
bind = "bindRegistrator",
service = ServletFilterRegistrator.class,
unbind = "unbindRegistrator",
cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
policy = ReferencePolicy.DYNAMIC,
strategy = ReferenceStrategy.EVENT
cardinality = ReferenceCardinality.MULTIPLE,
policy = ReferencePolicy.DYNAMIC
)
private Map<ServletFilterRegistrator, ScriptEntry> filterRegistratorMap = new HashMap<>();

protected synchronized void bindRegistrator(ServletFilterRegistrator registrator, Map<String, Object> properties) {
JsonValue scriptConfig = registrator.getConfiguration()
.get(SERVLET_FILTER_SCRIPT_EXTENSIONS)
Expand Down
Loading