Repository: nifi-registry Updated Branches: refs/heads/master 70d81f94a -> d6d42d998
http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/nifi-registry-security/pom.xml ---------------------------------------------------------------------- diff --git a/nifi-registry-security/pom.xml b/nifi-registry-security/pom.xml new file mode 100644 index 0000000..d7711e9 --- /dev/null +++ b/nifi-registry-security/pom.xml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<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> + <parent> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry</artifactId> + <version>0.0.1-SNAPSHOT</version> + </parent> + <artifactId>nifi-registry-security</artifactId> + <packaging>jar</packaging> + <build> + <resources> + <resource> + <directory>src/main/xsd</directory> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>jaxb2-maven-plugin</artifactId> + <executions> + <execution> + <id>xjc</id> + <goals> + <goal>xjc</goal> + </goals> + <configuration> + <packageName>org.apache.nifi.registry.user.generated</packageName> + </configuration> + </execution> + </executions> + <configuration> + <outputDirectory>${project.build.directory}/generated-sources/jaxb</outputDirectory> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <configuration> + <excludes>**/user/generated/*.java</excludes> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry-properties</artifactId> + <version>0.0.1-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + </dependency> + </dependencies> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/nifi-registry-security/src/main/java/org/apache/nifi/registry/security/AuthorizationProvider.java ---------------------------------------------------------------------- diff --git a/nifi-registry-security/src/main/java/org/apache/nifi/registry/security/AuthorizationProvider.java b/nifi-registry-security/src/main/java/org/apache/nifi/registry/security/AuthorizationProvider.java new file mode 100644 index 0000000..89be63e --- /dev/null +++ b/nifi-registry-security/src/main/java/org/apache/nifi/registry/security/AuthorizationProvider.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.registry.security; + +import org.apache.nifi.registry.properties.NiFiRegistryProperties; +import org.apache.nifi.registry.user.generated.User; +import org.apache.nifi.registry.user.generated.Users; +import org.xml.sax.SAXException; + +import javax.xml.XMLConstants; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class AuthorizationProvider { + + private static final String USERS_XSD = "/users.xsd"; + private static final String JAXB_GENERATED_PATH = "org.apache.nifi.registry.user.generated"; + private static final JAXBContext JAXB_CONTEXT = initializeJaxbContext(); + + /** + * Load the JAXBContext. + */ + private static JAXBContext initializeJaxbContext() { + try { + return JAXBContext.newInstance(JAXB_GENERATED_PATH, AuthorizationProvider.class.getClassLoader()); + } catch (JAXBException e) { + throw new RuntimeException("Unable to create JAXBContext."); + } + } + + private final List<String> authorizedUsers; + + public AuthorizationProvider(final NiFiRegistryProperties properties) { + final File usersFile = properties.getAuthorizedUsersFile(); + final List<String> userList = new ArrayList<>(); + + // load the users from the specified file + if (usersFile != null && usersFile.exists()) { + try { + // find the schema + final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + final Schema schema = schemaFactory.newSchema(AuthorizationProvider.class.getResource(USERS_XSD)); + + // attempt to unmarshal + final Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller(); + unmarshaller.setSchema(schema); + final JAXBElement<Users> element = unmarshaller.unmarshal(new StreamSource(usersFile), Users.class); + final Users users = element.getValue(); + + // add each users dn + for (final User user : users.getUser()) { + userList.add(user.getDn()); + } + } catch (SAXException | JAXBException e) { + throw new RuntimeException("Unable to read the authorized useres file: " + e, e); + } + } + + authorizedUsers = Collections.unmodifiableList(userList); + } + + public boolean canAccess(final String dn) { + return authorizedUsers.contains(dn); + } +} http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/nifi-registry-security/src/main/java/org/apache/nifi/registry/security/AuthorizedUserFilter.java ---------------------------------------------------------------------- diff --git a/nifi-registry-security/src/main/java/org/apache/nifi/registry/security/AuthorizedUserFilter.java b/nifi-registry-security/src/main/java/org/apache/nifi/registry/security/AuthorizedUserFilter.java new file mode 100644 index 0000000..3276a66 --- /dev/null +++ b/nifi-registry-security/src/main/java/org/apache/nifi/registry/security/AuthorizedUserFilter.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.registry.security; + +import java.io.IOException; +import java.io.PrintWriter; +import java.security.cert.X509Certificate; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AuthorizedUserFilter implements Filter { + + private static final Logger logger = LoggerFactory.getLogger(AuthorizedUserFilter.class); + private final AuthorizationProvider provider; + + public AuthorizedUserFilter(final AuthorizationProvider provider) { + this.provider = provider; + } + + @Override + public void init(FilterConfig fc) throws ServletException { + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + final HttpServletRequest httpServletRequest = (HttpServletRequest) request; + final HttpServletResponse httpServletResponse = (HttpServletResponse) response; + + if (request.isSecure()) { + final String dn = getDn(httpServletRequest); + + // if the user has a certificate, extract the dn and see if they can access + if (dn != null && provider.canAccess(dn)) { + chain.doFilter(request, response); + } else { + // set the response status + httpServletResponse.setContentType("text/plain"); + httpServletResponse.setStatus(HttpServletResponse.SC_FORBIDDEN); + + // write the response message + PrintWriter out = httpServletResponse.getWriter(); + out.println("Access is denied."); + + // log the failure + logger.info(String.format(String.format("User <%s> is not authorized.", dn))); + } + } else { + chain.doFilter(request, response); + } + } + + private String getDn(final HttpServletRequest request) { + X509Certificate[] certs = (X509Certificate[]) request.getAttribute("javax.servlet.request.X509Certificate"); + if (certs != null && certs.length > 0) { + return certs[0].getSubjectDN().getName().trim(); + } else { + return null; + } + } + + @Override + public void destroy() { + } + +} http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/nifi-registry-security/src/main/xsd/users.xsd ---------------------------------------------------------------------- diff --git a/nifi-registry-security/src/main/xsd/users.xsd b/nifi-registry-security/src/main/xsd/users.xsd new file mode 100644 index 0000000..fd54c12 --- /dev/null +++ b/nifi-registry-security/src/main/xsd/users.xsd @@ -0,0 +1,37 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <!-- user --> + <xs:complexType name="User"> + <xs:attribute name="dn"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:pattern value=".*[^\s].*"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + </xs:complexType> + + <!-- users --> + <xs:element name="users"> + <xs:complexType> + <xs:sequence> + <xs:element name="user" type="User" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> +</xs:schema> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/nifi-registry-service-api/pom.xml ---------------------------------------------------------------------- diff --git a/nifi-registry-service-api/pom.xml b/nifi-registry-service-api/pom.xml new file mode 100644 index 0000000..dc0e8bd --- /dev/null +++ b/nifi-registry-service-api/pom.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<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"> + <parent> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry</artifactId> + <version>0.0.1-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>nifi-registry-service-api</artifactId> + <packaging>jar</packaging> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + </dependency> + </dependencies> +</project> http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/nifi-registry-web-api/pom.xml ---------------------------------------------------------------------- diff --git a/nifi-registry-web-api/pom.xml b/nifi-registry-web-api/pom.xml new file mode 100644 index 0000000..a7e58ae --- /dev/null +++ b/nifi-registry-web-api/pom.xml @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<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> + <parent> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry</artifactId> + <version>0.0.1-SNAPSHOT</version> + </parent> + <artifactId>nifi-registry-web-api</artifactId> + <version>0.0.1-SNAPSHOT</version> + <packaging>war</packaging> + <dependencies> + <dependency> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry-properties</artifactId> + <version>0.0.1-SNAPSHOT</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry-service-api</artifactId> + <version>0.0.1-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-server</artifactId> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.containers</groupId> + <artifactId>jersey-container-servlet</artifactId> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-client</artifactId> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.media</groupId> + <artifactId>jersey-media-json-jackson</artifactId> + </dependency> + </dependencies> +</project> http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/NiFiRegistryResourceConfig.java ---------------------------------------------------------------------- diff --git a/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/NiFiRegistryResourceConfig.java b/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/NiFiRegistryResourceConfig.java new file mode 100644 index 0000000..f8295f3 --- /dev/null +++ b/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/NiFiRegistryResourceConfig.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.registry.web; + +import org.apache.nifi.registry.web.api.TestResource; +import org.apache.nifi.registry.web.mapper.IllegalArgumentExceptionMapper; +import org.apache.nifi.registry.web.mapper.ThrowableMapper; +import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.server.filter.HttpMethodOverrideFilter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.ServletContext; +import javax.ws.rs.core.Context; + +public class NiFiRegistryResourceConfig extends ResourceConfig { + + private static final Logger logger = LoggerFactory.getLogger(NiFiRegistryResourceConfig.class); + + public NiFiRegistryResourceConfig(@Context ServletContext servletContext) { + register(HttpMethodOverrideFilter.class); + + // register the exception mappers + register(new IllegalArgumentExceptionMapper()); + register(new ThrowableMapper()); + + // register endpoints + register(new TestResource()); + } +} http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/TestResource.java ---------------------------------------------------------------------- diff --git a/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/TestResource.java b/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/TestResource.java new file mode 100644 index 0000000..2564c8a --- /dev/null +++ b/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/TestResource.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.registry.web.api; + +import org.apache.nifi.registry.web.response.TestEntity; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/test") +public class TestResource { + + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response getTest() { + final TestEntity testEntity = new TestEntity("testing"); + return Response.ok(testEntity).build(); + } + +} http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/mapper/IllegalArgumentExceptionMapper.java ---------------------------------------------------------------------- diff --git a/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/mapper/IllegalArgumentExceptionMapper.java b/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/mapper/IllegalArgumentExceptionMapper.java new file mode 100644 index 0000000..3ae44cf --- /dev/null +++ b/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/mapper/IllegalArgumentExceptionMapper.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.registry.web.mapper; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Maps resource not found exceptions into client responses. + */ +@Provider +public class IllegalArgumentExceptionMapper implements ExceptionMapper<IllegalArgumentException> { + + private static final Logger logger = LoggerFactory.getLogger(IllegalArgumentExceptionMapper.class); + + @Override + public Response toResponse(IllegalArgumentException exception) { + logger.info(String.format("%s. Returning %s response.", exception, Response.Status.BAD_REQUEST)); + + if (logger.isDebugEnabled()) { + logger.debug(StringUtils.EMPTY, exception); + } + + return Response.status(Status.BAD_REQUEST).entity(exception.getMessage()).type("text/plain").build(); + } + +} http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/mapper/ThrowableMapper.java ---------------------------------------------------------------------- diff --git a/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/mapper/ThrowableMapper.java b/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/mapper/ThrowableMapper.java new file mode 100644 index 0000000..ecf47e8 --- /dev/null +++ b/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/mapper/ThrowableMapper.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.registry.web.mapper; + +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Maps unknown node exceptions into client responses. + */ +@Provider +public class ThrowableMapper implements ExceptionMapper<Throwable> { + + private static final Logger logger = LoggerFactory.getLogger(ThrowableMapper.class); + + @Override + public Response toResponse(Throwable exception) { + // log the error + logger.error(String.format("An unexpected error has occurred: %s. Returning %s response.", exception, Response.Status.INTERNAL_SERVER_ERROR), exception); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("An unexpected error has occurred. Please check the logs for additional details.").type("text/plain").build(); + } + +} http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/request/IntegerParameter.java ---------------------------------------------------------------------- diff --git a/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/request/IntegerParameter.java b/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/request/IntegerParameter.java new file mode 100644 index 0000000..f5048b3 --- /dev/null +++ b/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/request/IntegerParameter.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.registry.web.request; + +/** + * Class for parsing integer parameters and providing a user friendly error message. + */ +public class IntegerParameter { + + private static final String INVALID_INTEGER_MESSAGE = "Unable to parse '%s' as an integer value."; + + private Integer integerValue; + + public IntegerParameter(String rawIntegerValue) { + try { + integerValue = Integer.parseInt(rawIntegerValue); + } catch (NumberFormatException nfe) { + throw new IllegalArgumentException(String.format(INVALID_INTEGER_MESSAGE, rawIntegerValue)); + } + } + + public Integer getInteger() { + return integerValue; + } +} http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/response/TestEntity.java ---------------------------------------------------------------------- diff --git a/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/response/TestEntity.java b/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/response/TestEntity.java new file mode 100644 index 0000000..d72899d --- /dev/null +++ b/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/response/TestEntity.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.registry.web.response; + +public class TestEntity { + + private final String message; + + public TestEntity(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + +} http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/nifi-registry-web-api/src/main/webapp/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/nifi-registry-web-api/src/main/webapp/WEB-INF/web.xml b/nifi-registry-web-api/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..ea67a48 --- /dev/null +++ b/nifi-registry-web-api/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> + <display-name>nifi-registry-api</display-name> + + <servlet> + <servlet-name>api</servlet-name> + <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> + <init-param> + <param-name>javax.ws.rs.Application</param-name> + <param-value>org.apache.nifi.registry.web.NiFiRegistryResourceConfig</param-value> + </init-param> + </servlet> + <servlet-mapping> + <servlet-name>api</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + + <filter> + <filter-name>gzipCompressionFilter</filter-name> + <filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class> + <init-param> + <param-name>methods</param-name> + <param-value>get,post,put</param-value> + </init-param> + </filter> + <filter-mapping> + <filter-name>gzipCompressionFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + +</web-app> http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/nifi-registry-web-ui/pom.xml ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/pom.xml b/nifi-registry-web-ui/pom.xml new file mode 100644 index 0000000..270af29 --- /dev/null +++ b/nifi-registry-web-ui/pom.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<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> + <parent> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry</artifactId> + <version>0.0.1-SNAPSHOT</version> + </parent> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry-web-ui</artifactId> + <version>0.0.1-SNAPSHOT</version> + <packaging>war</packaging> + <dependencies> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>javax.servlet.jsp</groupId> + <artifactId>javax.servlet.jsp-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>javax.el</groupId> + <artifactId>javax.el-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>javax.servlet.jsp.jstl</groupId> + <artifactId>javax.servlet.jsp.jstl-api</artifactId> + <scope>provided</scope> + </dependency> + </dependencies> +</project> http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/nifi-registry-web-ui/src/main/webapp/WEB-INF/pages/index.jsp ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/src/main/webapp/WEB-INF/pages/index.jsp b/nifi-registry-web-ui/src/main/webapp/WEB-INF/pages/index.jsp new file mode 100644 index 0000000..c78f06a --- /dev/null +++ b/nifi-registry-web-ui/src/main/webapp/WEB-INF/pages/index.jsp @@ -0,0 +1,30 @@ +<%-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--%> +<%@ page contentType="text/html" pageEncoding="UTF-8" session="false" %> +<!DOCTYPE html> +<html> + <head> + <title>NiFi Registry</title> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <link rel="stylesheet" href="css/main.css" type="text/css" /> + </head> + <body> + <div id="content"> + <p>NiFi Registry</p> + </div> + </body> +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/nifi-registry-web-ui/src/main/webapp/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/src/main/webapp/WEB-INF/web.xml b/nifi-registry-web-ui/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..442b4b3 --- /dev/null +++ b/nifi-registry-web-ui/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> + <display-name>nifi-registry</display-name> + + <!-- servlet to map to search page --> + <servlet> + <servlet-name>index</servlet-name> + <jsp-file>/WEB-INF/pages/index.jsp</jsp-file> + </servlet> + <servlet-mapping> + <servlet-name>index</servlet-name> + <url-pattern>/index</url-pattern> + </servlet-mapping> + + <welcome-file-list> + <welcome-file>/WEB-INF/pages/index.jsp</welcome-file> + </welcome-file-list> +</web-app> http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/nifi-registry-web-ui/src/main/webapp/css/main.css ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/src/main/webapp/css/main.css b/nifi-registry-web-ui/src/main/webapp/css/main.css new file mode 100644 index 0000000..6e9d02d --- /dev/null +++ b/nifi-registry-web-ui/src/main/webapp/css/main.css @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* general */ + +body { + font-family: Open Sans; +} http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d6d42d99/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..788a0fc --- /dev/null +++ b/pom.xml @@ -0,0 +1,680 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<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/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache</groupId> + <artifactId>apache</artifactId> + <version>17</version> + <relativePath /> + </parent> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry</artifactId> + <version>0.0.1-SNAPSHOT</version> + <packaging>pom</packaging> + <description>Provides a central location for storage and management of shared resources across one or more instances of NiFi and/or MiNiFi.</description> + <modules> + <module>nifi-registry-assembly</module> + <module>nifi-registry-properties</module> + <module>nifi-registry-jetty</module> + <module>nifi-registry-resources</module> + <module>nifi-registry-runtime</module> + <module>nifi-registry-security</module> + <module>nifi-registry-service-api</module> + <module>nifi-registry-web-api</module> + <module>nifi-registry-web-ui</module> + </modules> + <url>https://nifi.apache.org/registry.html</url> + <organization> + <name>Apache NiFi Project</name> + <url>http://nifi.apache.org/</url> + </organization> + <licenses> + <license> + <name>Apache License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0</url> + </license> + </licenses> + <mailingLists> + <mailingList> + <name>Dev</name> + <subscribe>[email protected]</subscribe> + <unsubscribe>[email protected]</unsubscribe> + <post>[email protected]</post> + <archive>http://mail-archives.apache.org/mod_mbox/nifi-dev</archive> + </mailingList> + <mailingList> + <name>Users</name> + <subscribe>[email protected]</subscribe> + <unsubscribe>[email protected]</unsubscribe> + <post>[email protected]</post> + <archive>http://mail-archives.apache.org/mod_mbox/nifi-users</archive> + </mailingList> + <mailingList> + <name>Commits</name> + <subscribe>[email protected]</subscribe> + <unsubscribe>[email protected]</unsubscribe> + <post>[email protected]</post> + <archive>http://mail-archives.apache.org/mod_mbox/nifi-commits</archive> + </mailingList> + </mailingLists> + <prerequisites> + <maven>${maven.min-version}</maven> + </prerequisites> + <scm> + <connection>scm:git:git://git.apache.org/nifi-registry.git</connection> + <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/nifi-registry.git</developerConnection> + <url>https://git-wip-us.apache.org/repos/asf?p=nifi-registry.git</url> + <tag>HEAD</tag> + </scm> + <issueManagement> + <system>JIRA</system> + <url>https://issues.apache.org/jira/browse/NIFIREG</url> + </issueManagement> + <properties> + <maven.compiler.source>1.8</maven.compiler.source> + <maven.compiler.target>1.8</maven.compiler.target> + <maven.min-version>3.1.0</maven.min-version> + <maven.surefire.arguments/> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <inceptionYear>2017</inceptionYear> + <org.slf4j.version>1.7.12</org.slf4j.version> + <jetty.version>9.2.11.v20150529</jetty.version> + <jersey.version>2.19</jersey.version> + </properties> + + <repositories> + <repository> + <id>central</id> + <!-- This should be at top, it makes maven try the central repo + first and then others and hence faster dep resolution --> + <name>Maven Repository</name> + <url>https://repo1.maven.org/maven2</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + <repository> + <id>apache-repo</id> + <name>Apache Repository</name> + <url>https://repository.apache.org/content/repositories/releases</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + <repository> + <id>jcenter</id> + <url>http://jcenter.bintray.com</url> + <snapshots> + <enabled>false</enabled> + </snapshots> + <releases> + <enabled>true</enabled> + </releases> + </repository> + </repositories> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>1.1.3</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <version>1.1.3</version> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <version>${org.slf4j.version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>log4j-over-slf4j</artifactId> + <version>${org.slf4j.version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jul-to-slf4j</artifactId> + <version>${org.slf4j.version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>${org.slf4j.version}</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-server</artifactId> + <version>${jetty.version}</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlet</artifactId> + <version>${jetty.version}</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-webapp</artifactId> + <version>${jetty.version}</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlets</artifactId> + <version>${jetty.version}</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-jsp</artifactId> + <version>${jetty.version}</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.1.0</version> + </dependency> + <dependency> + <groupId>javax.servlet.jsp</groupId> + <artifactId>javax.servlet.jsp-api</artifactId> + <version>2.3.1</version> + </dependency> + <dependency> + <groupId>javax.el</groupId> + <artifactId>javax.el-api</artifactId> + <version>3.0.0</version> + </dependency> + <dependency> + <groupId>javax.servlet.jsp.jstl</groupId> + <artifactId>javax.servlet.jsp.jstl-api</artifactId> + <version>1.2.1</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-server</artifactId> + <version>${jersey.version}</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.containers</groupId> + <artifactId>jersey-container-servlet</artifactId> + <version>${jersey.version}</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-client</artifactId> + <version>${jersey.version}</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.media</groupId> + <artifactId>jersey-media-json-jackson</artifactId> + <version>${jersey.version}</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>3.4</version> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + <version>${org.slf4j.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.2</version> + <configuration> + <fork>true</fork> + <optimize>true</optimize> + <showDeprecation>true</showDeprecation> + <showWarnings>true</showWarnings> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-eclipse-compiler</artifactId> + <version>2.9.2-01</version> + <extensions>true</extensions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <version>2.5</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.9</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <version>2.7</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.18</version> + <configuration> + <systemPropertyVariables> + <java.awt.headless>true</java.awt.headless> + </systemPropertyVariables> + <includes> + <include>**/*Test.class</include> + <include>**/Test*.class</include> + <include>**/*Spec.class</include> + </includes> + <redirectTestOutputToFile>true</redirectTestOutputToFile> + <argLine combine.children="append">-Xmx1G -Djava.net.preferIPv4Stack=true ${maven.surefire.arguments}</argLine> + </configuration> + <dependencies> + <dependency> + <!-- Force surefire to use JUnit --> + <groupId>org.apache.maven.surefire</groupId> + <artifactId>surefire-junit4</artifactId> + <version>2.18</version> + </dependency> + </dependencies> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <version>2.18</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <version>2.5.2</version> + <configuration> + <tarLongFileMode>gnu</tarLongFileMode> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>jaxb2-maven-plugin</artifactId> + <version>1.6</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>2.4</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-site-plugin</artifactId> + <version>3.4</version> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>1.3.2</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.5</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.10.1</version> + <configuration> + <failOnError>false</failOnError> + <quiet>true</quiet> + <show>private</show> + <encoding>UTF-8</encoding> + <quiet>true</quiet> + <javadocVersion>1.8</javadocVersion> + <additionalJOption>-J-Xmx512m</additionalJOption> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-release-plugin</artifactId> + <version>2.5.1</version> + <configuration> + <useReleaseProfile>true</useReleaseProfile> + <releaseProfiles>apache-release</releaseProfiles> + <autoVersionSubmodules>true</autoVersionSubmodules> + <goals>deploy</goals> + <tagNameFormat>@{project.artifactId}-@{project.version}</tagNameFormat> + <pushChanges>false</pushChanges> + <localCheckout>true</localCheckout> + </configuration> + <executions> + <execution> + <id>default</id> + <goals> + <goal>perform</goal> + </goals> + <configuration> + <pomFileName>pom.xml</pomFileName> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>rpm-maven-plugin</artifactId> + <version>2.1.4</version> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>buildnumber-maven-plugin</artifactId> + <version>1.4</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>2.15</version> + <dependencies> + <dependency> + <groupId>com.puppycrawl.tools</groupId> + <artifactId>checkstyle</artifactId> + <version>6.5</version> + </dependency> + </dependencies> + </plugin> + </plugins> + </pluginManagement> + + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <executions> + <!-- Only run for tests --> + <execution> + <id>groovy-tests</id> + <goals> + <goal>testCompile</goal> + </goals> + <configuration> + <compilerId>groovy-eclipse-compiler</compilerId> + </configuration> + </execution> + </executions> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + <dependencies> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-eclipse-compiler</artifactId> + <version>2.9.2-01</version> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-eclipse-batch</artifactId> + <version>2.4.3-01</version> + </dependency> + </dependencies> + </plugin> + <plugin> + <groupId>org.sonatype.plugins</groupId> + <artifactId>nexus-staging-maven-plugin</artifactId> + <version>1.6.5</version> + <extensions>true</extensions> + <configuration> + <stagingProgressTimeoutMinutes>15</stagingProgressTimeoutMinutes> + <serverId>repository.apache.org</serverId> + <nexusUrl>https://repository.apache.org/</nexusUrl> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-enforcer-plugin</artifactId> + <executions> + <execution> + <id>enforce-maven</id> + <goals> + <goal>enforce</goal> + </goals> + <configuration> + <rules> + <requireSameVersions> + <plugins> + <plugin>org.apache.maven.plugins:maven-surefire-plugin</plugin> + <plugin>org.apache.maven.plugins:maven-failsafe-plugin</plugin> + <plugin>org.apache.maven.plugins:maven-surefire-report-plugin</plugin> + </plugins> + </requireSameVersions> + <requireMavenVersion> + <version>${maven.min-version}</version> + </requireMavenVersion> + </rules> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <configuration> + <checkstyleRules> + <module name="Checker"> + <property name="charset" value="UTF-8" /> + <property name="severity" value="warning" /> + <!-- Checks for whitespace --> + <!-- See http://checkstyle.sf.net/config_whitespace.html --> + <module name="FileTabCharacter"> + <property name="eachLine" value="true" /> + </module> + <module name="TreeWalker"> + <module name="RegexpSinglelineJava"> + <property name="format" value="\s+$" /> + <property name="message" value="Line has trailing whitespace." /> + </module> + <module name="RegexpSinglelineJava"> + <property name="format" value="[@]see\s+[{][@]link" /> + <property name="message" value="Javadoc @see does not need @link: pick one or the other." /> + </module> + <module name="OuterTypeFilename" /> + <module name="LineLength"> + <!-- needs extra, because Eclipse formatter ignores the ending left + brace --> + <property name="max" value="200" /> + <property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://" /> + </module> + <module name="AvoidStarImport" /> + <module name="UnusedImports"> + <property name="processJavadoc" value="true" /> + </module> + <module name="NoLineWrap" /> + <module name="LeftCurly"> + <property name="maxLineLength" value="160" /> + </module> + <module name="RightCurly" /> + <module name="RightCurly"> + <property name="option" value="alone" /> + <property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT" /> + </module> + <module name="SeparatorWrap"> + <property name="tokens" value="DOT" /> + <property name="option" value="nl" /> + </module> + <module name="SeparatorWrap"> + <property name="tokens" value="COMMA" /> + <property name="option" value="EOL" /> + </module> + <module name="PackageName"> + <property name="format" value="^[a-z]+(\.[a-z][a-zA-Z0-9]*)*$" /> + </module> + <module name="MethodTypeParameterName"> + <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)" /> + </module> + <module name="MethodParamPad" /> + <module name="OperatorWrap"> + <property name="option" value="NL" /> + <property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, QUESTION, SL, SR, STAR " /> + </module> + <module name="AnnotationLocation"> + <property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF" /> + </module> + <module name="AnnotationLocation"> + <property name="tokens" value="VARIABLE_DEF" /> + <property name="allowSamelineMultipleAnnotations" value="true" /> + </module> + <module name="NonEmptyAtclauseDescription" /> + <module name="JavadocMethod"> + <property name="allowMissingJavadoc" value="true" /> + <property name="allowMissingParamTags" value="true" /> + <property name="allowMissingThrowsTags" value="true" /> + <property name="allowMissingReturnTag" value="true" /> + <property name="allowedAnnotations" value="Override,Test,BeforeClass,AfterClass,Before,After" /> + <property name="allowThrowsTagsForSubclasses" value="true" /> + </module> + <module name="SingleLineJavadoc" /> + </module> + </module> + </checkstyleRules> + <violationSeverity>warning</violationSeverity> + <includeTestSourceDirectory>true</includeTestSourceDirectory> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.rat</groupId> + <artifactId>apache-rat-plugin</artifactId> + <configuration> + <excludes> + <exclude>nb-configuration.xml</exclude> <!-- courtesy excludes for netbeans users --> + <exclude>nbactions.xml</exclude> <!-- courtesy excludes for netbeans users --> + <exclude>DEPENDENCIES</exclude> <!-- auto generated file by apache's maven config while building sources.zip --> + <exclude>.github/PULL_REQUEST_TEMPLATE.md</exclude> <!-- PR Template for GitHub that does not have a mechanism of including comments --> + </excludes> + </configuration> + <dependencies> + <!-- workaround for RAT-158 --> + <dependency> + <groupId>org.apache.maven.doxia</groupId> + <artifactId>doxia-core</artifactId> + <version>1.6</version> + <exclusions> + <exclusion> + <groupId>xerces</groupId> + <artifactId>xercesImpl</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + </plugin> + </plugins> + </build> + + <profiles> + <profile> + <!-- Checks style and licensing requirements. This is a good idea to run + for contributions and for the release process. While it would be nice to + run always these plugins can considerably slow the build and have proven + to create unstable builds in our multi-module project and when building using + multiple threads. The stability issues seen with Checkstyle in multi-module + builds include false-positives and false negatives. --> + <id>contrib-check</id> + <build> + <plugins> + <plugin> + <groupId>org.apache.rat</groupId> + <artifactId>apache-rat-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>check</goal> + </goals> + <phase>verify</phase> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <executions> + <execution> + <id>check-style</id> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + <profile> + <!-- This profile will disable DocLint which performs strict + JavaDoc processing which was introduced in JDK 8. These are technically errors + in the JavaDoc which we need to eventually address. However, if a release + is performed using JDK 8, the JavaDoc generation would fail. By activating + this profile when running on JDK 8 we can ensure the JavaDocs continue to + generate successfully --> + <id>disable-doclint</id> + <activation> + <jdk>1.8</jdk> + </activation> + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <configuration> + <additionalparam>-Xdoclint:none</additionalparam> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + </profile> + </profiles> + +</project>
