Question: I have a very big dictionary of dictionaries and it is like this:

```
Dict={,
    ...
    '25465466':{'Cmstrk': 'cms_trk_dcs_05:CAEN', 'Crate': 'easyCrate0', 'Board': 'easyBoard06', 'Branch': 'branchController05', 'TrackerSY': 'CMS_TRACKER_SY1527_4', 'Channel': 'channel003\n'},
    '436232302': {'Cmstrk': 'cms_trk_dcs_03:CAEN', 'Crate': 'easyCrate1', 'Board': 'easyBoard01', 'Branch': 'branchController05', 'TrackerSY': 'CMS_TRACKER_SY1527_8', 'Channel': 'channel002\n'},
    '470311412': {'Cmstrk': 'cms_trk_dcs_03:CAEN', 'Crate': 'easyCrate0', 'Board': 'easyBoard00', 'Branch': 'branchController05', 'TrackerSY': 'CMS_TRACKER_SY1527_4', 'Channel': 'channel003\n'},
    ...
} 

```

And if the user types `cms_trk_dcs_05:CAEN` or `easyCrate1/easyBoard01` or more combination of this values the script has to return those keys (numbers like '654546536') that they have in common.

For example if input is `easyCrate0/CMS_TRACKER_SY1527_4` the answer is `470311412,25465466`.

Answer: 
It is an odd thing to do you by yourself when this matter is very complex, difficult and has very good mature solutions including Apache Shiro and Spring Security. But I assume it's just an exercise in design patterns.

I would probably go for the chain of responsibility pattern. Have a generic interface like:

```
interface Authenticator {
    /**
    * Analyze the request and return an Authentication object
    * upon success, or null otherwise
    */
    Authentication authenticate(HttpServletRequest request);
}

```

Implement it for each authentication mechanism, checking cookies, POST data or what have you.

Then, call them like:

```
public Authentication authenticateRequest(HttpServletRequest request) {
    for (Authenticator ator : supportedAuthenticators) {
        Authentication a = ator.authenticate(request);
        if (a != null) {
            // Logged in successfully!
            return a;
        }
    }
    throw new LoginFailed();
}

```
I would suggest to have an interface which will have signatures of basic authentication methods,and the implementing class can have different definitions of those authentication methods.