project pom checkstyle/spotbugs reorg

This commit is contained in:
jrivard@gmail.com 2018-08-11 22:04:06 -04:00
parent 95f2b9eacf
commit add0d6b15e
39 changed files with 428 additions and 188 deletions

View file

@ -0,0 +1,55 @@
<?xml version="1.0"?>
<!--
~ Password Management Servlets (PWM)
~ http://www.pwm-project.org
~
~ Copyright (c) 2006-2009 Novell, Inc.
~ Copyright (c) 2009-2018 The PWM Project
~
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation; either version 2 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-->
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<!--
PWM Checkstyle definition
-->
<module name="Checker">
<module name="Header">
<property name="headerFile" value="${basedir}/build/license-header-jsp.txt"/>
<property name="fileExtensions" value="jsp"/>
</module>
<module name="Header">
<property name="headerFile" value="${basedir}/build/license-header-java.txt"/>
<property name="fileExtensions" value="java,css"/>
</module>
<module name="Header">
<property name="headerFile" value="${basedir}/build/license-header-xml.txt"/>
<property name="fileExtensions" value="xml,svg"/>
</module>
<module name="Header">
<property name="headerFile" value="${basedir}/build/license-header-properties.txt"/>
<property name="fileExtensions" value="properties"/>
</module>
<module name="Header">
<property name="headerFile" value="${basedir}/build/license-header-js.txt"/>
<property name="fileExtensions" value="js,ts"/>
</module>
</module>

View file

@ -31,23 +31,6 @@
<module name="Checker">
<module name="Header">
<property name="headerFile" value="${basedir}/build/license-header-jsp.txt"/>
<property name="fileExtensions" value="jsp"/>
</module>
<module name="Header">
<property name="headerFile" value="${basedir}/build/license-header-java.txt"/>
<property name="fileExtensions" value="java,css"/>
</module>
<module name="Header">
<property name="headerFile" value="${basedir}/build/license-header-xml.txt"/>
<property name="fileExtensions" value="xml,svg"/>
</module>
<module name="Header">
<property name="headerFile" value="${basedir}/build/license-header-properties.txt"/>
<property name="fileExtensions" value="properties"/>
</module>
<!-- Checks that each Java package has a Javadoc file used for commenting. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
@ -76,7 +59,7 @@
<property name="lineSeparator" value="lf_cr_crlf" />
</module>
<module name="TreeWalker">
<module name="TreeWalker" >
<property name="cacheFile" value="target/checkstyle.cache"/>
<!-- required for SuppressWarningsFilter (and other Suppress* rules not used here) -->

View file

