SAML2: add saml sso and slo apicmds skeleton, add classes to AuthManager

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
server: add opensaml as dependency

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
SAML: WIP redirections work now

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
ApiServer: change loginUser method signature to return ResponseObject

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
DefaultLoginAPIAuthenticatorCmd: move createLoginResponse to ApiServer

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
SAML2LoginAPIAuthenticatorCmd: Implement SAML SSO using HTTP Redirect binding

- Creates SAMLRequest and uses HTTP redirect binding (uses GET/302)
- Redirects to IdP for auth
- On successful auth, check for assertion
- Tries to get attributes based on standard LDAP attribute names
- Next, gets user using EntityManager, if not found creates one with NameID as UUID
- Finally tries to log in and redirect

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
ApiServlet: Fix NPE while inserting to auditTrail

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
ui: Unbox extra quotes from sessionKey cookie value

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
SAML2LoginAPIAuthenticatorCmd: Set all necessary cookies and redirect to UI

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
Minor fixes

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
ui: refactor and use a unified unboxing helping method in cloudStack.js

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
utils: refactor and aggregate methods in SAMLUtils

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
Maven: add opensaml 2.6.1 version id in pom.xml

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
saml: move refactor files from server to api module

- Move interfaces and classes from server to api module
- This can be then used for pluggable api authenticators

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
api: fix refactored ApiServerService interface to api

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
api: Add PluggableAPIAuthenticator interface

This interface is used by any plugin for implementing a pluggable API
authenticator such as SAML, OAuth etc.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
core: Add registry and beans in spring registry for PluggableAPIAuthenticator

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
saml2: Implement SAML2AuthServiceImpl which is a PluggableAPIAuthenticator

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
server: fix server package after auth plugin refactor

- Have opensaml dependency to get version from root pom
- add com.cloud.api.auth.APIAuthenticationManagerImpl to spring ctx manager
- Fix getCommands() in APIAuthenticationManagerImpl
- Fix imports in resources, test and src classes

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
saml2: Fix plugin after refactoring

- Use opensaml version from root pom
- Add utils and api as explicit dependency
- Add org.apache.cloudstack.saml.SAML2AuthServiceImpl bean
- Fix imports in all source files and resource xmls
- Use methods available from SAMLUtils to encode/decode SAML request/response
- SAML logout api is not the global logout api

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>