2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.northbound.commons;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
13 import org.springframework.security.authentication.AuthenticationProvider;
14 import org.springframework.security.core.Authentication;
15 import org.springframework.security.core.AuthenticationException;
17 import org.opendaylight.controller.sal.utils.ServiceHelper;
18 import org.opendaylight.controller.usermanager.IUserManager;
20 import org.opendaylight.controller.northbound.commons.exception.InternalServerErrorException;
22 public class AuthenticationProviderWrapper implements AuthenticationProvider {
24 private static final Logger logger = LoggerFactory
25 .getLogger(AuthenticationProviderWrapper.class);
28 public Authentication authenticate(Authentication authentication)
29 throws AuthenticationException {
30 return ((AuthenticationProvider) getUserManagerRef())
31 .authenticate(authentication);
35 public boolean supports(Class<?> authentication) {
36 return ((AuthenticationProvider) getUserManagerRef())
37 .supports(authentication);
40 private IUserManager getUserManagerRef() {
41 IUserManager userManager = (IUserManager) ServiceHelper
42 .getGlobalInstance(IUserManager.class, this);
43 if (userManager != null) {
46 logger.error("UserManager Ref is null. ");
47 throw new InternalServerErrorException("UserManager Ref is null. ");