Showing 241 of 391 total issues

OidcProfile has 30 methods (exceeds 20 allowed). Consider refactoring.
Open

@ToString(callSuper = true)
@NoArgsConstructor
public class OidcProfile extends AbstractJwtProfile {

    @Serial
Severity: Minor
Found in pac4j-oidc/src/main/java/org/pac4j/oidc/profile/OidcProfile.java - About 3 hrs to fix

    Method removeOrRenewExpiredProfiles has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        protected void removeOrRenewExpiredProfiles(final LinkedHashMap<String, UserProfile> profiles, final boolean readFromSession) {
            var profilesUpdated = false;
            for (Iterator<Map.Entry<String, UserProfile>> profileIterator = profiles.entrySet().iterator(); profileIterator.hasNext(); ) {
                val entry= profileIterator.next();
                val key = entry.getKey();
    Severity: Minor
    Found in pac4j-core/src/main/java/org/pac4j/core/profile/ProfileManager.java - About 3 hrs 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 getBase64DecodedMessage has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        protected byte[] getBase64DecodedMessage() throws MessageDecodingException {
            Optional<String> encodedMessage = Optional.empty();
            for (val parameter : SAML_PARAMETERS) {
                encodedMessage = this.callContext.webContext().getRequestParameter(parameter);
                if (encodedMessage.isPresent()) {

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

        public void tryBuildDbAuthenticator(final Map<String, Authenticator> authenticators, final Map<String, PasswordEncoder> encoders) {
            for (var i = 0; i <= MAX_NUM_AUTHENTICATORS; i++) {
                if (containsProperty(DB_DATASOURCE_CLASS_NAME, i) || containsProperty(DB_JDBC_URL, i)) {
                    try {
                        val ds = buildDataSource(i);

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

        protected ClientAuthentication computeClientAuthentication() {
            val _clientID = new ClientID(configuration.getClientId());
    
            if (configuration.getSecret() != null) {
                // check authentication methods

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

        public void tryCreatePasswordEncoder(final Map<String, PasswordEncoder> encoders) {
            for (var i = 0; i <= MAX_NUM_ENCODERS; i++) {
                val exists = getProperty(SHIRO_ENCODER, i);
                val hasProperty =  containsProperty(SHIRO_ENCODER_GENERATE_PUBLIC_SALT, i)
                    || containsProperty(SHIRO_ENCODER_HASH_ALGORITHM_NAME, i)

    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 buildAuthnRequest has 83 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @SuppressWarnings("unchecked")
        protected final AuthnRequest buildAuthnRequest(final SAML2MessageContext context,
                                                       final Endpoint assertionConsumerService,
                                                       final Endpoint ssoService) {
            val configContext = context.getConfigurationContext();

      Method perform has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          public Object perform(final Config config, final String defaultUrl, final String inputLogoutUrlPattern, final Boolean inputLocalLogout,
                                final Boolean inputDestroySession, final Boolean inputCentralLogout, final FrameworkParameters parameters) {
      
              LOGGER.debug("=== LOGOUT ===");

        Method buildDataSource has 81 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private DataSource buildDataSource(final int i) throws SQLException {
                val ds = new HikariDataSource();
                if (containsProperty(DB_DATASOURCE_CLASS_NAME, i)) {
                    ds.setDataSourceClassName(getProperty(DB_DATASOURCE_CLASS_NAME, i));
                } else if (containsProperty(DB_JDBC_URL, i)) {

          Method generate has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              @Override
              public Optional<UserProfile> generate(final CallContext ctx, final UserProfile profile) {
          
                  if (profile instanceof KeycloakOidcProfile) {
                      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 convertAttributesToProfile has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

              protected U convertAttributesToProfile(final List<Map<String, Object>> listStorageAttributes, final String username) {
                  if (listStorageAttributes == null || listStorageAttributes.size() == 0) {
                      return null;
                  }
                  val storageAttributes = listStorageAttributes.get(0);

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

              public static Object getElement(final JsonNode json, final String name) {
                  if (json != null && name != null) {
                      var node = json;
                      for (var nodeName : name.split("\\.")) {
                          if (node != null) {
          Severity: Minor
          Found in pac4j-oauth/src/main/java/org/pac4j/oauth/profile/JsonHelper.java - About 2 hrs 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 tryCreateOidcClient has 69 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public void tryCreateOidcClient(final Collection<Client> clients) {
                  for (var i = 0; i <= MAX_NUM_CLIENTS; i++) {
                      val id = getProperty(OIDC_ID, i);
                      if (isNotBlank(id)) {
                          val configuration = new OidcConfiguration();

            Method hasOAuthClients has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

                protected boolean hasOAuthClients() {
                    if (isNotBlank(getProperty(LINKEDIN_ID)) && isNotBlank(getProperty(LINKEDIN_SECRET))) {
                        return true;
                    }
                    if (isNotBlank(getProperty(FACEBOOK_ID)) && isNotBlank(getProperty(FACEBOOK_SECRET))) {

            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 extract has 67 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @Override
                public Optional<Credentials> extract(final CallContext ctx) {
                    val webContext = ctx.webContext();
                    val logoutToken = webContext.getRequestParameter("logout_token");
                    val sid = webContext.getRequestParameter(Pac4jConstants.OIDC_CLAIM_SESSIONID);

              Method create has 67 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  @Override
                  @SuppressWarnings("unchecked")
                  public Optional<UserProfile> create(final CallContext ctx, final Credentials credentials) {
                      init();
              
              

                YahooProfile has 24 methods (exceeds 20 allowed). Consider refactoring.
                Open

                @SuppressWarnings("unchecked")
                public class YahooProfile extends OAuth10Profile {
                
                    @Serial
                    private static final long serialVersionUID = 791758805376191144L;

                  JEEContext has 24 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  @Deprecated
                  public class JEEContext implements WebContext {
                  
                      private final HttpServletRequest request;
                  
                  
                  Severity: Minor
                  Found in pac4j-javaee/src/main/java/org/pac4j/jee/context/JEEContext.java - About 2 hrs to fix

                    JEEContext has 24 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    public class JEEContext implements WebContext {
                    
                        private final HttpServletRequest request;
                    
                        private final HttpServletResponse response;
                    Severity: Minor
                    Found in pac4j-jakartaee/src/main/java/org/pac4j/jee/context/JEEContext.java - About 2 hrs to fix

                      SAML2MessageContext has 24 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      @Getter
                      @Setter
                      @ToString
                      public class SAML2MessageContext {
                      
                      
                        Severity
                        Category
                        Status
                        Source
                        Language