@ -0,0 +1,22 @@
/*
* Password Management Servlets (PWM)
* http://www.pwm-project.org
*
* Copyright (c) 2006-2009 Novell, Inc.
* Copyright (c) 2009-2018 The PWM Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Password Management Servlets (PWM)
~ Copyright (c) 2006-2018 Novell, Inc.
~ Copyright (c) 2006-2009 Novell, Inc.
~ Copyright (c) 2009-2018 The PWM Project
~
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by

View file

@ -1,6 +1,6 @@
/*
* Password Management Servlets (PWM)
htt://www.pwm-project.org
* http://www.pwm-project.org
*
* Copyright (c) 2006-2009 Novell, Inc.
* Copyright (c) 2009-2018 The PWM Project
@ -20,7 +20,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import {Component} from '../../component';
import {IHelpDeskService, ISuccessResponse} from '../../services/helpdesk.service';
import {IScope, ui} from 'angular';

View file

@ -1,4 +1,3 @@
/*
* Password Management Servlets (PWM)
* http://www.pwm-project.org
@ -20,6 +19,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* tslint:disable */
export const helpdeskProcessAction_clientData = {

View file

@ -19,6 +19,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* tslint:disable */
export const getRecentVerifications_response = {

View file

@ -3,7 +3,7 @@
* http://www.pwm-project.org
*
* Copyright (c) 2006-2009 Novell, Inc.
* Copyright (c) 2009-2016 The PWM Project
* Copyright (c) 2009-2018 The PWM Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -20,7 +20,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
export default class ObjectService {
// ES5 implementation of Object.assign
// Source from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign

View file

@ -8,7 +8,7 @@
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later versionI.
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -20,7 +20,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import { IPromise, IQService, ITimeoutService } from 'angular';
import { IPerson } from '../models/person.model';
import { IPeopleService } from './people.service';

View file

@ -3,7 +3,7 @@
* http://www.pwm-project.org
*
* Copyright (c) 2006-2009 Novell, Inc.
* Copyright (c) 2009-2016 The PWM Project
* Copyright (c) 2009-2018 The PWM Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -20,7 +20,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import { IPromise, IQService } from 'angular';
// Pattern explained at https://www.bennadel.com/blog/2731-canceling-a-promise-in-angularjs.htm

View file

@ -25,8 +25,12 @@ package password.pwm.receiver;
import password.pwm.util.java.StringUtil;
import password.pwm.util.java.TimeDuration;
import java.io.FileReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@ -74,14 +78,17 @@ public class Settings
static Settings readFromFile( final String filename ) throws IOException
{
final Properties properties = new Properties();
properties.load( new FileReader( filename ) );
final Map<Setting, String> returnMap = new HashMap<>();
for ( final Setting setting : Setting.values() )
try ( Reader reader = new InputStreamReader( new FileInputStream( new File( filename ) ), StandardCharsets.UTF_8 ) )
{
final String value = properties.getProperty( setting.name(), setting.getDefaultValue() );
returnMap.put( setting, value );
properties.load( reader );
final Map<Setting, String> returnMap = new HashMap<>();
for ( final Setting setting : Setting.values() )
{
final String value = properties.getProperty( setting.name(), setting.getDefaultValue() );
returnMap.put( setting, value );
}
return new Settings( Collections.unmodifiableMap( returnMap ) );
}
return new Settings( Collections.unmodifiableMap( returnMap ) );
}
public String getSetting( final Setting setting )

View file

@ -60,11 +60,11 @@ public class Storage
throw new IOException( "data path '" + dataPath + "' does not exist" );
}
final File stoagePath = new File( dataPath.getAbsolutePath() + File.separator + "storage" );
stoagePath.mkdir();
final File storagePath = new File( dataPath.getAbsolutePath() + File.separator + "storage" );
mkdirs( storagePath );
final EnvironmentConfig environmentConfig = new EnvironmentConfig();
environment = Environments.newInstance( stoagePath.getAbsolutePath(), environmentConfig );
environment = Environments.newInstance( storagePath.getAbsolutePath(), environmentConfig );
environment.executeInTransaction( txn -> store
= environment.openStore( "store1", StoreConfig.WITHOUT_DUPLICATES, txn ) );
@ -216,4 +216,12 @@ public class Storage
}
}
static void mkdirs( final File file ) throws IOException
{
if ( !file.mkdirs() )
{
throw new IOException( "unable to create path " + file.getAbsolutePath() );
}
}
}

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Password Management Servlets (PWM)
~ Copyright (c) 2006-2018 Novell, Inc.
~ Copyright (c) 2006-2009 Novell, Inc.
~ Copyright (c) 2009-2018 The PWM Project
~
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
@ -18,7 +19,6 @@
~ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-->
<Context tldValidation="false" unloadDelay="30000" useHttpOnly="true">
</Context>

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Password Management Servlets (PWM)
~ Copyright (c) 2006-2018 Novell, Inc.
~ Copyright (c) 2006-2009 Novell, Inc.
~ Copyright (c) 2009-2018 The PWM Project
~
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by

View file

@ -88,29 +88,7 @@
<type>war</type>
<scope>provided</scope>
</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>apache-jsp</artifactId>
<version>${jetty-version}</version>
<type>jar</type>
</dependency>
-->
<!-- embedded tomcat -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>

View file

