encryptorcode/iam-oauth

View on GitHub

Showing 399 of 407 total issues

Method login has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Confirmed

    public String login(HttpServletRequest request, HttpServletResponse response, String state, String grantCode) throws UserNotAllowedException {
        Map<String, OauthProvider> providers = configuration.oauthProviders;
        if (!providers.containsKey(state)) {
            LOGGER.log(Level.SEVERE, "INVALID_PROVIDER :: Redirecting the user to login page as given provider id is invalid: {0}", new String[]{state});
            return configuration.loginPath;

    Method initialize has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Confirmed

        public void initialize() {
            // Mandatory fields not set
            if (this.configuration.oauthProviders.size() == 0) {
                throw new RuntimeException("No oauth providers registered");
            }

      Method preProcessRequest has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Confirmed

          public void preProcessRequest(HttpServletRequest request, HttpServletResponse response) {
              AuthenticationThreadLocal.clear();
              AuthenticationThreadLocal.setCurrentRequest(request);
      
              String sessionIdentifier = getAuthCookieValue(request);

        Method login has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Confirmed

            public String login(HttpServletRequest request, HttpServletResponse response, String state, String grantCode) throws UserNotAllowedException {
                Map<String, OauthProvider> providers = configuration.oauthProviders;
                if (!providers.containsKey(state)) {
                    LOGGER.log(Level.SEVERE, "INVALID_PROVIDER :: Redirecting the user to login page as given provider id is invalid: {0}", new String[]{state});
                    return configuration.loginPath;

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Confirmed

            @Override
            public Session createSession(Session session) {
                context.insertInto(SESSIONS,
                        SESSIONS.IDENTIFIER,
                        SESSIONS.USER_ID,
        src/main/java/io/github/encryptorcode/implementation/storage/jdbc/JdbcUserHandler.java on lines 42..60

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 64.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Confirmed

            @Override
            public User createUser(User user) {
                context.insertInto(USERS,
                        USERS.USER_ID,
                        USERS.NAME,
        src/main/java/io/github/encryptorcode/implementation/storage/jdbc/JdbcSessionHandler.java on lines 34..51

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 64.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Method getLoginRedirectPath has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Confirmed

            public String getLoginRedirectPath(HttpServletRequest request, String providerId, String redirectPath) {
        
                // user is already logged in
                User user = getCurrentUser();
                if (user != null) {
        Severity: Minor
        Found in src/main/java/io/github/encryptorcode/service/AuthenticationService.java - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Confirmed

            @Override
            public AuthenticationDetail create(AuthenticationDetail detail) {
                AuthenticationDetail createdDetail = handler.create(detail);
                redisHandler.set(String.format(REDIS_KEY_FORMAT, detail.getUserId(), detail.getProvider()), detail);
                return createdDetail;
        src/main/java/io/github/encryptorcode/implementation/storage/redis/RedisAuthenticationHandler.java on lines 46..51

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 42.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Confirmed

            @Override
            public AuthenticationDetail update(AuthenticationDetail detail) {
                AuthenticationDetail createdDetail = handler.update(detail);
                redisHandler.set(String.format(REDIS_KEY_FORMAT, detail.getUserId(), detail.getProvider()), detail);
                return createdDetail;
        src/main/java/io/github/encryptorcode/implementation/storage/redis/RedisAuthenticationHandler.java on lines 39..44

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 42.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Method preProcessRequest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Confirmed

            public void preProcessRequest(HttpServletRequest request, HttpServletResponse response) {
                AuthenticationThreadLocal.clear();
                AuthenticationThreadLocal.setCurrentRequest(request);
        
                String sessionIdentifier = getAuthCookieValue(request);
        Severity: Minor
        Found in src/main/java/io/github/encryptorcode/service/AuthenticationService.java - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method getAuthCookie has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Confirmed

            private Cookie getAuthCookie(HttpServletRequest request) {
                Cookie[] cookies = request.getCookies();
                Cookie authCookie = null;
                if (cookies != null) {
                    for (Cookie cookie : cookies) {
        Severity: Minor
        Found in src/main/java/io/github/encryptorcode/service/AuthenticationService.java - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Extra separation in import group before 'java.util.UUID'
        Open

        import java.util.UUID;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Extra separation in import group before 'javax.servlet.http.Cookie'
        Open

        import javax.servlet.http.Cookie;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Wrong lexicographical order for 'java.util.Map' import. Should be before 'javax.servlet.http.HttpSession'.
        Open

        import java.util.Map;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 117).
        Open

            public static <Session extends ASession, User extends AUser> AuthenticationService<Session, User> getInstance() {

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 131).
        Open

                    LOGGER.log(Level.FINE, "Login page requested when the user is already logged in: {0}", new String[]{user.getUserId()});

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 127).
        Open

             * Call this method for every request. This method validates and sets details like current user and session in thread local

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 112).
        Open

            public AuthenticationInitializer<Session, User> setSecurityHandler(ASecurityHandler<User> securityHandler) {

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Empty line should be followed by <p> tag on the next line.</p>
        Open

         *

        Checks the Javadoc paragraph.

        Checks that:

        • There is one blank line between each of two paragraphs.
        • Each paragraph but the first has <p> immediately before the first word, withno space after.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Abbreviation in name 'EXPIRY_TIME' must contain no more than '2' consecutive capital letters.
        Open

            public final TableField<SESSIONS_RECORD, ZonedDateTime> EXPIRY_TIME =

        Validates abbreviations (consecutive capital letters) length in identifier name,it also allows to enforce camel case naming. Please read more atGoogle Style Guideto get to know how to avoid long abbreviations in names.

        allowedAbbreviationLength specifies how many consecutive capital letters areallowed in the identifier.A value of 3 indicates that up to 4 consecutive capital letters are allowed,one after the other, before a violation is printed. The identifier 'MyTEST' would beallowed, but 'MyTESTS' would not be.A value of 0 indicates that only 1 consecutive capital letter is allowed. Thisis what should be used to enforce strict camel casing. The identifier 'MyTest' wouldbe allowed, but 'MyTEst' would not be.

        ignoreFinal, ignoreStatic, and ignoreStaticFinalcontrol whether variables with the respective modifiers are to be ignored.Note that a variable that is both static and final will always be considered underignoreStaticFinal only, regardless of the values of ignoreFinaland ignoreStatic. So for example if ignoreStatic is true butignoreStaticFinal is false, then static final variables will not be ignored.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Severity
        Category
        Status
        Source
        Language