Question: How am I supposed to know what `getDetails()`, `getPrincipal()` etc returns on `SecurityContextHolder.getContext().getAuthentication()`? The type is object and I can't make sense of whats written in the documentation.

Answer: 
`getDetails()` returns a WebAuthenticationDetails object which holds the user's IP address and SessionId (though I suspect this may depend on the type of application; since `getPrincipal()` is similarly dependent, it stands to reason that `getDetails()` might also vary in a like manner).

`getPrincipal()` returns an object which depends on how you're managing authentication. With LDAP authentication, for example, the `getPrincipal()` method returns an LdapUserDetailsImpl object.

If you need to access user/principal information, I'd set up a custom UserDetails class, and store/retrieve the information needed from there, but you could just as easily use `getPrincipal()` and `getDetails()` provided you cast them as an eligible class, or you extend the classes they naturally return (and manage them however you like).

It is somewhat amusing, I feel obligated to note, that the `getPrincipal()` method doesn't actually return a Principal object (nor can the LdapUserDetailsImpl object be cast as a Principal object).
How about this? (assuming `getPrincipal()` doesn't return `null`)

```
String className = SecurityContextHolder.getContext().getAuthentication().getPrincipal().getClass().getName();

```

It should return the class name attached with the package name, i.e the fully qualified class name. I think the type would be something (some spring-specific class) that implements [`java.security.Principal`](http://docs.oracle.com/javase/7/docs/api/java/security/Principal.html). So, you could do the following:

```
Principal p = (Principal) SecurityContextHolder.getContext().getAuthentication().getPrincipal();

```