@ -110,9 +110,9 @@ public class ArgumentParser
private Map<Argument, String> mapFromProperties( final String filename ) throws ArgumentParserException
{
final Properties props = new Properties();
try
try ( InputStream is = new FileInputStream( new File( filename ) ) )
{
props.load( new FileInputStream( new File( filename ) ) );
props.load( is );
}
catch ( IOException e )
{
@ -167,9 +167,9 @@ public class ArgumentParser
final File inputWarFile = new File( argumentMap.get( Argument.war ) );
if ( !inputWarFile.exists() )
{
System.out.println( "output war file " + inputWarFile.getAbsolutePath() + "does not exist" );
System.exit( -1 );
return null;
final String msg = "output war file " + inputWarFile.getAbsolutePath() + "does not exist";
System.out.println( msg );
throw new IllegalStateException( msg );
}
onejarConfig.setWar( new FileInputStream( inputWarFile ) );
}
@ -187,8 +187,9 @@ public class ArgumentParser
}
catch ( NumberFormatException e )
{
System.out.println( Argument.port.name() + " argument must be numeric" );
System.exit( -1 );
final String msg = Argument.port.name() + " argument must be numeric";
System.out.println( msg );
throw new IllegalStateException( msg );
}
}
@ -249,14 +250,16 @@ public class ArgumentParser
return file;
}
private static File figureDefaultWorkPath( final OnejarConfig onejarConfig ) throws ArgumentParserException
private static File figureDefaultWorkPath( final OnejarConfig onejarConfig )
throws ArgumentParserException, IOException
{
final String userHomePath = System.getProperty( "user.home" );
if ( userHomePath != null && !userHomePath.isEmpty() )
{
final File basePath = new File( userHomePath + File.separator
+ Resource.defaultWorkPathName.getValue() );
basePath.mkdir();
mkdirs( basePath );
final String workPath;
{
@ -274,7 +277,7 @@ public class ArgumentParser
workPath = workPathStr;
}
final File workFile = new File( workPath );
workFile.mkdirs();
mkdirs( workFile );
TomcatOneJarMain.out( "using work directory: " + workPath );
return workFile;
}
@ -311,4 +314,12 @@ public class ArgumentParser
}
return stringBuilder.toString();
}
static void mkdirs( final File file ) throws IOException
{
if ( !file.mkdirs() && !file.exists() )
{
throw new IOException( "unable to create path " + file.getAbsolutePath() );
}
}
}

View file

@ -30,14 +30,17 @@ import org.apache.catalina.util.ServerInfo;
import javax.servlet.ServletException;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileVisitOption;
import java.nio.file.Files;
import java.nio.file.Path;
@ -105,7 +108,8 @@ public class TomcatOneJarMain
final InputStream warSource = onejarConfig.getWar();
final ZipInputStream zipInputStream = new ZipInputStream( warSource );
final File outputFolder = getWarFolder( onejarConfig );
outputFolder.mkdir();
ArgumentParser.mkdirs( outputFolder );
ZipEntry zipEntry = zipInputStream.getNextEntry();
@ -116,7 +120,7 @@ public class TomcatOneJarMain
if ( !zipEntry.isDirectory() )
{
newFile.getParentFile().mkdirs();
ArgumentParser.mkdirs( newFile.getParentFile() );
Files.copy( zipInputStream, newFile.toPath() );
}
zipEntry = zipInputStream.getNextEntry();
@ -151,18 +155,18 @@ public class TomcatOneJarMain
{
final File basePath = new File( onejarConfig.getWorkingPath().getPath() + File.separator + "b" );
basePath.mkdir();
ArgumentParser.mkdirs( basePath );
tomcat.setBaseDir( basePath.getAbsolutePath() );
}
{
final File basePath = new File( onejarConfig.getWorkingPath().getPath() + File.separator + "a" );
basePath.mkdir();
ArgumentParser.mkdirs( basePath );
tomcat.getServer().setCatalinaBase( basePath );
tomcat.getServer().setCatalinaHome( basePath );
}
{
final File workPath = new File( onejarConfig.getWorkingPath().getPath() + File.separator + "w" );
workPath.mkdir();
ArgumentParser.mkdirs( workPath );
tomcat.getHost().setAppBase( workPath.getAbsolutePath() );
}
@ -199,9 +203,9 @@ public class TomcatOneJarMain
final String srcRootIndex = "ROOT-redirect-webapp/WEB-INF/index.jsp";
final File redirBase = new File( onejarConfig.getWorkingPath().getAbsoluteFile() + File.separator + "redirectBase" );
redirBase.mkdirs();
ArgumentParser.mkdirs( redirBase );
{
new File ( redirBase.getAbsolutePath() + File.separator + "WEB-INF" ).mkdirs();
ArgumentParser.mkdirs( new File ( redirBase.getAbsolutePath() + File.separator + "WEB-INF" ) );
copyFileAndReplace(
srcRootWebXml,
redirBase.getPath() + File.separator + "WEB-INF" + File.separator + "web.xml",
@ -287,9 +291,12 @@ public class TomcatOneJarMain
final File webInfPath = new File( warPath.getAbsolutePath() + File.separator + "WEB-INF" + File.separator + "lib" );
final File[] jarFiles = webInfPath.listFiles();
final List<URL> jarURLList = new ArrayList<>();
for ( final File jarFile : jarFiles )
if ( jarFiles != null )
{
jarURLList.add( jarFile.toURI().toURL() );
for ( final File jarFile : jarFiles )
{
jarURLList.add( jarFile.toURI().toURL() );
}
}
final URLClassLoader classLoader = URLClassLoader.newInstance( jarURLList.toArray( new URL[ jarURLList.size() ] ) );
final Class pwmMainClass = classLoader.loadClass( "password.pwm.util.cli.MainClass" );
@ -321,7 +328,10 @@ public class TomcatOneJarMain
properties.setProperty( "AutoExportHttpsKeyStorePassword", onejarConfig.getKeystorePass() );
properties.setProperty( "AutoExportHttpsKeyStoreAlias", KEYSTORE_ALIAS );
final File propFile = getPwmAppPropertiesFile( onejarConfig );
properties.store( new FileWriter( propFile ), "auto-generated file" );
try ( Writer writer = new OutputStreamWriter( new FileOutputStream( propFile ), StandardCharsets.UTF_8 ) )
{
properties.store( writer, "auto-generated file" );
}
}
static void copyFileAndReplace(
@ -331,9 +341,14 @@ public class TomcatOneJarMain
)
throws IOException
{
final InputStream inputStream = TomcatOneJarMain.class.getClassLoader().getResourceAsStream( srcPath );
String contents = new BufferedReader( new InputStreamReader( inputStream ) ).lines().collect( Collectors.joining( "\n" ) );
contents = contents.replace( "[[[ROOT_CONTEXT]]]", rootcontext );
Files.write( Paths.get( destPath ), contents.getBytes() );
try ( InputStream inputStream = TomcatOneJarMain.class.getClassLoader().getResourceAsStream( srcPath ) )
{
try ( BufferedReader reader = new BufferedReader( new InputStreamReader( inputStream, "UTF8" ) ) )
{
String contents = reader.lines().collect( Collectors.joining( "\n" ) );
contents = contents.replace( "[[[ROOT_CONTEXT]]]", rootcontext );
Files.write( Paths.get( destPath ), contents.getBytes( "UTF8" ) );
}
}
}
}

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Password Management Servlets (PWM)
~ Copyright (c) 2006-2018 Novell, Inc.
~ Copyright (c) 2006-2009 Novell, Inc.
~ Copyright (c) 2009-2018 The PWM Project
~
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by

