diff --git a/Kieker.WebGUI/config/quality-config/cs-conf.xml b/Kieker.WebGUI/config/quality-config/cs-conf.xml index 172de58ccd00596596ea24d45cf285d213d9a0d9..30cb12189eb4cace68a72832968516bbeda76639 100644 --- a/Kieker.WebGUI/config/quality-config/cs-conf.xml +++ b/Kieker.WebGUI/config/quality-config/cs-conf.xml @@ -1,1178 +1,255 @@ -<?xml version="1.0"?> -<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.1//EN" "http://www.puppycrawl.com/dtds/configuration_1_1.dtd"> - +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> + +<!-- + This configuration file was written by the eclipse-cs plugin configuration editor +--> +<!-- + Checkstyle-Configuration: CS-Config + Description: none +--> <module name="Checker"> - - <!-- KIEKER default is warning instead of error --> - <property name="severity" value="warning"/> - - <!-- KIEKER Filter --> - <module name="SuppressWithNearbyCommentFilter"> - <property name="commentFormat" value="NOCS"/> - <property name="checkFormat" value=".*"/> - <property name="influenceFormat" value="0"/> + <property name="severity" value="warning"/> + <module name="TreeWalker"> + <property name="tabWidth" value="4"/> + <module name="FileContentsHolder"/> + <module name="AnnotationUseStyle"/> + <module name="MissingDeprecated"> + <property name="severity" value="info"/> </module> - - <!-- - <property name="basedir" value=""/> - <property name="localeCountry" value=""/> JVM locale country - <property name="localeLanguage" value=""/> JVM locale language - <property name="charset" value=""/> JVM file.encoding property - !--> - - - <!-- - !________________________________________________________________________________________ - ! - ! D U P L I C A T E S - !________________________________________________________________________________________ - !--> - <!-- Performs a line-by-line comparison of all code lines and reports duplicate code. !--> - <!-- See http://checkstyle.sf.net/config_duplicates.html !--> - <!-- KIEKER Does not work with headers!! - <module name="StrictDuplicateCode"> - <property name="min" value="12"/> - <property name="fileExtensions" value=""/> + <module name="PackageAnnotation"/> + <module name="SuppressWarnings"> + <property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF, ENUM_CONSTANT_DEF, PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF, CTOR_DEF"/> </module> - --> - - <!-- - !________________________________________________________________________________________ - ! - ! H E A D E R S - !________________________________________________________________________________________ - !--> - <!-- NOTE: You may enable zero or one of these header checks, but not both. !--> - - <!-- Checks that a source file begins with a specified header. !--> - <!-- See http://checkstyle.sf.net/config_header.html !--> - <!-- KIEKER !--> - <module name="Header"> - <!--<property name="headerFile" value="lib/checkstyle-5.4/header.txt"/>--> - <!--<property name="charset" value=""/>--> - <property name="header" value="/***************************************************************************\n * Copyright 2012 Kieker Project (http://kieker-monitoring.net)\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n"/> - <property name="ignoreLines" value="2"/> - <property name="fileExtensions" value="java"/> + <module name="AvoidNestedBlocks"> + <property name="allowInSwitchCase" value="true"/> </module> - - <!-- Checks the header of a source file against a header file that contains a regular expression !--> - <!-- for each line of the source header. !--> - <!-- See http://checkstyle.sf.net/config_header.html !--> - <!-- Default: OFF - <module name="RegexpHeader"> - <property name="headerFile" value=""/> - <property name="charset" value=""/> - <property name="header" value=""/> - <property name="multiLines" value=""/> - <property name="fileExtensions" value=""/> + <module name="EmptyBlock"> + <property name="tokens" value="LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF, LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT, STATIC_INIT"/> </module> - !--> - - <!-- - !________________________________________________________________________________________ - ! - ! J A V A D O C S - !________________________________________________________________________________________ - !--> - <!-- Checks that each Java package has a Javadoc file used for commenting. !--> - <!-- See http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage !--> - <!-- KIEKER: OFF - <module name="JavadocPackage"> - <property name="severity" value="info"/> - <property name="allowLegacy" value="false"/> + <module name="LeftCurly"> + <property name="maxLineLength" value="165"/> + <property name="tokens" value="CLASS_DEF, CTOR_DEF, INTERFACE_DEF, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, METHOD_DEF"/> </module> - !--> - - <!-- - !________________________________________________________________________________________ - ! - ! R E G E X P - !________________________________________________________________________________________ - !--> - <!-- A check for detecting that matches across multiple lines. Works with any file type. !--> - <!-- See http://checkstyle.sourceforge.net/config_regexp.html#RegexpMultiline !--> - <!-- Default: OFF - <module name="RegexpMultiline"> - <property name="format" value=""/> - <property name="message" value=""/> - <property name="ignoreCase" value="false"/> - <property name="minimum" value="0"/> - <property name="maximum" value="0"/> - <property name="fileExtensions" value=""/> + <module name="NeedBraces"> + <property name="tokens" value="LITERAL_DO, LITERAL_ELSE, LITERAL_IF, LITERAL_FOR, LITERAL_WHILE"/> </module> - !--> - - <!-- A check for detecting single lines that match a supplied regular expression. Works with any file type. !--> - <!-- See http://checkstyle.sourceforge.net/config_regexp.html#RegexpSingleline !--> - <!-- Default: OFF - <module name="RegexpSingleline"> - <property name="format" value=""/> - <property name="message" value=""/> - <property name="ignoreCase" value="false"/> - <property name="minimum" value="0"/> - <property name="maximum" value="0"/> - <property name="fileExtensions" value=""/> + <module name="RightCurly"> + <property name="tokens" value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE"/> </module> - !--> - - <!-- - !________________________________________________________________________________________ - ! - ! M I S C E L L A N E O U S - !________________________________________________________________________________________ - !--> - <!-- Checks whether files end with a new line. !--> - <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile !--> - <module name="NewlineAtEndOfFile"> - <property name="lineSeparator" value="system"/> - <property name="fileExtensions" value="*.*"/> + <module name="FinalClass"/> + <module name="HideUtilityClassConstructor"/> + <module name="InnerTypeLast"/> + <module name="InterfaceIsType"/> + <module name="MutableException"/> + <module name="VisibilityModifier"> + <property name="protectedAllowed" value="true"/> + <property name="publicMemberPattern" value="^serialVersionUID$"/> </module> - - <!-- Checks that property files contain the same keys. !--> - <!-- See http://checkstyle.sf.net/config_misc.html#Translation !--> - <module name="Translation"> - <property name="fileExtensions" value="properties"/> + <module name="ArrayTrailingComma"/> + <module name="AvoidInlineConditionals"> + <property name="severity" value="ignore"/> + <metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/> </module> - - - <!-- - !________________________________________________________________________________________ - ! - ! S I Z E V I O L A T I O N S - !________________________________________________________________________________________ - !--> - <!-- Checks for long source files. !--> - <!-- See http://checkstyle.sf.net/config_sizes.html !--> - <module name="FileLength"> - <property name="max" value="2000"/> - <property name="fileExtensions" value=""/> + <module name="CovariantEquals"/> + <module name="DeclarationOrder"/> + <module name="DefaultComesLast"/> + <module name="EmptyStatement"/> + <module name="EqualsAvoidNull"/> + <module name="EqualsHashCode"/> + <module name="FallThrough"> + <property name="reliefPattern" value="fallthru|falls??through"/> </module> - - - <!-- - !________________________________________________________________________________________ - ! - ! W H I T E S P A C E - !________________________________________________________________________________________ - !--> - <!-- Checks that there are no tab characters ('\t') in the source code. !--> - <!-- See http://checkstyle.sourceforge.net/config_whitespace.html#FileTabCharacter !--> - <!-- KIEKER we use TABs - <module name="FileTabCharacter"> - <property name="eachLine" value="false"/> - <property name="fileExtensions" value=""/> + <module name="FinalLocalVariable"/> + <module name="HiddenField"> + <property name="tokens" value="PARAMETER_DEF, VARIABLE_DEF"/> + <property name="ignoreConstructorParameter" value="true"/> + <property name="ignoreSetter" value="true"/> </module> - --> - - <module name="TreeWalker"> - <!-- KIEKER --> - <property name="tabWidth" value="4"/> - <module name="FileContentsHolder"/> - - <!-- - !________________________________________________________________________________________ - ! - ! A N N O T A T I O N S - !________________________________________________________________________________________ - !--> - <!-- This check controls the usage style of annotations. !--> - <!-- See http://checkstyle.sourceforge.net/config_annotation.html#AnnotationUseStyle !--> - <module name ="AnnotationUseStyle"> - <property name="elementStyle" value="compact_no_array"/> - <property name="closingParens" value="never"/> - <property name="trailingArrayComma" value="never"/> - </module> - - <!-- Verifies that both the java.lang.Deprecated import is present and the @deprecated Javadoc tag is present when either is present. !--> - <!-- See http://checkstyle.sourceforge.net/config_annotation.html#MissingDeprecated !--> - <!-- KIEKER --> - <module name="MissingDeprecated"> - <property name="severity" value="info"/> - </module> - - <!-- Verifies that the java.lang.Override annotation is present when the {@inheritDoc} javadoc tag is present. !--> - <!-- See http://checkstyle.sourceforge.net/config_annotation.html#MissingOverride !--> - <!-- problems with Java 1.5 - <module name="MissingOverride"> - <property name="javaFiveCompatibility" value="false"/> - </module> - --> - - <!-- This check makes sure that all package annotations are in the package-info.java file. !--> - <!-- See http://checkstyle.sourceforge.net/config_annotation.html#PackageAnnotation !--> - <module name="PackageAnnotation"/> - - <!-- This check allows you to specify what warnings that SuppressWarnings is not allowed to suppress. !--> - <!-- You can also specify a list of TokenTypes that the configured warning(s) cannot be suppressed on. !--> - <!-- See http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarnings !--> - <module name="SuppressWarnings"> - <property name="format" value="^$|^\s+$"/> - <property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, - ANNOTATION_FIELD_DEF, ENUM_CONSTANT_DEF, PARAMETER_DEF, - VARIABLE_DEF, METHOD_DEF, CTOR_DEF"/> - </module> - - - <!-- - !________________________________________________________________________________________ - ! - ! B L O C K S - !________________________________________________________________________________________ - !--> - <!-- Finds nested blocks, i.e. blocks that are used freely in the code. !--> - <!-- See http://checkstyle.sf.net/config_blocks.html !--> - <!-- KIEKER allowInSwitchCase !--> - <module name="AvoidNestedBlocks"> - <property name="allowInSwitchCase" value="true"/> - </module> - - <!-- Checks for empty blocks. !--> - <!-- See http://checkstyle.sf.net/config_blocks.html !--> - <!-- KIEKER removed LITERAL_CATCH !--> - <module name="EmptyBlock"> - <property name="option" value="stmt"/> - <property name="tokens" value="LITERAL_DO, - LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF, LITERAL_FOR, - LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT, STATIC_INIT"/> - </module> - - <!-- Checks for the placement of left curly braces ('{') for code blocks. !--> - <!-- See http://checkstyle.sf.net/config_blocks.html !--> - <module name="LeftCurly"> - <property name="option" value="eol"/> - <property name="maxLineLength" value="165"/> - <property name="tokens" value="CLASS_DEF, CTOR_DEF, - INTERFACE_DEF, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, - LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_SWITCH, - LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, - METHOD_DEF"/> - </module> - - <!-- Checks for braces around code blocks. !--> - <!-- See http://checkstyle.sf.net/config_blocks.html !--> - <module name="NeedBraces"> - <property name="tokens" value="LITERAL_DO, LITERAL_ELSE, LITERAL_IF, LITERAL_FOR, LITERAL_WHILE"/> - </module> - - <!-- Checks the placement of right curly braces ('}') for else, try, and catch tokens. !--> - <!-- See http://checkstyle.sf.net/config_blocks.html !--> - <module name="RightCurly"> - <property name="option" value="same"/> - <property name="tokens" value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE"/> - <property name="shouldStartLine" value="true"/> - </module> - - - <!-- - !________________________________________________________________________________________ - ! - ! C L A S S D E S I G N - !________________________________________________________________________________________ - !--> - <!-- Checks that classes are designed for extension. !--> - <!-- See http://checkstyle.sf.net/config_design.html !--> - <!-- Default: OFF - <module name="DesignForExtension"/> - !--> - - <!-- Checks that a class which has only private constructors is declared as final. !--> - <!-- See http://checkstyle.sf.net/config_design.html !--> - <module name="FinalClass"/> - - <!-- Make sure that utility classes (classes that contain only static methods) do not have a public constructor. !--> - <!-- See http://checkstyle.sf.net/config_design.html !--> - <module name="HideUtilityClassConstructor"/> - - <!-- Check nested (internal) classes/interfaces are declared at the bottom of the class after all method and field declarations. !--> - <!-- See http://checkstyle.sourceforge.net/config_design.html#InnerTypeLast !--> - <module name="InnerTypeLast"/> - - <!-- Implements Bloch, Effective Java, Item 17 - Use Interfaces only to define types. !--> - <!-- See http://checkstyle.sf.net/config_design.html !--> - <module name="InterfaceIsType"> - <property name="allowMarkerInterfaces" value="true"/> - </module> - - <!-- Ensures that exceptions (defined as any class name conforming to some regular expression) are immutable. !--> - <!-- That is, have only final fields. !--> - <!-- See http://checkstyle.sf.net/config_design.html !--> - <module name="MutableException"> - <property name="format" value="^.*Exception$|^.*Error$"/> - </module> - - <!-- Restricts throws statements to a specified count. !--> - <!-- See http://checkstyle.sf.net/config_design.html !--> - <!-- KIEKER off - <module name="ThrowsCount"> - <property name="max" value="1"/> - </module> - !--> - - <!-- Checks visibility of class members. !--> - <!-- See http://checkstyle.sf.net/config_design.html !--> - <module name="VisibilityModifier"> - <property name="packageAllowed" value="false"/> - <property name="protectedAllowed" value="true"/> - <property name="publicMemberPattern" value="^serialVersionUID$"/> - </module> - - - <!-- - !________________________________________________________________________________________ - ! - ! C O D I N G - !________________________________________________________________________________________ - !--> - <!-- Checks that array initialization contains a trailing comma. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="ArrayTrailingComma"/> - - <!-- Detects inline conditionals. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="AvoidInlineConditionals"/> - - <!-- Checks that classes that define a covariant equals() method also override method equals(java.lang.Object). !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="CovariantEquals"/> - - <!-- Checks declaration order according to Code Conventions for the Java Programming Language. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="DeclarationOrder"> - <property name="ignoreConstructors" value="false"/> - <property name="ignoreMethods" value="false"/> - <property name="ignoreModifiers" value="false"/> - </module> - - <!-- Check that the default is after all the cases in a switch statement. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="DefaultComesLast"/> - - <!-- Detects empty statements (standalone ;). !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="EmptyStatement"/> - - <!-- Checks that any combination of String literals with optional assignment is on the left side of an equals() comparison. !--> - <!-- See http://checkstyle.sourceforge.net/config_coding.html#EqualsAvoidNull !--> - <module name="EqualsAvoidNull"/> - - <!-- Checks that classes that override equals() also override hashCode(). !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="EqualsHashCode"/> - - <!-- Checks if any class or object member explicitly initialized to default for its type value. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <!-- KIEKER off - <module name="ExplicitInitialization"/> - !--> - - <!-- Checks for fall through in switch statements Finds locations where a case contains Java code ... !--> - <!-- but lacks a break, return, throw or continue statement. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="FallThrough"> - <property name="checkLastCaseGroup" value="false"/> - <property name="reliefPattern" value="fallthru|falls??through"/> - </module> - - <!-- Checks that local variables that never have their values changed are declared final. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="FinalLocalVariable"> - <property name="tokens" value="VARIABLE_DEF"/> - </module> - - <!-- Checks that a local variable or a parameter does not shadow a field that is defined in the same class. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <!-- KIEKER ignoreConstructorParameter, ignoreSetter --> - <module name="HiddenField"> - <property name="tokens" value="PARAMETER_DEF, VARIABLE_DEF"/> - <!-- - <property name="ignoreFormat" value=""/> - !--> - <property name="ignoreConstructorParameter" value="true"/> - <property name="ignoreSetter" value="true"/> - <property name="ignoreAbstractMethods" value="false"/> - </module> - - <!-- Catching java.lang.Exception, java.lang.Error or java.lang.RuntimeException is almost never acceptable. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="IllegalCatch"> - <property name="illegalClassNames" value="java.lang.Exception, java.lang.Throwable, java.lang.RuntimeException"/> - </module> - - <!-- Checks for illegal instantiations where a factory method is preferred. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <!-- KIEKER on for ??? !--> - <module name="IllegalInstantiation"> - <property name="classes" value="java.lang.Boolean"/> - </module> - - <!-- This check can be used to ensure that types are not declared to be thrown. !--> - <!-- Declaring to throw java.lang.Error or java.lang.RuntimeException is almost never acceptable. !--> - <!-- See http://checkstyle.sourceforge.net/config_coding.html#IllegalThrows !--> - <module name="IllegalThrows"> - <property name="illegalClassNames" value="java.lang.Throwable, java.lang.Error, java.lang.RuntimeException"/> - </module> - - <!-- Checks for illegal tokens. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <!-- KIEKER off - <module name="IllegalToken"> - <property name="tokens" value="LITERAL_SWITCH, POST_INC, POST_DEC"/> - </module> - !--> - - <!-- Checks for illegal token text. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <!-- Default: OFF - <module name="IllegalTokenText"> - <property name="tokens" value=""/> - <property name="format" value=""/> - <property name="ignoreCase" value="false"/> - <property name="message" value=""/> - </module> - !--> - - <!-- Checks that particular classes are never used as types in variable declarations, return values or parameters. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <!-- KIEKER removed format value="^(.*[\\.])?Abstract.*$" !--> - <module name="IllegalType"> - <property name="tokens" value="PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF"/> - <property name="illegalClassNames" value="java.util.GregorianCalendar, java.util.Hashtable, - java.util.HashSet, java.util.HashMap, java.util.ArrayList, - java.util.LinkedList, java.util.LinkedHashMap, - java.util.LinkedHashSet, java.util.TreeSet, - java.util.TreeMap, java.util.Vector"/> - <property name="legalAbstractClassNames" value=""/> - <property name="ignoredMethodNames" value="getInitialContext, getEnvironment"/> - <property name="format" value="XXX"/> - </module> - - <!-- Checks for assignments in subexpressions, such as in String s = Integer.toString(i = 2);. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="InnerAssignment"> - <property name="tokens" value="ASSIGN, BAND_ASSIGN, BOR_ASSIGN, BSR_ASSIGN, BXOR_ASSIGN, - DIV_ASSIGN, MINUS_ASSIGN, MOD_ASSIGN, PLUS_ASSIGN, SL_ASSIGN, - SR_ASSIGN, STAR_ASSIGN"/> - </module> - - <!-- Ensures that the setUp(), tearDown()methods are named correctly, have no arguments, !--> - <!-- return void and are either public or protected. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="JUnitTestCase"/> - - <!-- Checks that there are no "magic numbers", where a magic number is a numeric literal !--> - <!-- that is not defined as a constant. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <!-- deactivated for Kieker - <module name="MagicNumber"> - <property name="tokens" value="NUM_DOUBLE, NUM_FLOAT, NUM_INT, NUM_LONG"/> - <property name="ignoreNumbers" value="-1, 0, 1, 2"/> - <property name="ignoreHashCodeMethod" value="false"/> - </module> - !--> - - <!-- Checks that classes (except abtract one) define a ctor and don't rely on the default one. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="MissingCtor"/> - - <!-- Checks that switch statement has "default" clause. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="MissingSwitchDefault"/> - - <!-- Check for ensuring that for loop control variables are not modified inside the for block. !--> - <!-- See http://checkstyle.sourceforge.net/config_coding.html#ModifiedControlVariable !--> - <module name="ModifiedControlVariable"/> - - <!-- Checks for multiple occurrences of the same string literal within a single file. !--> - <!-- See http://checkstyle.sourceforge.net/config_coding.html#MultipleStringLiterals !--> - <!-- KIEKER off for now - <module name="MultipleStringLiterals"> - <property name="allowedDuplicates" value="1"/> - <property name="ignoreStringsRegexp" value='^""$'/> - <property name="ignoreOccurrenceContext" value="ANNOTATION"/> - </module> - !--> - - <!-- Checks that each variable declaration is in its own statement and on its own line. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="MultipleVariableDeclarations"/> - - <!-- Restricts nested for blocks to a specified depth. !--> - <!-- See http://checkstyle.sourceforge.net/config_coding.html#NestedForDepth !--> - <module name="NestedForDepth"> - <property name="max" value="2"/> - </module> - - <!-- Restricts nested if-else blocks to a specified depth. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="NestedIfDepth"> - <property name="max" value="3"/> - </module> - - <!-- Restricts nested try-catch blocks to a specified depth. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="NestedTryDepth"> - <property name="max" value="1"/> - </module> - - <!-- Checks that the clone method is not overridden from the Object class. !--> - <!-- See http://checkstyle.sourceforge.net/config_coding.html#NoClone !--> - <module name="NoClone"/> - - <!-- Verifies there are no finalize() methods defined in a class. !--> - <!-- See http://checkstyle.sourceforge.net/config_coding.html#NoFinalizer !--> - <module name="NoFinalizer"/> - - <!-- Checks there is only one statement per line. !--> - <!-- See http://checkstyle.sourceforge.net/config_coding.html#OneStatementPerLine !--> - <module name="OneStatementPerLine"/> - - <!-- Ensure a class has a package declaration. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="PackageDeclaration"> - <property name="ignoreDirectoryName" value="false"/> - </module> - - <!-- Disallow assignment of parameters. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="ParameterAssignment"/> - - <!-- Checks for redundant exceptions declared in throws clause such as duplicates, !--> - <!-- unchecked exceptions or subclasses of another declared exception. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="RedundantThrows"> - <property name="allowUnchecked" value="true"/> - <property name="allowSubclasses" value="false"/> - <property name="logLoadErrors" value="true"/> - <property name="suppressLoadErrors" value="false"/> - </module> - - <!-- Checks that code doesn't rely on the "this." default. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="RequireThis"> - <property name="checkFields" value="true"/> - <property name="checkMethods" value="true"/> - </module> - - <!-- Restrict the number of return statements. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="ReturnCount"> - <property name="max" value="2"/> - <property name="format" value=""/> - </module> - - <!-- Checks for overly complicated boolean expressions. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="SimplifyBooleanExpression"/> - - <!-- Checks for overly complicated boolean return statements. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="SimplifyBooleanReturn"/> - - <!-- Checks that string literals are not used with == or !=. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="StringLiteralEquality"/> - - <!-- Checks that an overriding clone() method invokes super.clone(). !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="SuperClone"/> - - <!-- Checks that an overriding finalize() method invokes super.finalize(). !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="SuperFinalize"/> - - <!-- Checks for the use of unnecessary parentheses. !--> - <!-- See http://checkstyle.sf.net/config_coding.html !--> - <module name="UnnecessaryParentheses"/> - - - <!-- - !________________________________________________________________________________________ - ! - ! I M P O R T S - !________________________________________________________________________________________ - !--> - <!-- Checks that there are no import statements that use the * notation. !--> - <!-- See http://checkstyle.sf.net/config_import.html !--> - <module name="AvoidStarImport"> - <property name="excludes" value=""/> - <property name="allowClassImports" value="false"/> - <property name="allowStaticMemberImports" value="false"/> - </module> - - <!-- Checks that there are no static import statements. !--> - <!-- See http://checkstyle.sourceforge.net/config_imports.html#AvoidStaticImport !--> - <module name="AvoidStaticImport"> - <property name="excludes" value=""/> - </module> - - <!-- Checks for imports from a set of illegal packages. !--> - <!-- See http://checkstyle.sf.net/config_import.html !--> - <module name="IllegalImport"> - <property name="illegalPkgs" value="sun"/> - <property name="illegalPkgs" value="org.apache.commons.logging"/> - </module> - - <!-- Controls what can be imported in each package. Useful for ensuring that application layering rules !--> - <!-- are not violated, especially on large projects. !--> - <!-- See http://checkstyle.sourceforge.net/config_imports.html#ImportControl !--> - <!-- Default: OFF - <module name="ImportControl"> - <property name="file" value=""/> - <property name="url" value=""/> - </module> - !--> - - <!-- Checks the ordering/grouping of imports. !--> - <!-- See http://checkstyle.sf.net/config_import.html !--> - <module name="ImportOrder"> - <property name="option" value="under"/> - <property name="groups" value="java,javax,junit,org,com,kieker,org.primefaces,org.eclipse"/> - <property name="ordered" value="true"/> - <property name="separated" value="true"/> - <property name="caseSensitive" value="true"/> - </module> - - <!-- Checks for redundant import statements. !--> - <!-- See http://checkstyle.sf.net/config_import.html !--> - <module name="RedundantImport"/> - - <!-- Checks for unused import statements. !--> - <!-- See http://checkstyle.sf.net/config_import.html !--> - <module name="UnusedImports"/> - - - <!-- - !________________________________________________________________________________________ - ! - ! J A V A D O C S - !________________________________________________________________________________________ - !--> - <!-- Checks to ensure that the javadoc tags exist (if required) !--> - <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocMethod !--> - <module name="JavadocMethod"> - <property name="severity" value="info"/> - <property name="scope" value="private"/> - <!-- - <property name="excludeScope" value=""/> - !--> - <property name="allowUndeclaredRTE" value="false"/> - <property name="allowThrowsTagsForSubclasses" value="false"/> - <property name="allowMissingParamTags" value="false"/> - <property name="allowMissingThrowsTags" value="false"/> - <property name="allowMissingReturnTag" value="false"/> - <property name="allowMissingJavadoc" value="false"/> - <property name="allowMissingPropertyJavadoc" value="false"/> - <property name="logLoadErrors" value="true"/> - <property name="suppressLoadErrors" value="false"/> - <property name="tokens" value="METHOD_DEF, CTOR_DEF"/> - </module> - - <!-- Validates Javadoc comments to help ensure they are well formed. !--> - <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocStyle !--> - <module name="JavadocStyle"> - <property name="severity" value="info"/> - <property name="scope" value="private"/> - <!-- - <property name="excludeScope" value=""/> - !--> - <property name="checkFirstSentence" value="true"/> -<!--TODO: <property name="endOfSentenceFormat" value="([.?!][ \t\n\r\f<])|([.?!]$)"/> !--> - <property name="checkEmptyJavadoc" value="false"/> - <property name="checkHtml" value="true"/> - <property name="tokens" value="INTERFACE_DEF, CLASS_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/> - </module> - - <!-- Checks Javadoc comments for class and interface definitions. !--> - <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocType !--> - <module name="JavadocType"> - <property name="severity" value="info"/> - <property name="scope" value="private"/> - <!-- - <property name="excludeScope" value=""/> - !--> - <property name="authorFormat" value=""/> - <!--<property name="versionFormat" value=""/>!--> - <property name="allowMissingParamTags" value="false"/> - <property name="allowUnknownTags" value="false"/> - <property name="tokens" value="INTERFACE_DEF, CLASS_DEF"/> - </module> - - <module name="JavadocType"> - <property name="severity" value="warning"/> - <property name="scope" value="package"/> - <property name="authorFormat" value="\S"/> - </module> - - <!-- Checks that variables have Javadoc comments. !--> - <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocVariable !--> - <module name="JavadocVariable"> - <property name="severity" value="info"/> - <property name="scope" value="package"/> - <!-- - <property name="excludeScope" value=""/> - !--> - </module> - - <!-- Outputs a JavaDoc tag as information. !--> - <!-- See http://checkstyle.sourceforge.net/config_javadoc.html#WriteTag !--> - <!-- KIEKER - <module name="WriteTag"> - <property name="severity" value="info"/> - <property name="tag" value=""/> - <property name="tagFormat" value=""/> - <property name="tagSeverity" value="info"/> - </module> - --> - - - <!-- - !________________________________________________________________________________________ - ! - ! M E T R I C S - !________________________________________________________________________________________ - !--> - <!-- Restrict the number of number of &&, || and ^ in an expression. !--> - <!-- See http://checkstyle.sf.net/config_metrics.html !--> - <module name="BooleanExpressionComplexity"> - <property name="severity" value="info"/> - <property name="max" value="3"/> - <property name="tokens" value="LAND, BAND, LOR, BOR, BXOR"/> - </module> - - <!-- Checks cyclomatic complexity against a specified limit. !--> - <!-- See http://checkstyle.sf.net/config_metrics.html !--> - <module name="CyclomaticComplexity"> - <property name="severity" value="info"/> - <property name="max" value="10"/> - </module> - - <!-- Determines complexity of methods, classes and files by counting the Non Commenting Source Statements (NCSS). !--> - <!-- See http://checkstyle.sourceforge.net/config_metrics.html#JavaNCSS !--> - <module name="JavaNCSS"> - <property name="severity" value="info"/> - <property name="methodMaximum" value="50"/> - <property name="classMaximum" value="1500"/> - <property name="fileMaximum" value="2000"/> - </module> - - <!-- The NPATH metric computes the number of possible execution paths through a function. !--> - <!-- See http://checkstyle.sf.net/config_metrics.html !--> - <module name="NPathComplexity"> - <property name="severity" value="info"/> - <property name="max" value="200"/> - </module> - - - <!-- - !________________________________________________________________________________________ - ! - ! M I S C E L L A N E O U S - !________________________________________________________________________________________ - !--> - <!-- Checks the style of array type definitions. !--> - <!-- See http://checkstyle.sf.net/config_misc.html !--> - <module name="ArrayTypeStyle"> - <property name="javaStyle" value="true"/> - </module> - - <!-- Checks for restricted tokens beneath other tokens. !--> - <!-- See http://checkstyle.sf.net/config_misc.html !--> - <!-- Default: OFF - <module name="DescendantToken"> - <property name="tokens" value=""/> - <property name="limitedTokens" value=""/> - <property name="minimumDepth" value="0"/> - <property name="maximumDepth" value="java.lang.Integer.MAX_VALUE"/> - <property name="minimumNumber" value="0"/> - <property name="maximumNumber" value="java.lang.Integer.MAX_VALUE"/> - <property name="sumTokenCounts" value="false"/> - <property name="minimumMessage" value="descendant.token.min"/> - <property name="maximumMessage" value="descendant.token.max"/> - </module> - !--> - - <!-- Check that method/constructor parameters are final. !--> - <!-- See http://checkstyle.sf.net/config_misc.html !--> - <module name="FinalParameters"> - <property name="tokens" value="METHOD_DEF, CTOR_DEF"/> - </module> - - <!-- A generic check for code problems - the user can search for any pattern. !--> - <!-- See http://checkstyle.sf.net/config_misc.html !--> - <!-- Default: OFF - <module name="GenericIllegalRegexp"> - <property name="format" value="\S\s+$"/> - <property name="message" value="Line has trailing spaces."/> - <property name="ignoreCase" value="false"/> - <property name="ignoreComments" value="false"/> - </module> - !--> - - <!-- Checks correct indentation of Java Code. !--> - <!-- See http://checkstyle.sf.net/config_misc.html !--> - <!-- KIEKER --> - <module name="Indentation"> - <property name="severity" value="info"/> - <property name="basicOffset" value="4"/> - <property name="braceAdjustment" value="0"/> - <property name="caseIndent" value="0"/> - </module> - - <!-- Checks that the outer type name and the file name match. !--> - <!-- See http://checkstyle.sourceforge.net/config_misc.html#OuterTypeFilename !--> - <module name="OuterTypeFilename"/> - - <!-- A check for TODO: comments. Actually it is a generic regular expression matcher on Java comments. !--> - <!-- See http://checkstyle.sf.net/config_misc.html !--> - <!-- Kieker !--> - <module name="TodoComment"> - <property name="format" value="TODO"/> - </module> - - <!-- The check to ensure that requires that comments be the only thing on a line. !--> - <!-- See http://checkstyle.sf.net/config_misc.html !--> - <!-- KIEKER we use them - <module name="TrailingComment"> - <property name="format" value="^[\\s\\}\\);]*$"/> - <property name="legalComment" value=""/> - </module> - --> - - <!-- Checks for uncommented main() methods (debugging leftovers). !--> - <!-- See http://checkstyle.sf.net/config_misc.html !--> - <module name="UncommentedMain"> - <property name="severity" value="info"/> - <property name="excludedClasses" value="Main$"/> - </module> - - <!-- Checks that long constants are defined with an upper ell. That is 'L' and not 'l'. !--> - <!-- See http://checkstyle.sf.net/config_misc.html !--> - <module name="UpperEll"/> - - - <!-- - !________________________________________________________________________________________ - ! - ! M O D I F I E R S - !________________________________________________________________________________________ - !--> - <!-- Checks that the order of modifiers conforms to the suggestions in the Java Language specification, !--> - <!-- sections 8.1.1, 8.3.1 and 8.4.3. !--> - <!-- See http://checkstyle.sf.net/config_modifiers.html !--> - <module name="ModifierOrder"/> - - <!-- Checks that there are no redundant modifiers. !--> - <!-- See http://checkstyle.sf.net/config_modifiers.html !--> - <!-- KIEKER off - <module name="RedundantModifier"> - <property name="tokens" value="METHOD_DEF, VARIABLE_DEF, ANNOTATION_FIELD_DEF"/> - </module> - !--> - - <!-- - !________________________________________________________________________________________ - ! - ! N A M I N G C O N V E N T I O N S - !________________________________________________________________________________________ - !--> - <!-- Checks for abstract class name naming conventions. !--> - <!-- See http://checkstyle.sf.net/config_naming.html !--> - <!-- KIEKER removed |^.*Factory$ --> - <module name="AbstractClassName"> - <property name="format" value="^Abstract.*$"/> - <property name="ignoreModifier" value="false"/> - <property name="ignoreName" value="false"/> - </module> - - <!-- Checks for class type parameter name naming conventions. !--> - <!-- See http://checkstyle.sourceforge.net/config_naming.html#ClassTypeParameterName !--> - <module name="ClassTypeParameterName"> - <property name="format" value="^[A-Z]$"/> - </module> - - <!-- Checks for constant name naming conventions. !--> - <!-- See http://checkstyle.sf.net/config_naming.html !--> - <module name="ConstantName"> - <property name="format" value="^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/> - <property name="applyToPublic" value="true"/> - <property name="applyToProtected" value="true"/> - <property name="applyToPackage" value="true"/> - <property name="applyToPrivate" value="true"/> - </module> - - <!-- Checks for local final variable name naming conventions. !--> - <!-- See http://checkstyle.sf.net/config_naming.html !--> - <module name="LocalFinalVariableName"> - <property name="format" value="^[a-z][a-zA-Z0-9]*$"/> - <property name="tokens" value="VARIABLE_DEF, PARAMETER_DEF"/> - </module> - - <!-- Checks for local variable name naming conventions. !--> - <!-- See http://checkstyle.sf.net/config_naming.html !--> - <module name="LocalVariableName"> - <property name="format" value="^[a-z][a-zA-Z0-9]*$"/> - <property name="tokens" value="PARAMETER_DEF"/> - </module> - - <!-- Checks for member variable name naming conventions. !--> - <!-- See http://checkstyle.sf.net/config_naming.html !--> - <module name="MemberName"> - <property name="format" value="^[a-z][a-zA-Z0-9]*$"/> - <property name="applyToPublic" value="true"/> - <property name="applyToProtected" value="true"/> - <property name="applyToPackage" value="true"/> - <property name="applyToPrivate" value="true"/> - </module> - - <!-- Checks for method name naming conventions. !--> - <!-- See http://checkstyle.sf.net/config_naming.html !--> - <module name="MethodName"> - <property name="format" value="^[a-z][a-zA-Z0-9]*$"/> - </module> - - <!-- Checks for method type parameter name naming conventions. !--> - <!-- See http://checkstyle.sourceforge.net/config_naming.html#MethodTypeParameterName !--> - <module name="MethodTypeParameterName"> - <property name="format" value="^[A-Z]$"/> - </module> - - <!-- Checks for package name naming conventions. !--> - <!-- See http://checkstyle.sf.net/config_naming.html !--> - <module name="PackageName"> - <property name="format" value="^[a-z]+(\.[a-zA-Z_][a-zA-Z0-9_]*)*$"/> - </module> - - <!-- Checks for parameter name naming conventions. !--> - <!-- See http://checkstyle.sf.net/config_naming.html !--> - <module name="ParameterName"> - <property name="format" value="^[a-z][a-zA-Z0-9]*$"/> - </module> - - <!-- Checks for static variable name naming conventions. !--> - <!-- See http://checkstyle.sf.net/config_naming.html !--> - <module name="StaticVariableName"> - <property name="format" value="^[a-z][a-zA-Z0-9]*$"/> - <property name="applyToPublic" value="true"/> - <property name="applyToProtected" value="true"/> - <property name="applyToPackage" value="true"/> - <property name="applyToPrivate" value="true"/> - </module> - - <!-- Checks for type name naming conventions. !--> - <!-- See http://checkstyle.sf.net/config_naming.html !--> - <!-- KIEKER: modded --> - <module name="TypeName"> - <property name="format" value="^[A-Z][a-zA-Z0-9]*$"/> - <property name="tokens" value="CLASS_DEF"/> - <property name="applyToPublic" value="true"/> - <property name="applyToProtected" value="true"/> - <property name="applyToPackage" value="true"/> - <property name="applyToPrivate" value="true"/> - </module> - - <module name="TypeName"> - <property name="format" value="^I[A-Z][a-zA-Z0-9]*$"/> - <property name="tokens" value="INTERFACE_DEF"/> - <property name="applyToPublic" value="true"/> - <property name="applyToProtected" value="true"/> - <property name="applyToPackage" value="true"/> - <property name="applyToPrivate" value="true"/> - </module> - - - <!-- - !________________________________________________________________________________________ - ! - ! R E G E X P - !________________________________________________________________________________________ - !--> - <!-- A check that makes sure that a specified pattern exists, exists less than a set number of times, !--> - <!-- or does not exist in the file. !--> - <!-- See http://checkstyle.sourceforge.net/config_misc.html#Regexp !--> - <!-- Default: OFF - <module name="Regexp"> - <property name="format" value=""/> - <property name="message" value=""/> - <property name="illegalPattern" value="false"/> - <property name="duplicateLimit" value="-1"/> - <property name="errorLimit" value="100"/> - <property name="ignoreComments" value="false"/> - </module> - !--> - - <!-- This class is variation on RegexpSingleline for detecting single lines that match a !--> - <!-- supplied regular expression in Java files. It supports suppressing matches in Java comments. !--> - <!-- See http://checkstyle.sourceforge.net/config_regexp.html#RegexpSinglelineJava !--> - <!-- Default: OFF - <module name="RegexpSinglelineJava"> - <property name="format" value=""/> - <property name="message" value=""/> - <property name="ignoreCase" value="false"/> - <property name="minimum" value="0"/> - <property name="maximum" value="0"/> - <property name="ignoreComments" value="false"/> - </module> - !--> - - <!-- - !________________________________________________________________________________________ - ! - ! S I Z E V I O L A T I O N S - !________________________________________________________________________________________ - !--> - <!-- Checks for long anonymous inner classes. !--> - <!-- See http://checkstyle.sf.net/config_sizes.html !--> - <module name="AnonInnerLength"> - <property name="severity" value="info"/> - <property name="max" value="20"/> - </module> - - <!-- Restricts the number of executable statements to a specified limit. !--> - <!-- See http://checkstyle.sf.net/config_sizes.html !--> - <!-- KIEKER off - <module name="ExecutableStatementCount"> - <property name="severity" value="info"/> - <property name="max" value="30"/> - <property name="tokens" value="CTOR_DEF, METHOD_DEF, INSTANCE_INIT, STATIC_INIT"/> - </module> - !--> - - <!-- See http://checkstyle.sf.net/config_sizes.html !--> - <!-- Checks for long lines. !--> - <module name="LineLength"> - <property name="severity" value="info"/> - <property name="ignorePattern" value="^$"/> - <property name="max" value="165"/> - </module> - - <!-- Checks the number of methods declared in each type. This includes the number of each scope !--> - <!-- (private, package, protected and public) as well as an overall total. !--> - <!-- See http://checkstyle.sourceforge.net/config_sizes.html#MethodCount !--> - <module name="MethodCount"> - <property name="severity" value="info"/> - <property name="maxTotal" value="100"/> - <property name="maxPrivate" value="100"/> - <property name="maxPackage" value="100"/> - <property name="maxProtected" value="100"/> - <property name="maxPublic" value="100"/> - </module> - - <!-- Checks for long methods and constructors. !--> - <!-- See http://checkstyle.sf.net/config_sizes.html !--> - <module name="MethodLength"> - <property name="severity" value="info"/> - <property name="max" value="150"/> - <property name="countEmpty" value="true"/> - <property name="tokens" value="METHOD_DEF, CTOR_DEF"/> - </module> - - <!-- Checks for the number of types declared at the outer (or root) level in a file. !--> - <!-- See http://checkstyle.sourceforge.net/config_sizes.html#OuterTypeNumber !--> - <!-- KIEKER 2 !--> - <module name="OuterTypeNumber"> - <property name="max" value="2"/> - </module> - - <!-- Checks the number of parameters of a method or constructor. !--> - <!-- See http://checkstyle.sf.net/config_sizes.html !--> - <!-- KIEKER off - <module name="ParameterNumber"> - <property name="severity" value="info"/> - <property name="max" value="7"/> - <property name="tokens" value="METHOD_DEF, CTOR_DEF"/> - </module> - !--> - - <!-- - !________________________________________________________________________________________ - ! - ! W H I T E S P A C E - !________________________________________________________________________________________ - !--> - <!-- Checks the padding of an empty for initializer. !--> - <!-- See http://checkstyle.sf.net/config_whitespace.html !--> - <module name="EmptyForInitializerPad"> - <property name="option" value="nospace"/> - </module> - - <!-- Checks the padding of an empty for iterator. !--> - <!-- See http://checkstyle.sf.net/config_whitespace.html !--> - <module name="EmptyForIteratorPad"> - <property name="option" value="nospace"/> - </module> - - <!-- Checks that the whitespace around the Generic tokens < and > is correct to the typical convention. !--> - <!-- See http://checkstyle.sourceforge.net/config_whitespace.html#GenericWhitespace !--> - <module name="GenericWhitespace"/> - - <!-- Checks the padding between the identifier of a method definition, !--> - <!-- constructor definition, method call, or constructor invocation; and the left parenthesis of the parameter list. !--> - <!-- See http://checkstyle.sf.net/config_whitespace.html !--> - <module name="MethodParamPad"> - <property name="allowLineBreaks" value="false"/> - <property name="option" value="nospace"/> - <property name="tokens" value="CTOR_DEF, LITERAL_NEW, METHOD_CALL, METHOD_DEF, SUPER_CTOR_CALL "/> - </module> - - <!-- Checks that there is no whitespace after a token. !--> - <!-- See http://checkstyle.sf.net/config_whitespace.html !--> - <!-- KIEKER removed ARRAY_INIT !--> - <module name="NoWhitespaceAfter"> - <property name="allowLineBreaks" value="true"/> - <property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS"/> - </module> - - <!-- Checks that there is no whitespace before a token. !--> - <!-- See http://checkstyle.sf.net/config_whitespace.html !--> - <module name="NoWhitespaceBefore"> - <property name="allowLineBreaks" value="false"/> - <property name="tokens" value="SEMI, POST_DEC, POST_INC"/> - </module> - - <!-- Checks the policy on how to wrap lines on operators. !--> - <!-- See http://checkstyle.sf.net/config_whitespace.html !--> - <module name="OperatorWrap"> - <property name="option" value="nl"/> - <property name="tokens" value="BAND, BOR, BSR, BXOR, COLON, DIV, - EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, - LOR, LT, MINUS, MOD, NOT_EQUAL, - PLUS, QUESTION, SL, SR, STAR"/> - </module> - - <!-- Checks the policy on the padding of parentheses. !--> - <!-- See http://checkstyle.sf.net/config_whitespace.html !--> - <module name="ParenPad"> - <property name="option" value="nospace"/> - <property name="tokens" value="CTOR_CALL, LPAREN, METHOD_CALL, RPAREN, SUPER_CTOR_CALL"/> - </module> - - <!-- Checks the policy on the padding of parentheses for typecasts. !--> - <!-- See http://checkstyle.sf.net/config_whitespace.html !--> - <module name="TypecastParenPad"> - <property name="option" value="nospace"/> - <property name="tokens" value="TYPECAST, RPAREN"/> - </module> - - <!-- Checks that a token is followed by whitespace. !--> - <!-- See http://checkstyle.sf.net/config_whitespace.html !--> - <module name="WhitespaceAfter"> - <property name="tokens" value="COMMA, SEMI, TYPECAST"/> - </module> - - <!-- Checks that a token is surrounded by whitespace. !--> - <!-- See http://checkstyle.sf.net/config_whitespace.html !--> - <module name="WhitespaceAround"> - <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, - BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, - LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, - LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, - LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, - MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, - QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN"/> - <property name="allowEmptyConstructors" value="true"/> - <property name="allowEmptyMethods" value="true"/> - </module> - + <module name="IllegalCatch"/> + <module name="IllegalInstantiation"> + <property name="classes" value="java.lang.Boolean"/> </module> - + <module name="IllegalThrows"/> + <module name="IllegalType"> + <property name="tokens" value="PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF"/> + <property name="illegalClassNames" value="java.util.GregorianCalendar, java.util.Hashtable, java.util.HashSet, java.util.HashMap, java.util.ArrayList, java.util.LinkedList, java.util.LinkedHashMap, java.util.LinkedHashSet, java.util.TreeSet, java.util.TreeMap, java.util.Vector"/> + <property name="format" value="XXX"/> + </module> + <module name="InnerAssignment"> + <property name="tokens" value="ASSIGN, BAND_ASSIGN, BOR_ASSIGN, BSR_ASSIGN, BXOR_ASSIGN, DIV_ASSIGN, MINUS_ASSIGN, MOD_ASSIGN, PLUS_ASSIGN, SL_ASSIGN, SR_ASSIGN, STAR_ASSIGN"/> + </module> + <module name="JUnitTestCase"/> + <module name="MissingCtor"/> + <module name="MissingSwitchDefault"/> + <module name="ModifiedControlVariable"/> + <module name="MultipleVariableDeclarations"/> + <module name="NestedForDepth"> + <property name="max" value="2"/> + </module> + <module name="NestedIfDepth"> + <property name="max" value="3"/> + </module> + <module name="NestedTryDepth"/> + <module name="NoClone"/> + <module name="NoFinalizer"/> + <module name="OneStatementPerLine"/> + <module name="PackageDeclaration"/> + <module name="ParameterAssignment"/> + <module name="RedundantThrows"> + <property name="allowUnchecked" value="true"/> + </module> + <module name="RequireThis"/> + <module name="ReturnCount"/> + <module name="SimplifyBooleanExpression"/> + <module name="SimplifyBooleanReturn"/> + <module name="StringLiteralEquality"/> + <module name="SuperClone"/> + <module name="SuperFinalize"/> + <module name="UnnecessaryParentheses"/> + <module name="AvoidStarImport"/> + <module name="AvoidStaticImport"/> + <module name="IllegalImport"> + <property name="illegalPkgs" value="org.apache.commons.logging"/> + </module> + <module name="ImportOrder"> + <property name="groups" value="java,javax,junit,org,com,kieker,org.primefaces,org.eclipse"/> + <property name="separated" value="true"/> + </module> + <module name="RedundantImport"/> + <module name="UnusedImports"/> + <module name="JavadocMethod"> + <property name="severity" value="info"/> + <property name="tokens" value="METHOD_DEF, CTOR_DEF"/> + </module> + <module name="JavadocStyle"> + <property name="severity" value="info"/> + <property name="tokens" value="INTERFACE_DEF, CLASS_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/> + </module> + <module name="JavadocType"> + <property name="severity" value="info"/> + <property name="tokens" value="INTERFACE_DEF, CLASS_DEF"/> + </module> + <module name="JavadocType"> + <property name="severity" value="warning"/> + <property name="scope" value="package"/> + <property name="authorFormat" value="\S"/> + </module> + <module name="JavadocVariable"> + <property name="severity" value="info"/> + <property name="scope" value="package"/> + </module> + <module name="BooleanExpressionComplexity"> + <property name="severity" value="info"/> + <property name="tokens" value="LAND, BAND, LOR, BOR, BXOR"/> + </module> + <module name="CyclomaticComplexity"> + <property name="severity" value="info"/> + </module> + <module name="JavaNCSS"> + <property name="severity" value="info"/> + </module> + <module name="NPathComplexity"> + <property name="severity" value="info"/> + </module> + <module name="ArrayTypeStyle"/> + <module name="FinalParameters"> + <property name="tokens" value="METHOD_DEF, CTOR_DEF"/> + </module> + <module name="Indentation"> + <property name="severity" value="info"/> + <property name="caseIndent" value="0"/> + </module> + <module name="OuterTypeFilename"/> + <module name="TodoComment"> + <property name="format" value="TODO"/> + </module> + <module name="UncommentedMain"> + <property name="severity" value="info"/> + <property name="excludedClasses" value="Main$"/> + </module> + <module name="UpperEll"/> + <module name="ModifierOrder"/> + <module name="AbstractClassName"> + <property name="format" value="^Abstract.*$"/> + </module> + <module name="ClassTypeParameterName"/> + <module name="ConstantName"/> + <module name="LocalFinalVariableName"/> + <module name="LocalVariableName"> + <property name="tokens" value="PARAMETER_DEF"/> + </module> + <module name="MemberName"/> + <module name="MethodName"/> + <module name="MethodTypeParameterName"/> + <module name="PackageName"/> + <module name="ParameterName"/> + <module name="StaticVariableName"/> + <module name="TypeName"> + <property name="tokens" value="CLASS_DEF"/> + </module> + <module name="TypeName"> + <property name="format" value="^I[A-Z][a-zA-Z0-9]*$"/> + <property name="tokens" value="INTERFACE_DEF"/> + </module> + <module name="AnonInnerLength"> + <property name="severity" value="info"/> + </module> + <module name="LineLength"> + <property name="severity" value="info"/> + <property name="max" value="165"/> + </module> + <module name="MethodCount"> + <property name="severity" value="info"/> + </module> + <module name="MethodLength"> + <property name="severity" value="info"/> + <property name="tokens" value="METHOD_DEF, CTOR_DEF"/> + </module> + <module name="OuterTypeNumber"> + <property name="max" value="2"/> + </module> + <module name="EmptyForInitializerPad"/> + <module name="EmptyForIteratorPad"/> + <module name="GenericWhitespace"/> + <module name="MethodParamPad"> + <property name="tokens" value="CTOR_DEF, LITERAL_NEW, METHOD_CALL, METHOD_DEF, SUPER_CTOR_CALL "/> + </module> + <module name="NoWhitespaceAfter"> + <property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS"/> + </module> + <module name="NoWhitespaceBefore"> + <property name="tokens" value="SEMI, POST_DEC, POST_INC"/> + </module> + <module name="OperatorWrap"> + <property name="tokens" value="BAND, BOR, BSR, BXOR, COLON, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR"/> + </module> + <module name="ParenPad"> + <property name="tokens" value="CTOR_CALL, LPAREN, METHOD_CALL, RPAREN, SUPER_CTOR_CALL"/> + </module> + <module name="TypecastParenPad"> + <property name="tokens" value="TYPECAST, RPAREN"/> + </module> + <module name="WhitespaceAfter"> + <property name="tokens" value="COMMA, SEMI, TYPECAST"/> + </module> + <module name="WhitespaceAround"> + <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN"/> + <property name="allowEmptyConstructors" value="true"/> + <property name="allowEmptyMethods" value="true"/> + </module> + </module> + <module name="SuppressWithNearbyCommentFilter"> + <property name="commentFormat" value="NOCS"/> + </module> + <module name="Header"> + <property name="header" value="/***************************************************************************\n * Copyright 2012 Kieker Project (http://kieker-monitoring.net)\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n"/> + <property name="ignoreLines" value="2"/> + <property name="fileExtensions" value="java"/> + </module> + <module name="NewlineAtEndOfFile"> + <property name="fileExtensions" value="*.*"/> + </module> + <module name="Translation"/> + <module name="FileLength"/> </module> diff --git a/Kieker.WebGUI/config/quality-config/fb-filter.xml b/Kieker.WebGUI/config/quality-config/fb-filter.xml index 0a7a6e1fac123c35a3453e5c8cd29b5178e1a2a9..1c7a80d428eb78b384b1b8e4a699ce61ef35140d 100644 --- a/Kieker.WebGUI/config/quality-config/fb-filter.xml +++ b/Kieker.WebGUI/config/quality-config/fb-filter.xml @@ -1,6 +1,7 @@ <FindBugsFilter> <Match> <Class name="kieker.webgui.persistence.impl.util.CloseableURLClassLoader" /> + <Bug code="DP, RI" /> </Match> <Match> diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ViewScope.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ViewScope.java index 652aa84f36dd2757f72de7c6ce5ff227b5db38f2..af0baa16eeee37b8a180d65aec6f31953d94070f 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ViewScope.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ViewScope.java @@ -29,6 +29,12 @@ import org.springframework.beans.factory.config.Scope; * @author Nils Christian Ehmke */ public class ViewScope implements Scope { + /** + * Default constructor. <b>Do not use this constructor. This bean is Spring managed.</b> + */ + public ViewScope() { + // No code necessary. + } @SuppressWarnings("rawtypes") @Override diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java index e2a5a0b0137d8e4dedaca634819309e1650f6b27..cf8cc6ec94ba1afc67a26b08ffe0a99cbec027aa 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java @@ -16,18 +16,33 @@ package kieker.webgui.domain; -import java.util.List; - +/** + * This is a domain object representing a user within the system. + * + * @author Nils Christian Ehmke + */ public class User { private String name; private String password; - private List<Role> roles; + private Role role; private boolean enabled; - public User(final String name, final String password, final List<Role> roles, final boolean enabled) { + /** + * Creates a new instance of this class. + * + * @param name + * The name of the user. + * @param password + * The password of the user. + * @param role + * The role of the user. + * @param enabled + * A flag whether the user is enabled or not. + */ + public User(final String name, final String password, final Role role, final boolean enabled) { this.name = name; - this.roles = roles; + this.role = role; this.enabled = enabled; this.password = password; } @@ -71,22 +86,22 @@ public class User { } /** - * Getter for the property {@link User#roles}. + * Getter for the property {@link User#role}. * * @return The current value of the property. */ - public List<Role> getRoles() { - return this.roles; + public Role getRole() { + return this.role; } /** - * Setter for the property {@link User#roles}. + * Setter for the property {@link User#role}. * - * @param roles + * @param role * The new value of the property. */ - public void setRoles(final List<Role> roles) { - this.roles = roles; + public void setRole(final Role role) { + this.role = role; } /** @@ -108,30 +123,68 @@ public class User { this.enabled = enabled; } + /** + * This enum represents the available roles within this systen. + * + * @author Nils Christian Ehmke + */ public static enum Role { - ROLE_GUEST(0), ROLE_USER(1), ROLE_ADMIN(2); + /** + * Represents a guest within the system. + */ + ROLE_GUEST(0), + /** + * Represents an user within the system. + */ + ROLE_USER(1), + /** + * Represents an admin within the system. + */ + ROLE_ADMIN(2); private int id; + /** + * Creates a new instance of this enum. + * + * @param id + * The id of the role. + */ private Role(final int id) { this.id = id; } + /** + * Getter for the property {@link Role#id}. + * + * @return The current value of the property. + */ public int getID() { return this.id; } + /** + * Delivers the corresponding role to the given id. if the id cannot be recognized the value {@link Role#ROLE_GUEST} will be returned. + * + * @param id + * The id to be recognized. + * @return The corresponding role. + */ public static Role fromID(final int id) { + final Role role; + if (id == 2) { - return Role.ROLE_ADMIN; + role = Role.ROLE_ADMIN; } else { if (id == 1) { - return Role.ROLE_USER; + role = Role.ROLE_USER; } else { - return Role.ROLE_GUEST; + role = Role.ROLE_GUEST; } } + + return role; } } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java index 4c5702e66723e3d7d4485d76b3e2d58b04de944e..3468746a11894fc3f3922438616fc13474416728 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java @@ -24,7 +24,6 @@ import java.util.Collection; import java.util.List; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.transaction.annotation.Transactional; import kieker.analysis.model.analysisMetaModel.MIDependency; import kieker.analysis.model.analysisMetaModel.MIProject; @@ -37,9 +36,10 @@ import kieker.webgui.common.exception.ProjectNotExistingException; import org.primefaces.model.UploadedFile; /** + * This is the interface for the data access object(s) which will access for example the file system to manage the available projects. + * * @author Nils Christian Ehmke */ -// FIXME The transactional annotations do not work yet. public interface IProjectDAO { /** @@ -53,8 +53,7 @@ public interface IProjectDAO { * @throws IOException * If something went wrong during the creation of the project. */ - @PreAuthorize("isAuthenticated()") - @Transactional + @PreAuthorize("hasAnyRole('User', 'Administrator')") public abstract void addProject(String projectName) throws ProjectAlreadyExistingException, IOException; /** @@ -72,8 +71,7 @@ public interface IProjectDAO { * @throws IOException * If something went wrong during the creation of the target-project or during the loading of the source-project. */ - @PreAuthorize("isAuthenticated()") - @Transactional + @PreAuthorize("hasAnyRole('User', 'Administrator')") public abstract void copyProject(String originalProjectName, String newProjectName) throws ProjectNotExistingException, ProjectAlreadyExistingException, IOException; @@ -89,7 +87,6 @@ public interface IProjectDAO { * If something went wrong during the opening of the project. */ @PreAuthorize("isAuthenticated()") - @Transactional public abstract MIProject openProject(String projectName) throws ProjectNotExistingException, IOException; /** @@ -108,7 +105,6 @@ public interface IProjectDAO { * If something went wrong during the opening of the project. This can also mean that the given {@link ClassAndMethodContainer} is somehow invalid. */ @PreAuthorize("isAuthenticated()") - @Transactional public abstract Object openProject(String projectName, ClassAndMethodContainer classAndMethodContainer) throws ProjectNotExistingException, IOException; /** @@ -131,8 +127,7 @@ public interface IProjectDAO { * @throws NewerProjectException * If the project on the file system is newer and the overwriteNewerProject-flag has not been set. */ - @PreAuthorize("isAuthenticated()") - @Transactional + @PreAuthorize("hasAnyRole('User', 'Administrator')") public abstract void saveProject(String projectName, MIProject project, long timeStamp, boolean overwriteNewerProject) throws ProjectNotExistingException, IOException, NewerProjectException; @@ -146,7 +141,6 @@ public interface IProjectDAO { * If a project with the given name does not exist. */ @PreAuthorize("isAuthenticated()") - @Transactional public abstract long getCurrTimeStamp(String projectName) throws ProjectNotExistingException; /** @@ -163,8 +157,7 @@ public interface IProjectDAO { * @throws LibraryAlreadyExistingException * If a library with the same name exists already. */ - @PreAuthorize("isAuthenticated()") - @Transactional + @PreAuthorize("hasAnyRole('User', 'Administrator')") public abstract void uploadLibrary(UploadedFile file, String projectName) throws ProjectNotExistingException, IOException, LibraryAlreadyExistingException; /** @@ -172,6 +165,8 @@ public interface IProjectDAO { * * @param projectName * The name of the project. + * @param requester + * The requester of the classloader. * @return A class loader for the given project. * @throws ProjectNotExistingException * If a project with the given name does not exist. @@ -179,7 +174,6 @@ public interface IProjectDAO { * If something went wrong during the initialization of the class loader. */ @PreAuthorize("isAuthenticated()") - @Transactional public ClassLoader getClassLoader(final String projectName, final Object requester) throws ProjectNotExistingException, IOException; /** @@ -192,7 +186,6 @@ public interface IProjectDAO { * If a project with the given name does not exist. */ @PreAuthorize("isAuthenticated()") - @Transactional public abstract List<String> listAllLibraries(String projectName) throws ProjectNotExistingException; /** @@ -201,7 +194,6 @@ public interface IProjectDAO { * @return A list containing all available project names. */ @PreAuthorize("isAuthenticated()") - @Transactional public abstract Collection<String> listAllProjects(); /** @@ -216,7 +208,6 @@ public interface IProjectDAO { * If the URL is for some reason invalid. */ @PreAuthorize("isAuthenticated()") - @Transactional public abstract URL getURL(MIDependency lib, String project) throws MalformedURLException; /** @@ -225,7 +216,6 @@ public interface IProjectDAO { * @return The kieker library. */ @PreAuthorize("isAuthenticated()") - @Transactional public abstract URL getKiekerURL(); /** @@ -236,7 +226,6 @@ public interface IProjectDAO { * @return The kax-file of the project. */ @PreAuthorize("isAuthenticated()") - @Transactional public abstract File getProjectFile(String projectName); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IUserDAO.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IUserDAO.java index b6236f1083b5040a49b1de9209c4a2aa5ed4ba78..a8b3881ba163e7f05866f4c8733b8b59fe4db6d5 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IUserDAO.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IUserDAO.java @@ -20,8 +20,8 @@ import java.util.List; import org.springframework.security.access.prepost.PreAuthorize; +import kieker.webgui.common.exception.DataAccessException; import kieker.webgui.domain.User; -import kieker.webgui.domain.User.Role; /** * This is the interface for the data access object(s) which will access for example a database to manage the available users. The methods within this interface are @@ -31,16 +31,51 @@ import kieker.webgui.domain.User.Role; */ public interface IUserDAO { - @PreAuthorize("hasRole('ROLE_ADMIN')") - public void addUser(final String username, final String password, final List<Role> roles); + /** + * Adds a user to the system. + * + * @param user + * The domain object used to extract the necessary data to create the user. + * @throws DataAccessException + * If it was not possible to add the user to the system. Either because a constraint was violated or because the connection to the database has + * somehow been damaged. + */ + @PreAuthorize("hasRole('Administrator')") + public void addUser(final User user) throws DataAccessException; - @PreAuthorize("hasRole('ROLE_ADMIN')") - public void removeUser(final String username); + /** + * Deletes a user from the system. + * + * @param user + * The domain object used to extract the necessary data to delete the user. + * @throws DataAccessException + * If it was not possible to delete the user. Either because a constraint was violated or because the connection to the database has somehow been + * damaged. + */ + @PreAuthorize("hasRole('Administrator')") + public void deleteUser(final User user) throws DataAccessException; - @PreAuthorize("hasRole('ROLE_ADMIN')") - public void editUser(final String username, final String password, final Role... roles); + /** + * Edits a given user. If the password field of the given domain object is empty, the password won't be changed. If it is filled, it will be changed. + * + * @param user + * The domain object used to extract the necessary data to edit the user. + * @throws DataAccessException + * If it was not possible to edit the user. Either because a constraint was violated or because the connection to the database has somehow been + * damaged. + */ + @PreAuthorize("hasRole('Administrator')") + public void editUser(final User user) throws DataAccessException; - @PreAuthorize("hasRole('ROLE_ADMIN')") - public List<User> getUsers(); + /** + * Delivers a list containing the available users within the system. The password fields of the returned domain objects will be empty. The list is always a copy + * and can be modified at will. + * + * @return A list with the available users. + * @throws DataAccessException + * If something went wrong during the reading. This happens probably if the connection to the database has somehow been damaged. + */ + @PreAuthorize("hasRole('Administrator')") + public List<User> getUsers() throws DataAccessException; } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAOImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAOImpl.java index 9f5ca3df144f6c9be8a31827e7581a3cf3cff397..b7756edaca38f509930d626f8c6a049f1f8839b0 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAOImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAOImpl.java @@ -22,8 +22,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -import java.util.Map; -import java.util.TreeMap; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; @@ -33,23 +31,25 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.datasource.DataSourceUtils; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; +import kieker.webgui.common.exception.DataAccessException; import kieker.webgui.domain.User; import kieker.webgui.domain.User.Role; import kieker.webgui.persistence.IUserDAO; /** + * An implementation of the {@link IUserDAO} interface, which uses Apache Derby to store and manage the available users. A transaction manager is not necessary, as + * all of the used commands are atomic (except for the getUsers() method, which is read only though). * * @author Nils Christian Ehmke */ -// FIXME The transactional annotations do not work yet. @Service public class DerbyUserDAOImpl implements IUserDAO { private static final Log LOG = LogFactory.getLog(DerbyUserDAOImpl.class); + @Autowired private DataSource dataSource; private Connection connection; @@ -62,43 +62,54 @@ public class DerbyUserDAOImpl implements IUserDAO { } /** - * This method initializes the object.. <b>Do not call this method manually. It will only be accessed by Spring.</b> + * This method initializes the object. <b>Do not call this method manually. It will only be accessed by Spring.</b> * * @throws SQLException - * If something went wrong during the initialization + * If something went wrong during the initialization. */ @PostConstruct public void initialize() throws SQLException { this.connection = DataSourceUtils.getConnection(this.dataSource); } + /** + * This method "destroys" the object by closing the connection to the database. <b>Do not call this method manually. It will only be accessed by Spring.</b> + * + * @throws SQLException + * If something went wrong during the initialization. + */ @PreDestroy public void destroy() throws SQLException { this.connection.close(); } + /* + * (non-Javadoc) + * + * @see kieker.webgui.persistence.IserDAO#addUser(user) + */ @Override - @PreAuthorize("hasRole('ROLE_ADMIN')") - @Transactional - public void addUser(final String username, final String password, final List<Role> roles) { + @PreAuthorize("hasRole('Administrator')") + public void addUser(final User user) throws DataAccessException { PreparedStatement userCmd = null; - PreparedStatement roleCmd = null; try { - userCmd = this.connection.prepareStatement("INSERT INTO KIEKERUser (name, password, enabled) VALUES (?, ?, True)"); - roleCmd = this.connection.prepareStatement("INSERT INTO Userroles (name, role) VALUES (?, ?)"); + userCmd = this.connection.prepareStatement("INSERT INTO Users (name, password, isGuest, isUser, isAdministrator, isEnabled) VALUES (?, ?, ?, ?, ?, ?)"); - userCmd.setString(1, username); - userCmd.setString(2, password); - userCmd.execute(); + // Use all properties of the given object + userCmd.setString(1, user.getName()); + userCmd.setString(2, user.getPassword()); + userCmd.setBoolean(3, user.getRole() == Role.ROLE_GUEST); + userCmd.setBoolean(4, user.getRole() == Role.ROLE_USER); + userCmd.setBoolean(5, user.getRole() == Role.ROLE_ADMIN); + userCmd.setBoolean(6, user.isEnabled()); - roleCmd.setString(1, username); - for (final Role role : roles) { - roleCmd.setInt(2, role.getID()); - roleCmd.execute(); - } + // Run the command + userCmd.execute(); } catch (final SQLException ex) { - DerbyUserDAOImpl.LOG.error("Could not add user to the database.", ex); + // Something went wrong. Inform the calling method. + throw new DataAccessException("Could not add user to the database.", ex); } finally { + // Try to close the statement. If that doesn't work then log it, but it is not necessary to inform the calling method. if (userCmd != null) { try { userCmd.close(); @@ -106,9 +117,32 @@ public class DerbyUserDAOImpl implements IUserDAO { DerbyUserDAOImpl.LOG.error("Could not close prepared statement.", ex); } } - if (roleCmd != null) { + } + } + + /* + * (non-Javadoc) + * + * @see kieker.webgui.persistence.IserDAO#deleteUser(user) + */ + @Override + @PreAuthorize("hasRole('Administrator')") + public void deleteUser(final User user) throws DataAccessException { + PreparedStatement delCmd = null; + try { + delCmd = this.connection.prepareStatement("DELETE FROM Users WHERE name=?"); + + delCmd.setString(1, user.getName()); + + delCmd.execute(); + } catch (final SQLException ex) { + // Something went wrong. Inform the calling method. + throw new DataAccessException("Could not delete user from the database.", ex); + } finally { + // Try to close the statement. If that doesn't work then log it, but it is not necessary to inform the calling method. + if (delCmd != null) { try { - roleCmd.close(); + delCmd.close(); } catch (final SQLException ex) { DerbyUserDAOImpl.LOG.error("Could not close prepared statement.", ex); } @@ -116,60 +150,83 @@ public class DerbyUserDAOImpl implements IUserDAO { } } + /* + * (non-Javadoc) + * + * @see kieker.webgui.persistence.IserDAO#editUser(user) + */ @Override - @PreAuthorize("hasRole('ROLE_ADMIN')") - @Transactional - public void removeUser(final String username) { - // TODO Auto-generated method stub + @PreAuthorize("hasRole('Administrator')") + public void editUser(final User user) throws DataAccessException { + PreparedStatement updateCmd = null; + try { + // Choose the right update command, depending on whether the password has to be changed or not + if (user.getPassword() == null) { + updateCmd = this.connection.prepareStatement("UPDATE Users SET name=?, isGuest=?, isUser=?, isAdministrator=?, isEnabled=? WHERE name=?"); + } else { + // In this case we have to set the password as well + updateCmd = this.connection + .prepareStatement("UPDATE Users SET name=?, isGuest=?, isUser=?, isAdministrator=?, isEnabled=?, password=? WHERE name=?"); + updateCmd.setString(6, user.getPassword()); + } - } + // Set the other values + updateCmd.setString(1, user.getName()); + updateCmd.setBoolean(2, user.getRole() == Role.ROLE_GUEST); + updateCmd.setBoolean(3, user.getRole() == Role.ROLE_USER); + updateCmd.setBoolean(4, user.getRole() == Role.ROLE_ADMIN); + updateCmd.setBoolean(5, user.isEnabled()); - @Override - @PreAuthorize("hasRole('ROLE_ADMIN')") - @Transactional - public void editUser(final String username, final String password, final Role... roles) { - // TODO Auto-generated method stub + // Run the command + updateCmd.execute(); + } catch (final SQLException ex) { + throw new DataAccessException("Could not update user within the database.", ex); + } finally { + // Try to close the statement. If that doesn't work then log it, but it is not necessary to inform the calling method. + if (updateCmd != null) { + try { + updateCmd.close(); + } catch (final SQLException ex) { + DerbyUserDAOImpl.LOG.error("Could not close prepared statement.", ex); + } + } + } } + /* + * (non-Javadoc) + * + * @see List<User> kieker.webgui.persistence.getUsers() + */ @Override - @PreAuthorize("hasRole('ROLE_ADMIN')") - @Transactional(readOnly = true) - public List<User> getUsers() { - // FIXME Users without roles + @PreAuthorize("hasRole('Administrator')") + public List<User> getUsers() throws DataAccessException { final List<User> result = new ArrayList<User>(); + ResultSet queryResult = null; + PreparedStatement getQuery = null; try { - final Map<String, User> tempMap = new TreeMap<String, User>(); - - final PreparedStatement getQuery = this.connection - .prepareStatement("select u.name, ur.role, u.enabled from KIEKERUser u, Userroles ur where u.name=ur.name"); + getQuery = this.connection.prepareStatement("SELECT name, isGuest, isUser, isAdministrator, isEnabled FROM Users"); // Run through all results queryResult = getQuery.executeQuery(); while (queryResult.next()) { - // Get both the username and the role from the current entry final String username = queryResult.getString(1); - final int roleID = queryResult.getInt(2); - final Role role = Role.fromID(roleID); - final boolean enabled = queryResult.getBoolean(3); - - // If the user doesn't exist in our map yet, add him. - // In each case we add the role to the user - if (tempMap.containsKey(username)) { - tempMap.get(username).getRoles().add(role); - } else { - final List<Role> roles = new ArrayList<Role>(); - roles.add(role); - tempMap.put(username, new User(username, null, roles, enabled)); - } - } + final boolean isGuest = queryResult.getBoolean(2); + final boolean isUser = queryResult.getBoolean(3); + final boolean isAdministrator = queryResult.getBoolean(4); + final boolean isEnabled = queryResult.getBoolean(5); + + // The case that the user has no role cannot happen, as the database should make sure that this is not possible + final Role role = isAdministrator ? Role.ROLE_ADMIN : (isUser ? Role.ROLE_USER : (isGuest ? Role.ROLE_GUEST : null)); // NOPMD (Null assigning) - // Now convert the map to the list - result.addAll(tempMap.values()); + result.add(new User(username, null, role, isEnabled)); + } } catch (final SQLException ex) { DerbyUserDAOImpl.LOG.error("Could not receive user list.", ex); } finally { + // Try to close the everything. If that doesn't work then log it, but it is not necessary to inform the calling method. try { if (queryResult != null) { queryResult.close(); @@ -177,6 +234,13 @@ public class DerbyUserDAOImpl implements IUserDAO { } catch (final SQLException ex) { DerbyUserDAOImpl.LOG.error("Could not close query result.", ex); } + if (getQuery != null) { + try { + getQuery.close(); + } catch (final SQLException ex) { + DerbyUserDAOImpl.LOG.error("Could not close prepared statement.", ex); + } + } } return result; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java index 84d5ad5c4978dc7625ce2136f559e356c468455a..e13bd892f9e0fdb5ea5509ea48be7af3a2ece5a9 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java @@ -39,6 +39,7 @@ import java.util.concurrent.ConcurrentHashMap; import javax.annotation.PostConstruct; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import org.springframework.util.WeakReferenceMonitor; import org.springframework.util.WeakReferenceMonitor.ReleaseListener; @@ -61,12 +62,15 @@ import kieker.webgui.persistence.impl.util.CloseableURLClassLoader; import org.primefaces.model.UploadedFile; /** + * This is an implementation of the {@link IProjectDAO} interface, which uses the file system to store the available projects and everything. + * * @author Nils Christian Ehmke */ @Service public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { private static final Log LOG = LogFactory.getLog(FSProjectDAOImpl.class); + private static final String KAX_EXTENSION = "kax"; private static final String LIB_EXTENSION = "jar"; private static final String LIB_DIRECTORY = "lib"; @@ -91,16 +95,19 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { } /** - * This method initializes the class. + * This method initializes the object. <b>Do not call this method manually. It will only be accessed by Spring.</b> + * + * @throws IOException + * If the creation of the necessary directories failed. */ @PostConstruct - public void initialize() { + public void initialize() throws IOException { // Check for our root-directory and create it if necessary final File rootDir = new File(FSProjectDAOImpl.ROOT_DIRECTORY); if (!rootDir.exists()) { final boolean result = rootDir.mkdir(); if (!result) { - FSProjectDAOImpl.LOG.error("Could not create root directory."); + throw new IOException("Could not create root directory."); } } } @@ -111,6 +118,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#addProject(java.lang.String) */ @Override + @PreAuthorize("hasAnyRole('User', 'Administrator')") public void addProject(final String projectName) throws ProjectAlreadyExistingException, IOException { // Assemble all necessary paths and files for the given project final File projectDir = this.assembleProjectDir(projectName); @@ -156,6 +164,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#copyProject(java.lang.String, java.lang.String) */ @Override + @PreAuthorize("hasAnyRole('User', 'Administrator')") public void copyProject(final String originalProjectName, final String newProjectName) throws ProjectNotExistingException, ProjectAlreadyExistingException, IOException { // Get the necessary paths @@ -206,6 +215,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#openProject(java.lang.String) */ @Override + @PreAuthorize("isAuthenticated()") public MIProject openProject(final String projectName) throws ProjectNotExistingException, IOException { if (projectName == null) { throw new IOException("Project is null"); @@ -225,6 +235,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#openProject(java.lang.String, kieker.webgui.common.ClassAndMethodContainer) */ @Override + @PreAuthorize("isAuthenticated()") public Object openProject(final String projectName, final ClassAndMethodContainer classAndMethodContainer) throws ProjectNotExistingException, IOException { if (projectName == null) { throw new IOException("Project is null"); @@ -247,6 +258,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#saveProject(java.lang.String, kieker.analysis.model.analysisMetaModel.MIProject, long, boolean) */ @Override + @PreAuthorize("hasAnyRole('User', 'Administrator')") public void saveProject(final String projectName, final MIProject project, final long timeStamp, final boolean overwriteNewerProject) throws ProjectNotExistingException, IOException, NewerProjectException { // Check whether the project exists @@ -270,6 +282,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#getCurrTimeStamp(java.lang.String) */ @Override + @PreAuthorize("isAuthenticated()") public long getCurrTimeStamp(final String projectName) throws ProjectNotExistingException { // Check whether the project exists if (!this.projectExists(projectName)) { @@ -284,6 +297,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#uploadLibrary(org.primefaces.model.UploadedFile, java.lang.String) */ @Override + @PreAuthorize("hasAnyRole('User', 'Administrator')") public void uploadLibrary(final UploadedFile file, final String projectName) throws ProjectNotExistingException, IOException, LibraryAlreadyExistingException { // Check whether the project exists if (!this.projectExists(projectName)) { @@ -345,6 +359,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#getClassLoader(java.lang.String) */ @Override + @PreAuthorize("isAuthenticated()") public ClassLoader getClassLoader(final String projectName, final Object requester) throws ProjectNotExistingException, IOException { // Check whether the project exists if (!this.projectExists(projectName)) { @@ -362,7 +377,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { for (final File file : files) { if (file.getName().endsWith("." + FSProjectDAOImpl.LIB_EXTENSION)) { try { - libs.add(file.toURL()); + libs.add(file.toURI().toURL()); } catch (final MalformedURLException ex) { ex.printStackTrace(); } @@ -390,6 +405,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#listAllLibraries(java.lang.String) */ @Override + @PreAuthorize("isAuthenticated()") public List<String> listAllLibraries(final String projectName) throws ProjectNotExistingException { // Check whether the project exists if (!this.projectExists(projectName)) { @@ -417,6 +433,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#listAllProjects() */ @Override + @PreAuthorize("isAuthenticated()") public Collection<String> listAllProjects() { final List<String> result = new ArrayList<String>(); @@ -525,10 +542,11 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#getURL(kieker.analysis.model.analysisMetaModel.MIDependency, java.lang.String) */ @Override + @PreAuthorize("isAuthenticated()") public URL getURL(final MIDependency lib, final String project) throws MalformedURLException { final File file = new File(FSProjectDAOImpl.ROOT_DIRECTORY + File.separator + project + File.separator + FSProjectDAOImpl.LIB_DIRECTORY + File.separator + lib.getFilePath()); - return file.toURL(); + return file.toURI().toURL(); } /** @@ -570,6 +588,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#getKiekerURL() */ @Override + @PreAuthorize("isAuthenticated()") public URL getKiekerURL() { return Thread.currentThread().getContextClassLoader().getResource(FSProjectDAOImpl.KIEKER_LIB); } @@ -580,6 +599,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#getProjectFile(java.lang.String) */ @Override + @PreAuthorize("isAuthenticated()") public File getProjectFile(final String projectName) { return this.assembleKaxFile(projectName); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/util/CloseableURLClassLoader.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/util/CloseableURLClassLoader.java index 8da748bd8a69d0b8008ab87bcc94951a6f875750..e20604da4a4f0813ed314669b19a4b815f8d556a 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/util/CloseableURLClassLoader.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/util/CloseableURLClassLoader.java @@ -22,16 +22,21 @@ import java.net.URLClassLoader; import java.util.Collection; /** - * A class loader which extends the {@link URLClassLoader} with a close-method using a hack. This will probably only work for a Sun VM. + * A class loader which extends the {@link URLClassLoader} with a close-method using a hack. This will probably only work for a Sun VM. The class itself will + * partially <b>not</b> be checked by Findbugs (there is an exception-rule in the configuration-file) as I <b>know</b> that the code is dangerous. It is a hack after + * all. * * @author Nils Christian Ehmke */ public class CloseableURLClassLoader extends URLClassLoader implements Closeable { - /* - * (non-Javadoc) + /** + * Creates a new instance of this class using the given parameters. * - * @see URLClassLoader#URLClassLoader(URL[], ClassLoader) + * @param urls + * The URLs to be used by the classloader. + * @param parent + * The parent of this classloader. */ public CloseableURLClassLoader(final URL[] urls, final ClassLoader parent) { super(urls, parent); @@ -53,6 +58,7 @@ public class CloseableURLClassLoader extends URLClassLoader implements Closeable final java.lang.reflect.Field loaders = sunMiscURLClassPath.getClass().getDeclaredField("loaders"); loaders.setAccessible(true); + // Run through all available loaders and try to close them final Object javaUtilCollection = loaders.get(sunMiscURLClassPath); for (final Object sunMiscURLClassPathJarLoader : ((Collection<?>) javaUtilCollection).toArray()) { try { @@ -60,11 +66,11 @@ public class CloseableURLClassLoader extends URLClassLoader implements Closeable loader.setAccessible(true); final Object javaUtilIarJarFile = loader.get(sunMiscURLClassPathJarLoader); ((java.util.jar.JarFile) javaUtilIarJarFile).close(); - } catch (final Throwable t) { + } catch (final Throwable t) { // NOCS, NOPMD (Catch of Throwable) // if we got this far, this is probably not a JAR loader so skip it } } - } catch (final Throwable ex) { + } catch (final Throwable ex) { // NOCS, NOPMD (Catch of Throwable) // probably not a SUN VM throw new IOException("Not a Sun VM.", ex); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java index e47fae9d0e178e76739b9a5b707df5325659e1bb..fc30376a0b4f9345f32f8a19a708b7638f695acf 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java @@ -162,6 +162,8 @@ public interface IProjectService { * * @param projectName * The name of the project. + * @param requester + * The requester of the class loader. * @return A class loader for the given project. * @throws ProjectNotExistingException * If a project with the given name does not exist. @@ -331,10 +333,8 @@ public interface IProjectService { * @param projectName * The name of the project whose state have to be returned. * @return The state of the given project, if available. {@code null} otherwise. - * @throws ProjectNotExistingException - * If a project with the given name does not exist. */ - public STATE getCurrentState(final String projectName) throws ProjectNotExistingException; + public STATE getCurrentState(final String projectName); /** * This method delivers the available log entries of the analysis controller of the given project. diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IUserService.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IUserService.java index 0623c8ae0b7cd1f69828fb41b447ed086ba7aa2b..e5820f2c405f5581620409b30cd242e13054996a 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IUserService.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IUserService.java @@ -18,30 +18,63 @@ package kieker.webgui.service; import java.util.List; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.transaction.annotation.Transactional; +import kieker.webgui.common.exception.DataAccessException; import kieker.webgui.domain.User; -import kieker.webgui.domain.User.Role; /** + * This is an interface to the service which can be used to manage the available users within the system. The methods within this interface are only accessible by + * administrators. + * * @author Nils Christian Ehmke */ public interface IUserService { - @PreAuthorize("hasRole('ROLE_ADMIN')") - @Transactional - public void addUser(final String username, final String password, final List<Role> roles); + /** + * Adds a user to the system. + * + * @param user + * The domain object used to extract the necessary data to create the user. + * @throws DataAccessException + * If it was not possible to add the user to the system. Either because a constraint was violated or because the connection to the database has + * somehow been damaged. + */ + @PreAuthorize("hasRole('Administrator')") + public void addUser(final User user) throws DataAccessException; - @PreAuthorize("hasRole('ROLE_ADMIN')") - @Transactional - public void removeUser(final String username); + /** + * Deletes a user from the system. + * + * @param user + * The domain object used to extract the necessary data to delete the user. + * @throws DataAccessException + * If it was not possible to delete the user. Either because a constraint was violated or because the connection to the database has somehow been + * damaged. + */ + @PreAuthorize("hasRole('Administrator')") + public void deleteUser(final User user) throws DataAccessException; - @PreAuthorize("hasRole('ROLE_ADMIN')") - @Transactional - public void editUser(final String username, final String password, final Role... roles); + /** + * Edits a given user. If the password field of the given domain object is empty, the password won't be changed. If it is filled, it will be changed. + * + * @param user + * The domain object used to extract the necessary data to edit the user. + * @throws DataAccessException + * If it was not possible to edit the user. Either because a constraint was violated or because the connection to the database has somehow been + * damaged. + */ + @PreAuthorize("hasRole('Administrator')") + public void editUser(final User user) throws DataAccessException; - @PreAuthorize("hasRole('ROLE_ADMIN')") - @Transactional - public List<User> getUsers(); + /** + * Delivers a list containing the available users within the system. The password fields of the returned domain objects will be empty. The list is always a copy + * and can be modified at will. + * + * @return A list with the available users. + * @throws DataAccessException + * If something went wrong during the reading. This happens probably if the connection to the database has somehow been damaged. + */ + @PreAuthorize("hasRole('Administrator')") + public List<User> getUsers() throws DataAccessException; } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/ProjectServiceImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/ProjectServiceImpl.java index 863fa7888223299e1720d8a1b5038eee01ac2ec0..c156a6ca4d9951bbd3b93f829b7ec5ed55ea8ec2 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/ProjectServiceImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/ProjectServiceImpl.java @@ -277,7 +277,7 @@ public final class ProjectServiceImpl implements IProjectService { } @Override - public STATE getCurrentState(final String projectName) throws ProjectNotExistingException { + public STATE getCurrentState(final String projectName) { final Object analysisLock = this.getLock(projectName, this.analysesLocks); synchronized (analysisLock) { diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java index d8db0c941d6c4bec8afba2019b8b89c46828e1d0..23ac51187abc4c73ef90e7ca95936d3c248cc676 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java @@ -20,14 +20,15 @@ import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; +import kieker.webgui.common.exception.DataAccessException; import kieker.webgui.domain.User; -import kieker.webgui.domain.User.Role; import kieker.webgui.persistence.IUserDAO; import kieker.webgui.service.IUserService; /** + * This is an implementation of the {@link IUserService} interface. The work will be delegated to the underlying data access object. + * * @author Nils Christian Ehmke */ @Service @@ -36,66 +37,55 @@ public class UserServiceImpl implements IUserService { @Autowired private IUserDAO userDAO; - public UserServiceImpl() { - // No code necessary - } - /** - * Setter for the property {@link UserServiceImpl#userDAO}. - * - * @param userDAO - * The new value of the property. + * Default constructor. <b>Do not use this constructor. This bean is Spring managed.</b> */ - public void setUserDAO(final IUserDAO userDAO) { - this.userDAO = userDAO; + public UserServiceImpl() { + // No code necessary } /* * (non-Javadoc) * - * @see kieker.webgui.service.IUserService#addUser(java.lang.String, java.lang.String, java.util.List) + * @see kieker.webgui.service.IUserService#addUser(kieker.webgui.domain.User) */ @Override - @PreAuthorize("hasRole('ROLE_ADMIN')") - @Transactional - public void addUser(final String username, final String password, final List<Role> roles) { - this.userDAO.addUser(username, password, roles); + @PreAuthorize("hasRole('Administrator')") + public void addUser(final User user) throws DataAccessException { + this.userDAO.addUser(user); } /* * (non-Javadoc) * - * @see kieker.webgui.service.IUserService#removeUser(java.lang.String) + * @see kieker.webgui.service.IUserService#getUsers() */ @Override - @PreAuthorize("hasRole('ROLE_ADMIN')") - @Transactional - public void removeUser(final String username) { - this.userDAO.removeUser(username); + @PreAuthorize("hasRole('Administrator')") + public List<User> getUsers() throws DataAccessException { + return this.userDAO.getUsers(); } /* * (non-Javadoc) * - * @see kieker.webgui.service.IUserService#editUser(java.lang.String, java.lang.String, kieker.webgui.domain.User.Role[]) + * @see kieker.webgui.service.IUserService#deleteUser(kieker.webgui.domain.User) */ @Override - @PreAuthorize("hasRole('ROLE_ADMIN')") - @Transactional - public void editUser(final String username, final String password, final Role... roles) { - this.userDAO.editUser(username, password, roles); + @PreAuthorize("hasRole('Administrator')") + public void deleteUser(final User user) throws DataAccessException { + this.userDAO.deleteUser(user); } /* * (non-Javadoc) * - * @see kieker.webgui.service.IUserService#getUsers() + * @see kieker.webgui.service.IUserService#editUser(kieker.webgui.domain.User) */ @Override - @PreAuthorize("hasRole('ROLE_ADMIN')") - @Transactional - public List<User> getUsers() { - return this.userDAO.getUsers(); + @PreAuthorize("hasRole('Administrator')") + public void editUser(final User user) throws DataAccessException { + this.userDAO.editUser(user); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/ACManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/ACManager.java index 86f5d42d164209079e6ac248217d74f6cb4c9be8..a9addbe3fee38a5bbe92495e051cf263919ffefb 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/ACManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/ACManager.java @@ -51,15 +51,6 @@ public final class ACManager { // No code necessary. } - /** - * The setter for the property {@link ACManager#projectDAO}. <b>Do not use this method. This property is Spring managed.</b> - * - * @param projectDAO - */ - public void setProjectDAO(final IProjectDAO projectDAO) { - this.projectDAO = projectDAO; - } - /** * This method initializes the analysis for the given project. * @@ -203,41 +194,36 @@ public final class ACManager { } /** - * This method delivers the current state of the analysis, if it is available, an exception otherwise. + * This method delivers the current state of the analysis, if it is available, null otherwise. * * @param projectName * The name of the project. * @return The state of the given project. - * @throws ProjectNotExistingException - * If a project with the given name does not exist. */ - public STATE getCurrentState(final String projectName) throws ProjectNotExistingException { - // The analysis for the given project must exist! - if (!this.analyses.containsKey(projectName)) { - throw new ProjectNotExistingException("The analysis has not been initialized yet."); - } + public STATE getCurrentState(final String projectName) { + STATE retState = null; - final Analysis analysis = this.analyses.get(projectName); - final Enum<?> state = analysis.getCurrentState(); - - if (state == null) { - throw new ProjectNotExistingException("Unknown state."); - } - - if (STATE.FAILED.toString().equals(state.toString())) { - return STATE.FAILED; - } - if (STATE.READY.toString().equals(state.toString())) { - return STATE.READY; - } - if (STATE.RUNNING.toString().equals(state.toString())) { - return STATE.RUNNING; - } - if (STATE.TERMINATED.toString().equals(state.toString())) { - return STATE.TERMINATED; + // The analysis for the given project must exist! + if (this.analyses.containsKey(projectName)) { + final Analysis analysis = this.analyses.get(projectName); + final Enum<?> state = analysis.getCurrentState(); + + if (state != null) { + if (STATE.FAILED.toString().equals(state.toString())) { + retState = STATE.FAILED; + } + if (STATE.READY.toString().equals(state.toString())) { + retState = STATE.READY; + } + if (STATE.RUNNING.toString().equals(state.toString())) { + retState = STATE.RUNNING; + } + if (STATE.TERMINATED.toString().equals(state.toString())) { + retState = STATE.TERMINATED; + } + } } - - throw new ProjectNotExistingException("Unknown state."); + return retState; } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/ProjectsBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/ProjectsBean.java index f21c1e7c41c9dc1a9b3b1f9c0199357018e40ab8..88b7f9e114cc6226065d00b91dbd4ffc2ef929c5 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/ProjectsBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/ProjectsBean.java @@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import kieker.analysis.AnalysisController.STATE; import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; @@ -66,16 +67,6 @@ public final class ProjectsBean { // No code necessary } - /** - * The Setter for the property {@link ProjectsBean#projectService}. <b>Do not use this method. This property is Spring managed.</b> - * - * @param projectService - * The new value for the property. - */ - public void setProjectService(final IProjectService projectService) { - this.projectService = projectService; - } - /** * This method does some initialization work after construction. <b>Do not call this method. The method is Spring managed.</b> */ @@ -218,10 +209,10 @@ public final class ProjectsBean { * @return The current state of the corresponding AnalysisController. */ public String getAnalysisControllerState(final String project) { - try { - return this.projectService.getCurrentState(project).toString(); - } catch (final ProjectNotExistingException ex) { - ProjectsBean.LOG.info("A project with the given name does not exist.", ex); + final STATE state = this.projectService.getCurrentState(project); + if (state != null) { + return state.toString(); + } else { return ProjectsBean.DEFAULT_ANALYSIS_STATE; } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/request/NewUserBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/request/NewUserBean.java index a9e207802052d48ee0abd9d650f959efd5f86266..d54fc22cdf671474ae61547102e96f78cc6ca7b3 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/request/NewUserBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/request/NewUserBean.java @@ -16,9 +16,6 @@ package kieker.webgui.web.beans.request; -import java.util.ArrayList; -import java.util.List; - import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -34,7 +31,7 @@ import kieker.webgui.domain.User.Role; @Scope("request") public class NewUserBean { - private List<Role> roles; + private final Role role; private String username; private String password; @@ -42,28 +39,18 @@ public class NewUserBean { * Creates a new instance of this bean and initializes it with empty fields. <b>Do not use this constructor. This bean is Spring managed.</b> */ public NewUserBean() { - this.roles = new ArrayList<Role>(); + this.role = Role.ROLE_GUEST; this.username = ""; this.password = ""; } /** - * Delivers the current value of the property {@link NewUserBean#roles}. + * Getter for the property {@link NewUserBean#role}. * * @return The current value of the property. */ - public List<Role> getRoles() { - return this.roles; - } - - /** - * Setter for the property {@link NewUserBean#roles}. - * - * @param roles - * The new value for the property. - */ - public void setRoles(final List<Role> roles) { - this.roles = roles; + public Role getRole() { + return this.role; } /** diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/session/UserBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/session/UserBean.java index da3ea02c2d62c8f8cb0b1a357b2e5279327de6b9..df01e14fac5166742f7e8979093f38b9bd27cf58 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/session/UserBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/session/UserBean.java @@ -17,6 +17,7 @@ package kieker.webgui.web.beans.session; import java.io.Serializable; +import java.util.Iterator; import java.util.Map; import javax.annotation.PostConstruct; @@ -26,6 +27,7 @@ import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; +import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.stereotype.Component; @@ -74,22 +76,39 @@ public final class UserBean implements Serializable { * @return The user name of the session user. */ public String getUsername() { - final String username; + String username = "N/A"; - // Try to get the principal - final Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); - if (principal instanceof UserDetails) { - // Looks like it worked. Extract the username. - final UserDetails userDetails = (UserDetails) principal; + final UserDetails userDetails = UserBean.getUserDetails(); + if (userDetails != null) { username = userDetails.getUsername(); - } else { - // Something went wrong - username = "N/A"; } return username; } + public String getUserrole() { + String userrole = "N/A"; + + final UserDetails userDetails = UserBean.getUserDetails(); + if (userDetails != null) { + final Iterator<? extends GrantedAuthority> authorities = userDetails.getAuthorities().iterator(); + // If there is at least one authority, we know that it must be the first (we only have one authority per user). + if (authorities.hasNext()) { + userrole = authorities.next().getAuthority(); + } + } + + return userrole; + } + + private static UserDetails getUserDetails() { + final Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); + if (principal instanceof UserDetails) { + return (UserDetails) principal; + } + return null; + } + /** * The setter for the property {@link UserBean#globalPropertiesBean}. <b>Do not use this method. This property is Spring managed.</b> * diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentUserManagementBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentUserManagementBean.java index 3e82f3889e836562ab7509d4df7f1f3d74fd9387..64422baff8f1aa778acd8009d296eadc008658f5 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentUserManagementBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentUserManagementBean.java @@ -20,14 +20,17 @@ import java.util.ArrayList; import java.util.List; import javax.annotation.PostConstruct; +import javax.faces.application.FacesMessage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import kieker.webgui.common.exception.DataAccessException; import kieker.webgui.domain.User; import kieker.webgui.domain.User.Role; import kieker.webgui.service.IUserService; +import kieker.webgui.web.beans.application.GlobalPropertiesBean; /** * @author Nils Christian Ehmke @@ -35,12 +38,11 @@ import kieker.webgui.service.IUserService; @Component @Scope("view") public final class CurrentUserManagementBean { + @Autowired private IUserService userService; - /** - * This list contains all available users. - */ - private List<User> users = new ArrayList<User>(); + + private List<User> availableUses = new ArrayList<User>(); /** * Default constructor. <b>Do not call this constructor manually. It will only be accessed by Spring.</b> @@ -50,13 +52,11 @@ public final class CurrentUserManagementBean { } /** - * Setter for the property {@link CurrentUserManagementBean#userService}. - * - * @param userService - * The new value for the property. + * This method initializes the bean. <b>Do not call this method manually. It will only be accessed by Spring.</b> */ - public void setUserService(final IUserService userService) { - this.userService = userService; + @PostConstruct + protected void initialialize() { + this.updateList(); } /** @@ -66,52 +66,63 @@ public final class CurrentUserManagementBean { * The name of the new user. * @param password * The password of the new user. - * @param roles - * The roles of the new user. + * @param role + * The role of the new user. + * @param isEnabled + * Determines whether the user is enabled already or not. */ - public void addUser(final String username, final String password, final List<Role> roles) { - this.userService.addUser(username, password, roles); - // TODO Check that the op was successful before adding the user to our list - this.users.add(new User(username, null, roles, true)); + public void addUser(final String username, final String password, final Role role, final boolean isEnabled) { + final User user = new User(username, password, role, isEnabled); + + try { + this.userService.addUser(user); + this.availableUses.add(user); + GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, "Added user to the database."); + } catch (final DataAccessException ex) { + GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "Could not add the user to the database."); + } } /** * This method removed the given user from the database and informs about success via the growl component. * - * @param username - * The name of the user. + * @param user + * The user to be deleted. */ - public void removeUser(final String username) { - this.userService.removeUser(username); + public void deleteUser(final User user) { + try { + this.userService.deleteUser(user); + this.availableUses.remove(user); + GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, "Deleted user from the database."); + } catch (final DataAccessException ex) { + GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "Could not deleted the user from the database."); + } } /** * This method edits the given user within the database and informs about success via the growl component. * - * @param username - * The name of the user. - * @param password - * The (new) password of the user. - * @param roles - * The (new) roles of the user. - */ - public void editUser(final String username, final String password, final Role... roles) { - this.userService.editUser(username, password, roles); - } - - /** - * This method initializes the bean. <b>Do not call this method manually. It will only be accessed by Spring.</b> + * @param user + * The user to be modified. */ - @PostConstruct - protected void initialialize() { - this.updateList(); + public void editUser(final User user) { + try { + this.userService.editUser(user); + GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, "Modified user within the database."); + } catch (final DataAccessException ex) { + GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "Could not modified the user within the database."); + } } /** * Updates the list containing the available users. */ public void updateList() { - this.users = this.userService.getUsers(); + try { + this.availableUses = this.userService.getUsers(); + } catch (final DataAccessException ex) { + GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while accessing the database."); + } } /** @@ -120,6 +131,6 @@ public final class CurrentUserManagementBean { * @return All currently available users. */ public List<User> getUsers() { - return this.users; + return this.availableUses; } } diff --git a/Kieker.WebGUI/src/main/resources/lang/LoginPage_de.properties b/Kieker.WebGUI/src/main/resources/lang/LoginPage_de.properties index beef4292a8be73cc62d7bce5c0264e1b061d4aa6..7ac6e50e76383af558d33b8759b2e585408206f8 100644 --- a/Kieker.WebGUI/src/main/resources/lang/LoginPage_de.properties +++ b/Kieker.WebGUI/src/main/resources/lang/LoginPage_de.properties @@ -1,15 +1,15 @@ #------------------------------------------------------------------------------ # -# Diese Datei beinhaltet sämtliche Nachrichten, Buttonbeschriftungen etc., +# Diese Datei beinhaltet s\u00e4mtliche Nachrichten, Buttonbeschriftungen etc., # welche innerhalb der Anmeldeseite benutzt werden. # #------------------------------------------------------------------------------ msgWelcomeShort = Willkommen bei der Kieker.WebGUI -msgWelcome = Dies ist eine fr\u00fche Beta Version der Kieker Web GUI. Deshalb kann diese noch Bugs enthalten und einige Funktionalit\u00e4ten sind m\u00f6glicherweise noch nicht implementiert. Benutzen sie den Benutzer "Kieker-Team" mit dem Passwort "kieker" um sich anzumelden und fortzufahren. +msgWelcome = Dies ist eine fr\u00fche Beta Version der Kieker Web GUI. Deshalb kann diese noch Bugs enthalten und einige Funktionalit\u00e4ten sind m\u00f6glicherweise noch nicht implementiert. Benutzen sie den Benutzer "Kieker-Administrator" mit dem Passwort "kieker" um sich anzumelden und fortzufahren. username = Benutzername password = Passwort login = Anmelden -hint = Hinweis: Die Kieker.WebGUI benötigt Cookies und JavaScript, um korrekt zu funktionieren. Bitte stellen Sie sicher, dass beides aktiviert ist. \ No newline at end of file +hint = Hinweis: Die Kieker.WebGUI ben\u00f6tigt Cookies und JavaScript, um korrekt zu funktionieren. Bitte stellen Sie sicher, dass beides aktiviert ist. \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/resources/lang/LoginPage_en.properties b/Kieker.WebGUI/src/main/resources/lang/LoginPage_en.properties index 153c8a76c5f95639912deaba73856d347053c0d3..faef1b907c2bbeeeba88542541ef27eb6eb9596f 100644 --- a/Kieker.WebGUI/src/main/resources/lang/LoginPage_en.properties +++ b/Kieker.WebGUI/src/main/resources/lang/LoginPage_en.properties @@ -6,7 +6,7 @@ #------------------------------------------------------------------------------ msgWelcomeShort = Welcome to the Kieker.WebGUI -msgWelcome = This is an early beta version of the Kieker Web GUI. Therefore it may contain bugs and some functionality may have not been implemented yet. Use the user "Kieker-Team" with the password "kieker" to login and continue. +msgWelcome = This is an early beta version of the Kieker Web GUI. Therefore it may contain bugs and some functionality may have not been implemented yet. Use the user "Kieker-Administrator" with the password "kieker" to login and continue. username = Username password = Password diff --git a/Kieker.WebGUI/src/main/resources/lang/UserManagementPage_de.properties b/Kieker.WebGUI/src/main/resources/lang/UserManagementPage_de.properties index f5aadf0cfd9875f716c087addc7eaa2e9844c1a2..878f37ba6cf545bb7dce1a6ae0fed80a915d6885 100644 --- a/Kieker.WebGUI/src/main/resources/lang/UserManagementPage_de.properties +++ b/Kieker.WebGUI/src/main/resources/lang/UserManagementPage_de.properties @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ # -# Diese Datei beinhaltet sämtliche Nachrichten, Buttonbeschriftungen etc., +# Diese Datei beinhaltet s\u00e4mtliche Nachrichten, Buttonbeschriftungen etc., # welche innerhalb der Benutzerverwaltungsseite benutzt werden. # #------------------------------------------------------------------------------ @@ -12,8 +12,8 @@ updateUserList = Benutzerliste Aktualisieren editUser = Benutzer Bearbeiten disableUser = Benutzer Deaktivieren enableUser = Benutzer Aktivieren -deleteUser = Benutzer Löschen +deleteUser = Benutzer L\u00f6schen username = Benutzername -userroles = Benutzerrollen +userrole = Benutzerrolle enabled = Aktiviert \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/resources/lang/UserManagementPage_en.properties b/Kieker.WebGUI/src/main/resources/lang/UserManagementPage_en.properties index fcca366ae9570d14a04c2cbabeffd28470e6f1ae..f705fdec2d50eef8697cd3d67e374899010f2a10 100644 --- a/Kieker.WebGUI/src/main/resources/lang/UserManagementPage_en.properties +++ b/Kieker.WebGUI/src/main/resources/lang/UserManagementPage_en.properties @@ -15,5 +15,5 @@ enableUser = Enable User deleteUser = Delete User username = Username -userroles = Userroles +userrole = Userrole enabled = Enabled \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/resources/sql/tables.sql b/Kieker.WebGUI/src/main/resources/sql/tables.sql index 1b5b6acd805c0c1dd67d647f8e553b2878b127dc..f2838af0447b2fbc687710c46e6132ca7227c1f9 100644 --- a/Kieker.WebGUI/src/main/resources/sql/tables.sql +++ b/Kieker.WebGUI/src/main/resources/sql/tables.sql @@ -1,3 +1 @@ -CREATE TABLE Roles (ID int NOT NULL PRIMARY KEY, Role varchar(255)); -CREATE TABLE KIEKERUser (name varchar(255) NOT NULL PRIMARY KEY, password varchar(255) NOT NULL, enabled BOOLEAN); -CREATE TABLE Userroles (name varchar(255) NOT NULL, role int NOT NULL , CONSTRAINT key_roles PRIMARY KEY(name, role)); \ No newline at end of file +CREATE TABLE Users (name VARCHAR(255) NOT NULL PRIMARY KEY, password VARCHAR(255) NOT NULL, isGuest BOOLEAN, isUser BOOLEAN, isAdministrator BOOLEAN, isEnabled BOOLEAN, CONSTRAINT checkFlags CHECK ((CASE WHEN isGuest THEN 1 ELSE 0 END)+(CASE WHEN isUser THEN 1 ELSE 0 END)+(CASE WHEN isAdministrator THEN 1 ELSE 0 END)=1)); \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/resources/sql/test-data.sql b/Kieker.WebGUI/src/main/resources/sql/test-data.sql index 1c17b8ef9aeee3b827104badc2df042be937a5a1..5110ea9ca9114f9201f86909fef5dd3fd5eb22cd 100644 --- a/Kieker.WebGUI/src/main/resources/sql/test-data.sql +++ b/Kieker.WebGUI/src/main/resources/sql/test-data.sql @@ -1,3 +1 @@ -INSERT INTO Roles (ID, Role) VALUES (1, 'ROLE_USER'), (2, 'ROLE_ADMIN') -INSERT INTO KIEKERUser (name, password, enabled) VALUES ('Kieker-Team', 'kieker', True), ('Kieker-User', 'kieker', True) -INSERT INTO Userroles (name, role) VALUES ('Kieker-Team', 1), ('Kieker-User', 1), ('Kieker-Team', 2) \ No newline at end of file +INSERT INTO Users (name, password, isGuest, isUser, isAdministrator, isEnabled) VALUES ('Kieker-Administrator', 'kieker', false, false, true, true), ('Kieker-User', 'kieker', false, true, false, true), ('Kieker-Guest', 'kieker', true, false, false, true) \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-bean-config.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-bean-config.xml index 3e101623e1609c82467fa9e729dbf816ba726abd..7397f093037fe3c46c4c00c6b0f47a2c7c241258 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-bean-config.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-bean-config.xml @@ -58,6 +58,7 @@ <context:component-scan base-package="kieker.webgui"/> <!-- The enums. --> + <util:constant id="ROLE_GUEST" static-field="kieker.webgui.domain.User.Role.ROLE_GUEST"/> <util:constant id="ROLE_USER" static-field="kieker.webgui.domain.User.Role.ROLE_USER"/> <util:constant id="ROLE_ADMIN" static-field="kieker.webgui.domain.User.Role.ROLE_ADMIN"/> </beans> diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-security-config.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-security-config.xml index 990ee3569de60ecc226fcbb2b1e419db3f848afa..7b6d72c9c392233052e738b80869e404eaf22480 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-security-config.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-security-config.xml @@ -3,7 +3,7 @@ xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> <http use-expressions="true" access-denied-page="/accessDenied" > <form-login login-page="/login" default-target-url="/pages/" authentication-failure-url="/login?state=fail"/> @@ -15,12 +15,23 @@ <intercept-url pattern="/templates/**" access="denyAll"/> <!-- The admin area is only accessible by administrators. --> - <intercept-url pattern="/pages/admin/**" access="hasRole('ROLE_ADMIN')"/> - <intercept-url pattern="/faces/pages/admin/**" access="hasRole('ROLE_ADMIN')"/> + <intercept-url pattern="/pages/admin/**" access="hasRole('Administrator')"/> + <intercept-url pattern="/faces/pages/admin/**" access="hasRole('Administrator')"/> + + <!-- The is the guest area. --> + <intercept-url pattern="/pages/analysisEditor" access="isAuthenticated()"/> + <intercept-url pattern="/pages/cockpit" access="isAuthenticated()"/> + <intercept-url pattern="/faces/pages/analysisEditor" access="isAuthenticated()"/> + <intercept-url pattern="/faces/pages/cockpit" access="isAuthenticated()"/> + <intercept-url pattern="/pages/AnalysisEditorPage.xhtml" access="isAuthenticated()"/> + <intercept-url pattern="/pages/CockpitPage.xhtml" access="isAuthenticated()"/> + <intercept-url pattern="/faces/pages/AnalysisEditorPage.xhtml" access="isAuthenticated()"/> + <intercept-url pattern="/faces/pages/CockpitPage.xhtml" access="isAuthenticated()"/> <!-- The is the usual user area. --> - <intercept-url pattern="/pages/**" access="isAuthenticated()"/> - <intercept-url pattern="/faces/pages/**" access="isAuthenticated()"/> + <intercept-url pattern="/pages/**" access="hasAnyRole('User', 'Administrator')"/> + <intercept-url pattern="/faces/pages/**" access="hasAnyRole('User', 'Administrator')"/> + <!-- The root will be redirected to home via prettyfaces. --> <intercept-url pattern="/" access="isAuthenticated()" /> @@ -33,12 +44,10 @@ <authentication-provider> <jdbc-user-service data-source-ref="userDataSource" users-by-username-query=" - select name, password, enabled - from KIEKERUser where name=?" + SELECT name, password, isEnabled + FROM Users WHERE name=?" - authorities-by-username-query=" - select u.name, r.Role from KIEKERUser u, Userroles ur, Roles r - where u.name=ur.name and r.ID = ur.role and u.name=?" + authorities-by-username-query="select name, (case when isGuest then 'Guest' else (case when isUser then 'User' else 'Administrator' end) end) as ROLE from users where users.name = ?" /> </authentication-provider> </authentication-manager> diff --git a/Kieker.WebGUI/src/main/webapp/dialogs/AnalysisEditorPageDialogs.xhtml b/Kieker.WebGUI/src/main/webapp/dialogs/AnalysisEditorPageDialogs.xhtml index 3bb924951b2804fabce08565d5918c6f1e51aacb..1374ef41e89bfdbc985a7364e26f41089b27166d 100644 --- a/Kieker.WebGUI/src/main/webapp/dialogs/AnalysisEditorPageDialogs.xhtml +++ b/Kieker.WebGUI/src/main/webapp/dialogs/AnalysisEditorPageDialogs.xhtml @@ -4,7 +4,7 @@ xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"> - <p:dialog id="manageLibrariesDlg" header="#{localizedMessages.libraries}" resizable="false" modal="true" widgetVar="manageLibrariesDialog"> + <p:dialog id="manageLibrariesDlg" header="#{localizedAnalysisEditorPageMessages.libraries}" resizable="false" modal="true" widgetVar="manageLibrariesDialog"> <h:form id="dependenciesForm"> <p:dataTable id="currentDependencies" value="#{currentAnalysisEditorBean.libraries}" var="dependency" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" > diff --git a/Kieker.WebGUI/src/main/webapp/dialogs/UserManagementDialogs.xhtml b/Kieker.WebGUI/src/main/webapp/dialogs/UserManagementDialogs.xhtml index 2106604ad4feab461ae37820e2955e652920eee0..00a2a4282a9abd797e3e333dd4c8c4880e57cbc6 100644 --- a/Kieker.WebGUI/src/main/webapp/dialogs/UserManagementDialogs.xhtml +++ b/Kieker.WebGUI/src/main/webapp/dialogs/UserManagementDialogs.xhtml @@ -17,16 +17,23 @@ <p:inputText value="#{newUserBean.password}" style="width: 100%" /> - <h:outputText value="Benutzerrollen: " /> - <p:selectManyCheckbox value="#{newUserBean.roles}" layout="pageDirection" converter="roleStringConverter"> + <h:outputText value="Benutzerrolle: " /> + <p:selectOneRadio value="#{newUserBean.role}" converter="roleStringConverter"> + <f:selectItem itemLabel="Gast" itemValue="#{ROLE_GUEST}" /> <f:selectItem itemLabel="Benutzer" itemValue="#{ROLE_USER}" /> <f:selectItem itemLabel="Administrator" itemValue="#{ROLE_ADMIN}" /> - </p:selectManyCheckbox> + </p:selectOneRadio> + + <h:outputText value="Status: " /> + <p:selectOneRadio> + <f:selectItem itemLabel="Aktiviert" itemValue="#{true}" /> + <f:selectItem itemLabel="Deaktiviert" itemValue="#{false}" /> + </p:selectOneRadio> </h:panelGrid> <hr/> <div style="text-align: right"> - <p:commandButton value="#{localizedMessages.ok}" action="#{currentUserManagementBean.addUser(newUserBean.username, newUserBean.password, newUserBean.roles)}" oncomplete="newUserDlg.hide()" update=":usersListForm"/> + <p:commandButton value="#{localizedMessages.ok}" action="#{currentUserManagementBean.addUser(newUserBean.username, newUserBean.password, newUserBean.role, true)}" oncomplete="newUserDlg.hide()" update=":usersListForm"/> </div> </h:form> </p:dialog> diff --git a/Kieker.WebGUI/src/main/webapp/pages/ProjectOverviewPage.xhtml b/Kieker.WebGUI/src/main/webapp/pages/ProjectOverviewPage.xhtml index 719740a3113693aaf36eef6ed77eb9edb539d80d..dec28c8943ccb6b3509bb8df7d5b8ec7b41ab9cf 100644 --- a/Kieker.WebGUI/src/main/webapp/pages/ProjectOverviewPage.xhtml +++ b/Kieker.WebGUI/src/main/webapp/pages/ProjectOverviewPage.xhtml @@ -4,7 +4,8 @@ xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui" - xmlns:f="http://java.sun.com/jsf/core"> + xmlns:f="http://java.sun.com/jsf/core" + xmlns:c="http://java.sun.com/jsp/jstl/core"> <h:head/> @@ -27,9 +28,11 @@ <!-- Those are the menu bar entries left from the help-submenu. --> <ui:define name="furtherMenuBarEntries"> <p:submenu label="#{localizedMessages.file}"> - <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-newProject" value=" #{localizedProjectOverviewMessages.newProject}" onclick="newProjectDialog.show()" ajax="true"/> - <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-importProject" value=" #{localizedProjectOverviewMessages.importProject}" ajax="true" disabled="true"/> - <p:separator/> + <c:if test="#{sec:areAnyGranted('User, Administrator')}"> + <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-newProject" value=" #{localizedProjectOverviewMessages.newProject}" onclick="newProjectDialog.show()" ajax="true"/> + <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-importProject" value=" #{localizedProjectOverviewMessages.importProject}" ajax="true" disabled="true"/> + <p:separator/> + </c:if> <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-reload" value=" #{localizedProjectOverviewMessages.refreshProjectsList}" update=":projectsListForm" action="#{currentProjectOverviewBean.updateLists()}" ajax="true"/> <p:separator/> <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-settings" value=" #{localizedMessages.settings}" onclick="settingsDlg.show()" ajax="true"/> @@ -49,20 +52,26 @@ <p:menuitem icon="ui-icon-analysisEditor" id="openButton" value=" #{localizedMessages.analysisEditor}" styleClass="element-with-whitespace" ajax="false" outcome="analysisEditor"> <f:param name="projectName" value="#{project}"/> </p:menuitem> - <p:menuitem icon="ui-icon-analysis" id="controlAnalysis" styleClass="element-with-whitespace" value=" #{localizedMessages.analysis}" ajax="false" outcome="controller"> - <f:param name="projectName" value="#{project}"/> - </p:menuitem> + <c:if test="#{sec:areAnyGranted('User, Administrator')}"> + <p:menuitem icon="ui-icon-analysis" id="controlAnalysis" styleClass="element-with-whitespace" value=" #{localizedMessages.analysis}" ajax="false" outcome="controller"> + <f:param name="projectName" value="#{project}"/> + </p:menuitem> + </c:if> <p:separator/> - <p:menuitem icon="ui-icon-cockpitEditor" id="editAnalysisViews" styleClass="element-with-whitespace" value=" #{localizedMessages.cockpitEditor}" ajax="false" outcome="cockpitEditor" > - <f:param name="projectName" value="#{project}"/> - </p:menuitem> + <c:if test="#{sec:areAnyGranted('User, Administrator')}"> + <p:menuitem icon="ui-icon-cockpitEditor" id="editAnalysisViews" styleClass="element-with-whitespace" value=" #{localizedMessages.cockpitEditor}" ajax="false" outcome="cockpitEditor" > + <f:param name="projectName" value="#{project}"/> + </p:menuitem> + </c:if> <p:menuitem icon="ui-icon-cockpit" id="showAnalysis" styleClass="element-with-whitespace" value=" #{localizedMessages.cockpit}" ajax="false" outcome="cockpit"> <f:param name="projectName" value="#{project}"/> </p:menuitem> - <p:separator/> - <p:menuitem id="copyButton" icon="ui-icon-copy" styleClass="element-with-whitespace" value=" #{localizedProjectOverviewMessages.copyProject}" action="#{currentProjectOverviewBean.setProjectName(project)}" onclick="copyProjectDialog.show()"/> - <p:menuitem id="renameButton" icon="ui-icon-edit" styleClass="element-with-whitespace" value=" #{localizedProjectOverviewMessages.renameProject}" action="#{currentProjectOverviewBean.setProjectName(project)}" onclick="renameProjectDialog.show()" disabled="true"/> - <p:menuitem id="deleteButton" icon="ui-icon-delete" styleClass="element-with-whitespace" value=" #{localizedProjectOverviewMessages.deleteProject}" action="#{currentProjectOverviewBean.setProjectName(project)}" onclick="deleteProjectDialog.show()" disabled="true"/> + <c:if test="#{sec:areAnyGranted('User, Administrator')}"> + <p:separator/> + <p:menuitem id="copyButton" icon="ui-icon-copy" styleClass="element-with-whitespace" value=" #{localizedProjectOverviewMessages.copyProject}" action="#{currentProjectOverviewBean.setProjectName(project)}" onclick="copyProjectDialog.show()"/> + <p:menuitem id="renameButton" icon="ui-icon-edit" styleClass="element-with-whitespace" value=" #{localizedProjectOverviewMessages.renameProject}" action="#{currentProjectOverviewBean.setProjectName(project)}" onclick="renameProjectDialog.show()" disabled="true"/> + <p:menuitem id="deleteButton" icon="ui-icon-delete" styleClass="element-with-whitespace" value=" #{localizedProjectOverviewMessages.deleteProject}" action="#{currentProjectOverviewBean.setProjectName(project)}" onclick="deleteProjectDialog.show()" disabled="true"/> + </c:if> </p:menu> </p:column> <p:column headerText="#{localizedProjectOverviewMessages.state}" style="text-align: center" sortBy="#{projectsBean.getAnalysisControllerState(project)}"> @@ -72,15 +81,15 @@ <p:column headerText="#{localizedProjectOverviewMessages.owner}" style="text-align: center"> <h:outputText value="N/A" /> </p:column> - + <p:column headerText="#{localizedProjectOverviewMessages.lastModification}" sortBy="#{projectsBean.getCurrTimeStamp(project)}" style="text-align: center"> <h:outputText value="#{projectsBean.getCurrTimeStamp(project)}" /> </p:column> - + <p:column headerText="#{localizedProjectOverviewMessages.lastEditor}" style="text-align: center"> <h:outputText value="N/A" /> </p:column> - + </p:dataTable> </h:form> </ui:define> diff --git a/Kieker.WebGUI/src/main/webapp/pages/admin/UserManagementPage.xhtml b/Kieker.WebGUI/src/main/webapp/pages/admin/UserManagementPage.xhtml index b44ced63add34c0e6cf1307409fe478788fce373..249419492bf20f530dd95a666857a8f2e6b8f33e 100644 --- a/Kieker.WebGUI/src/main/webapp/pages/admin/UserManagementPage.xhtml +++ b/Kieker.WebGUI/src/main/webapp/pages/admin/UserManagementPage.xhtml @@ -48,8 +48,8 @@ </p:menu> </p:column> - <p:column headerText="#{localizedUserManagementMessages.userroles}" sortBy="#{user.roles}"> - #{user.roles} + <p:column headerText="#{localizedUserManagementMessages.userrole}" sortBy="#{user.role}"> + #{user.role} </p:column> <p:column headerText="#{localizedUserManagementMessages.enabled}" sortBy="#{user.enabled}" style="text-align: center"> diff --git a/Kieker.WebGUI/src/main/webapp/templates/PagesTemplate.xhtml b/Kieker.WebGUI/src/main/webapp/templates/PagesTemplate.xhtml index 1c09d653f4d0a7ea9e3cad989a6270688c389f21..da0139079fd67133218f876906dcbcfa3a9faa8d 100644 --- a/Kieker.WebGUI/src/main/webapp/templates/PagesTemplate.xhtml +++ b/Kieker.WebGUI/src/main/webapp/templates/PagesTemplate.xhtml @@ -30,17 +30,21 @@ <p:button styleClass="perspective-button" icon="ui-icon-analysisEditor" value="#{localizedMessages.analysisEditor}" outcome="analysisEditor" disabled="#{pagename == 'analysisEditor' or empty projectName}"> <f:param name="projectName" value="#{projectName}" rendered="#{not empty projectName}"/> </p:button> - <p:button styleClass="perspective-button" icon="ui-icon-analysis" value="#{localizedMessages.analysis}" outcome="controller" disabled="#{pagename == 'controller' or empty projectName}"> - <f:param name="projectName" value="#{projectName}" rendered="#{not empty projectName}"/> - </p:button> + <c:if test="#{sec:areAnyGranted('User, Administrator')}"> + <p:button styleClass="perspective-button" icon="ui-icon-analysis" value="#{localizedMessages.analysis}" outcome="controller" disabled="#{pagename == 'controller' or empty projectName}"> + <f:param name="projectName" value="#{projectName}" rendered="#{not empty projectName}"/> + </p:button> + </c:if> <p:separator/> - <p:button styleClass="perspective-button" icon="ui-icon-cockpitEditor" value="#{localizedMessages.cockpitEditor}" outcome="cockpitEditor" disabled="#{pagename == 'cockpitEditor' or empty projectName}"> - <f:param name="projectName" value="#{projectName}" rendered="#{not empty projectName}"/> - </p:button> + <c:if test="#{sec:areAnyGranted('User, Administrator')}"> + <p:button styleClass="perspective-button" icon="ui-icon-cockpitEditor" value="#{localizedMessages.cockpitEditor}" outcome="cockpitEditor" disabled="#{pagename == 'cockpitEditor' or empty projectName}"> + <f:param name="projectName" value="#{projectName}" rendered="#{not empty projectName}"/> + </p:button> + </c:if> <p:button styleClass="perspective-button" icon="ui-icon-cockpit" value="#{localizedMessages.cockpit}" outcome="cockpit" disabled="#{pagename == 'cockpit' or empty projectName}"> <f:param name="projectName" value="#{projectName}" rendered="#{not empty projectName}"/> </p:button> - <c:if test="#{sec:areAnyGranted('ROLE_ADMIN')}"> + <c:if test="#{sec:areAnyGranted('Administrator')}"> <p:separator/> <p:button styleClass="perspective-button" icon="ui-icon-userManagement" value="User Management" outcome="userManagement" disabled="#{pagename == 'userManagement'}" /> </c:if> @@ -57,7 +61,7 @@ <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-about" value=" #{localizedMessages.about}" onclick="aboutDlg.show()" ajax="true"/> </p:submenu> - <p:menuitem styleClass="logOutButton element-with-whitespace" icon="ui-icon-logout" value=" #{userBean.username}" ajax="true" url="#{request.contextPath}/j_spring_security_logout"/> + <p:menuitem styleClass="logOutButton element-with-whitespace" icon="ui-icon-logout" value=" #{userBean.username} (#{userBean.userrole})" ajax="true" url="#{request.contextPath}/j_spring_security_logout"/> </p:menubar> <ui:insert name="furtherMenuBar"/> </h:form>