vzakharchenko/keycloak-radius-plugin

View on GitHub

Showing 19 of 34 total issues

Method evaluateTriggers has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public void evaluateTriggers(RequiredActionContext context) {
        int daysToExpirePassword = context.getRealm().getPasswordPolicy()
                .getDaysToExpirePassword();
        if (daysToExpirePassword != -1) {

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 verifyChapPassword has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private boolean verifyChapPassword(String plaintext) {
        RadiusAttribute chapPasswordA = accessRequest.getAttribute(CHAP_PASSWORD);
        RadiusAttribute chapChallengeA = accessRequest.getAttribute(CHAP_CHALLENGE);
        if (chapPasswordA != null) {
            byte[] chapPassword = chapPasswordA.getValue();

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 isValid has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public boolean isValid(RealmModel realm, UserModel user,
                           CredentialInput credentialInput) {
        if (Objects.equals(credentialInput.getType(), getType())) {
            CredentialModel credentialModel = getCredentialStore(user)

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 verifyMSChapV2Password has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private boolean verifyMSChapV2Password(String plaintext) {

        if (msChapChallenge != null && msChap2Response != null) {
            if (plaintext == null || plaintext.isEmpty()) {
                LOGGER.warn("plaintext must not be empty");

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.
Open

package com.github.vzakharchenko.radius.radius.handlers.attributes;

import org.keycloak.models.KeycloakSession;
import org.tinyradius.packet.AccessRequest;
import org.keycloak.models.RoleModel;
keycloak-plugins/radius-plugin/src/main/java/com/github/vzakharchenko/radius/radius/handlers/attributes/GroupKeycloakAttributes.java on lines 1..36

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 72.

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.
Open

package com.github.vzakharchenko.radius.radius.handlers.attributes;

import org.keycloak.models.KeycloakSession;
import org.keycloak.models.GroupModel;
import org.tinyradius.packet.AccessRequest;
keycloak-plugins/radius-plugin/src/main/java/com/github/vzakharchenko/radius/radius/handlers/attributes/RoleKeycloakAttributes.java on lines 1..36

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 72.

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 prepareAnswer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public final RadiusPacket prepareAnswer(RadiusPacket answer) {
        RadiusPacket resAnswer = answer;
        IRadiusUserInfoGetter radiusUserInfoGetter = KeycloakSessionUtils
                .getRadiusUserInfo(session);

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 init has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    private boolean init(RadiusClientConnection clientConnection,
                         String username,
                         AuthProtocol protocol,
                         KeycloakSession threadSession,
                         RealmModel realm,

    Method generateAuthenticatorResponse has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

                byte[] password,
                byte[] ntResponse,
                byte[] peerChallenge,
                byte[] authenticatorChallenge,
                byte[] userName) throws NoSuchAlgorithmException {

      Method desEncrypt has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          private static void desEncrypt(byte[] clear,
                                         byte[] key, int keyOffset, byte[] cypher, int cypherOffset) {

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

        package com.github.vzakharchenko.radius.proxy.endpoints;
        
        import com.github.vzakharchenko.radius.radius.handlers.attributes.AttributeWalkerUtils;
        import org.keycloak.models.GroupModel;
        import org.keycloak.models.UserModel;
        keycloak-plugins/proxy-radius-plugin/src/main/java/com/github/vzakharchenko/radius/proxy/endpoints/RoleEndpointProvider.java on lines 1..30

        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 47.

        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.
        Open

        package com.github.vzakharchenko.radius.proxy.endpoints;
        
        import com.github.vzakharchenko.radius.radius.handlers.attributes.AttributeWalkerUtils;
        import org.keycloak.models.RoleModel;
        import org.keycloak.models.UserModel;
        keycloak-plugins/proxy-radius-plugin/src/main/java/com/github/vzakharchenko/radius/proxy/endpoints/GroupProxyEndpointProvider.java on lines 1..30

        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 47.

        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 runJobInTransaction has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public static <T> T runJobInTransaction(KeycloakSessionFactory factory,
                                                    KeycloakSessionTaskWithReturn<T> task) {
                KeycloakSession session = factory.create();
                KeycloakTransaction tx = session.getTransactionManager();
                try {

        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 read has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public KeycloakAttributes read() {
                Set<KEYCLOAK_TYPE> groups = getKeycloakTypes();
                for (KEYCLOAK_TYPE type : groups) {
                    Map<String, Set<String>> attributes = getAttributes(type);

        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 getPassword has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public RadiusCredentialModel getPassword(RealmModel realm, UserModel user) {
                List<CredentialModel> passwords = null;
                if (user instanceof CachedUserModel && !((CachedUserModel) user).isMarkedForEviction()) {
                    CachedUserModel cached = (CachedUserModel) user;

        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 handleAnswer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private RadiusPacket handleAnswer(AccessRequest request,
                                              AuthProtocol authProtocol,
                                              KeycloakSession threadSession,
                                              InetSocketAddress remoteAddress) {
                boolean init = authRequestInitialization.init(remoteAddress, request.getUserName(),

        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 fillAnswer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public void fillAnswer(RadiusPacket answer) {
                for (RadiusAttributeHolder<KEYCLOAK_TYPE> attributeHolder : attributeHolders) {
                    Map<String, Set<String>> attributes = attributeHolder.getAttributes();
                    for (Map.Entry<String, Set<String>> entry : attributes.entrySet()) {

        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 getSharedSecret has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public String getSharedSecret(InetSocketAddress address) {
                InetAddress inetAddress = address
                        .getAddress();
                if (inetAddress == null) {

        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 getServiceMap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static Map<String, List<IRadiusServiceProvider>> getServiceMap(
                    KeycloakSession session) {
                if (serviceMap.isEmpty()) {
                    Set<IRadiusServiceProvider> allProviders = session
                            .getAllProviders(IRadiusServiceProvider.class);

        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

        Severity
        Category
        Status
        Source
        Language