53
pom.xml
View file

@ -51,6 +51,12 @@
<checkstyle.skip>true</checkstyle.skip>
</properties>
</profile>
<profile>
<id>skip-spotbugs</id>
<properties>
<skipSpotbugs>true</skipSpotbugs>
</properties>
</profile>
</profiles>
<build>
@ -97,7 +103,7 @@
</dependencies>
<executions>
<execution>
<id>validate</id>
<id>checkstyle</id>
<phase>validate</phase>
<configuration>
<propertyExpansion>basedir=${project.root.basedir}</propertyExpansion>
@ -115,6 +121,51 @@
<goal>check</goal>
</goals>
</execution>
<execution>
<id>checkstyle-header</id>
<phase>validate</phase>
<configuration>
<propertyExpansion>basedir=${project.root.basedir}</propertyExpansion>
<configLocation>${project.root.basedir}/build/checkstyle-header.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<includeTestResources>false</includeTestResources>
<failsOnError>true</failsOnError>
<includes>**/**</includes>
<sourceDirectories>
<directory>src</directory>
</sourceDirectories>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.3.1</version>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>3.1.6</version>
</dependency>
</dependencies>
<configuration>
<fork>false</fork>
<excludeFilterFile>${project.root.basedir}/build/spotbugs-exclude.xml</excludeFilterFile>
<includeTests>false</includeTests>
<skip>${skipSpotbugs}</skip>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

View file

@ -0,0 +1,48 @@
/*
* Password Management Servlets (PWM)
* http://www.pwm-project.org
*
* Copyright (c) 2006-2009 Novell, Inc.
* Copyright (c) 2009-2018 The PWM Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package password.pwm.cr;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.TimeZone;
public class CrUtils
{
static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss Z";
static Instant parseDateString( final String input ) throws ParseException
{
final SimpleDateFormat dateFormatter = new SimpleDateFormat( DATE_FORMAT );
dateFormatter.setTimeZone( TimeZone.getTimeZone( "Zulu" ) );
return dateFormatter.parse( input ).toInstant();
}
static String formatDateString( final Instant input )
{
final SimpleDateFormat dateFormatter = new SimpleDateFormat( DATE_FORMAT );
dateFormatter.setTimeZone( TimeZone.getTimeZone( "Zulu" ) );
return dateFormatter.format( input );
}
}

View file

@ -31,42 +31,10 @@
<maven.javadoc.skip>true</maven.javadoc.skip>
</properties>
</profile>
<profile>
<id>skip-spotbugs</id>
<properties>
<skipSpotbugs>true</skipSpotbugs>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.3.1</version>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>3.1.6</version>
</dependency>
</dependencies>
<configuration>
<fork>false</fork>
<excludeFilterFile>../build/spotbugs-exclude.xml</excludeFilterFile>
<includeTests>false</includeTests>
<skip>${skipSpotbugs}</skip>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Password Management Servlets (PWM)
~ Copyright (c) 2006-2018 Novell, Inc.
~ Copyright (c) 2006-2009 Novell, Inc.
~ Copyright (c) 2009-2018 The PWM Project
~
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
@ -18,7 +19,6 @@
~ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-->
<Context tldValidation="false" unloadDelay="30000" useHttpOnly="true">
</Context>

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Password Management Servlets (PWM)
~ Copyright (c) 2006-2018 Novell, Inc.
~ Copyright (c) 2006-2009 Novell, Inc.
~ Copyright (c) 2009-2018 The PWM Project
~
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
@ -22,9 +23,9 @@
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="PWM-rest-test-servlet" version="3.0">
<display-name>PWM REST Test Server</display-name>
<display-name>PWM Web Service Test Server</display-name>
<!-- <distributable/> Clustering/Session replication is not supported -->
<description>PWM REST Test Server</description>
<description>PWM Web Service Test Server</description>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

View file

@ -17,7 +17,6 @@
<properties>
<project.root.basedir>${project.basedir}/..</project.root.basedir>
<skipTests>false</skipTests>
<skipSpotbugs>false</skipSpotbugs>
</properties>
<profiles>
@ -33,12 +32,6 @@
<maven.javadoc.skip>true</maven.javadoc.skip>
</properties>
</profile>
<profile>
<id>skip-spotbugs</id>
<properties>
<skipSpotbugs>true</skipSpotbugs>
</properties>
</profile>
<profile>
<!-- Builds a zip file containing the built war file, along with the supplemental directory -->
<id>release</id>
@ -105,32 +98,6 @@
</plugin>
-->
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.3.1</version>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>3.1.6</version>
</dependency>
</dependencies>
<configuration>
<fork>false</fork>
<excludeFilterFile>../build/spotbugs-exclude.xml</excludeFilterFile>
<includeTests>false</includeTests>
<skip>${skipSpotbugs}</skip>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>

View file

@ -44,6 +44,7 @@ import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.HttpRoutePlanner;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
@ -89,12 +90,13 @@ import java.time.Instant;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
public class PwmHttpClient
{
private static final PwmLogger LOGGER = PwmLogger.forClass( PwmHttpClient.class );
private static int classCounter = 0;
private static final AtomicInteger REQUEST_COUNTER = new AtomicInteger( 0 );
private final PwmApplication pwmApplication;
private final SessionLabel sessionLabel;
@ -128,6 +130,7 @@ public class PwmHttpClient
throws PwmUnrecoverableException
{
final HttpClientBuilder clientBuilder = HttpClientBuilder.create();
clientBuilder.useSystemProperties();
clientBuilder.setUserAgent( PwmConstants.PWM_APP_NAME + " " + PwmConstants.SERVLET_VERSION );
final boolean httpClientPromiscuousEnable = Boolean.parseBoolean( configuration.readAppProperty( AppProperty.SECURITY_HTTP_PROMISCUOUS_ENABLE ) );
@ -149,7 +152,10 @@ public class PwmHttpClient
new SecureRandom() );
final SSLConnectionSocketFactory sslConnectionFactory = new SSLConnectionSocketFactory( sslContext, NoopHostnameVerifier.INSTANCE );
final Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create().register( "https", sslConnectionFactory ).build();
final Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
.register( "https", sslConnectionFactory )
.register( "http", PlainConnectionSocketFactory.INSTANCE )
.build();
final HttpClientConnectionManager ccm = new BasicHttpClientConnectionManager( registry );
clientBuilder.setSSLSocketFactory( sslConnectionFactory );
@ -271,7 +277,7 @@ public class PwmHttpClient
throws IOException, URISyntaxException, PwmUnrecoverableException
{
final Instant startTime = Instant.now();
final int counter = classCounter++;
final int counter = REQUEST_COUNTER.getAndIncrement();
LOGGER.trace( sessionLabel, "preparing to send (id=" + counter + ") "
+ clientRequest.toDebugString( this ) );

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Password Management Servlets (PWM)
~ Copyright (c) 2006-2018 Novell, Inc.
~ Copyright (c) 2006-2009 Novell, Inc.
~ Copyright (c) 2009-2018 The PWM Project
~
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by

View file

@ -1,3 +1,25 @@
/*
* Password Management Servlets (PWM)
* http://www.pwm-project.org
*
* Copyright (c) 2006-2009 Novell, Inc.
* Copyright (c) 2009-2018 The PWM Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package password.pwm.config;
import org.junit.Assert;

View file

@ -1,3 +1,25 @@
/*
* Password Management Servlets (PWM)
* http://www.pwm-project.org
*
* Copyright (c) 2006-2009 Novell, Inc.
* Copyright (c) 2009-2018 The PWM Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package password.pwm.health;
import org.junit.Assert;

View file

@ -1,3 +1,25 @@
/*
* Password Management Servlets (PWM)
* http://www.pwm-project.org
*
* Copyright (c) 2006-2009 Novell, Inc.
* Copyright (c) 2009-2018 The PWM Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package password.pwm.i18n;
import org.junit.Assert;

View file

@ -1,3 +1,25 @@
/*
* Password Management Servlets (PWM)
* http://www.pwm-project.org
*
* Copyright (c) 2006-2009 Novell, Inc.
* Copyright (c) 2009-2018 The PWM Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package password.pwm.i18n;
import org.junit.Assert;

View file

@ -1,3 +1,25 @@
/*
* Password Management Servlets (PWM)
* http://www.pwm-project.org
*
* Copyright (c) 2006-2009 Novell, Inc.
* Copyright (c) 2009-2018 The PWM Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package password.pwm.util.java;
import org.junit.Assert;

View file

@ -1,3 +1,25 @@
/*
* Password Management Servlets (PWM)
* http://www.pwm-project.org
*
* Copyright (c) 2006-2009 Novell, Inc.
* Copyright (c) 2009-2018 The PWM Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package password.pwm.ws.server.rest;
import org.junit.Assert;

View file

@ -15,30 +15,17 @@
<name>PWM Password Self Service: Server WAR</name>
<properties>
<skipTests>false</skipTests>
<skipSpotbugs>false</skipSpotbugs>
<skipSpotbugs>true</skipSpotbugs>
<project.root.basedir>${project.basedir}/..</project.root.basedir>
</properties>
<profiles>
<profile>
<id>skip-tests</id>
<properties>
<skipTests>true</skipTests>
</properties>
</profile>
<profile>
<id>skip-javadoc</id>
<properties>
<maven.javadoc.skip>true</maven.javadoc.skip>
</properties>
</profile>
<profile>
<id>skip-spotbugs</id>
<properties>
<skipSpotbugs>true</skipSpotbugs>
</properties>
</profile>
<profile>
<!-- Builds a zip file containing the built war file, along with the supplemental directory -->
<id>release</id>

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Password Management Servlets (PWM)
~ http://www.pwm-project.org
~
~ Copyright (c) 2006-2009 Novell, Inc.
~ Copyright (c) 2009-2018 The PWM Project
~

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Password Management Servlets (PWM)
~ http://www.pwm-project.org
~
~ Copyright (c) 2006-2009 Novell, Inc.
~ Copyright (c) 2009-2018 The PWM Project
~

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Password Management Servlets (PWM)
~ http://www.pwm-project.org
~
~ Copyright (c) 2006-2009 Novell, Inc.
~ Copyright (c) 2009-2018 The PWM Project
~

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Password Management Servlets (PWM)
~ Copyright (c) 2006-2018 Novell, Inc.
~ Copyright (c) 2006-2009 Novell, Inc.
~ Copyright (c) 2009-2018 The PWM Project
~
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Password Management Servlets (PWM)
~ Copyright (c) 2006-2018 Novell, Inc.
~ Copyright (c) 2006-2009 Novell, Inc.
~ Copyright (c) 2009-2018 The PWM Project
~
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Password Management Servlets (PWM)
~ Copyright (c) 2006-2018 Novell, Inc.
~ Copyright (c) 2006-2009 Novell, Inc.
~ Copyright (c) 2009-2018 The PWM Project
~
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by