#1032 Possible issue in MappingTokenProfileResolver.
Closed: migrated 3 years ago by dmoluguw. Opened 9 years ago by edewata.

The getTokenType() in MappingTokenProfileResolver is trying to get the token type of a mapping that matches the specified criteria. There seems to be a logic problem in the code. See the inline comments:

// targetTokenType is initially null
String targetTokenType = null;

// iterate through all mappings
for (String mappingId : mappingOrder.split(",")) {

    // set targetTokenType value
    targetTokenType = configStore.getString(mappingConfigName);

    // do various tests
    // if a test fails, go to the next mapping
    if (majorVersion != null && majorVersion.length() > 0) {

        int major = Integer.parseInt(majorVersion);

        if (major != major_version) {
            continue;
        }
    }

    // all tests passed, stop
    break;
}

// if targetTokenType is null, throw exception
if (targetTokenType == null) {
    throw new TPSException(...);
}

return targetTokenType;

The targetTokenType is assigned a value early in each iteration. If any of the test fails, the targetTokenType carries over the value to the next iteration. Suppose none of the mappings match the specified criteria, it probably should throw an exception. However, the current code will return the token type from the last iteration.

So the problem is it would not be possible to distinguish the following cases:

  • only the last mapping matches the criteria
  • none of the mappings matches the criteria

because in either case it returns the token type of the last mapping.

I think targetTokenType should only be assigned a value after all tests have passed:

String targetTokenType = null;

// iterate through all mappings
for (String mappingId : mappingOrder.split(",")) {

    // get token type
    String t = configStore.getString(mappingConfigName);

    // do various tests
    // if a test fails, go to the next mapping

    // all tests passed, set targetTokenType, then stop
    targetTokenType = t;
    break;
}  

Proposed milestone: 10.2 June


[06/04/2014] - Moving to Milestone 10.2.2 after discussions with cfu and jmagne.

Proposed Milestone: 10.2.2 (per CS Meeting of 09/17/2014)

Per 10.2.2 Triage meeting of 02/24/2015: 10.3

Metadata Update from @edewata:
- Issue assigned to cfu
- Issue set to the milestone: UNTRIAGED

7 years ago

Dogtag PKI is moving from Pagure issues to GitHub issues. This means that existing or new
issues will be reported and tracked through Dogtag PKI's GitHub Issue tracker.

This issue has been cloned to GitHub and is available here:
https://github.com/dogtagpki/pki/issues/1597

If you want to receive further updates on the issue, please navigate to the
GitHub issue and click on Subscribe button.

Thank you for understanding, and we apologize for any inconvenience.

Metadata Update from @dmoluguw:
- Issue close_status updated to: migrated
- Issue status updated to: Closed (was: Open)

3 years ago

Login to comment on this ticket.

Metadata