Jasig/cas — pull request #676 by mmoayyed (2014-08-24 09:35:39+00:00)
Title: Issue 468: Support for dynamic principal attributes

This fixes #468

# Summary
The idea of this pull request is to allow principal attributes to be retrieved upon requests, so that a fresh copy is always reported back to CAS. Presently, attributes are cached until the principal is forced to be resolved again.

Note that this behavior ideally may be considered an optional feature and should be turned on, if needed. Not everyone has a requirement to freshen up the state of attributes in CAS.

# How
To do this, principal objects are no longer allowed to be created directly. Rather, they must be obtained. The "thing" that creates them will produce a proper principal type that is able to retrieve attributes for CAS, and is the entity that decides whether attributes are cached for this principal or not.

So:

`SimplePrincipalFactory` creates `SimplePrincipal`
`NotCachingAttributesPrincipalFactory` creates `NotCachingAttributesPrincipal`

`NotCachingAttributesPrincipal` holds a reference to the attribute repository and will obtain attributes upon every request.

Factories are passed around in the context where needed. To create a principal, one would do:

```java
Principal p = new SimplePrincipalFactory().createPrincipal(...)
...
Principal p = new NotCachingAttributesPrincipalFactory(attributeRepository).createPrincipal(...)
```

# Default
Default behavior is preserved with no breaking API changes. The only significant work an adopter has to do is adjust the CASImpl configuration: