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
8 package org.opendaylight.controller.netconf.ssh.authentication;
10 import java.io.IOException;
11 import org.opendaylight.controller.sal.authorization.AuthResultEnum;
12 import org.opendaylight.controller.usermanager.IUserManager;
13 import static com.google.common.base.Preconditions.checkNotNull;
15 public class AuthProvider implements AuthProviderInterface {
17 private IUserManager um;
18 private final String pem;
20 public AuthProvider(IUserManager ium, String pemCertificate) throws IllegalArgumentException, IOException {
21 checkNotNull(pemCertificate, "Parameter 'pemCertificate' is null");
22 checkNotNull(ium, "No user manager service available.");
28 public boolean authenticated(String username, String password) {
29 AuthResultEnum authResult = this.um.authenticate(username, password);
30 return authResult.equals(AuthResultEnum.AUTH_ACCEPT) || authResult.equals(AuthResultEnum.AUTH_ACCEPT_LOC);
34 public char[] getPEMAsCharArray() {
35 return pem.toCharArray();
39 public void removeUserManagerService() {
44 public void addUserManagerService(IUserManager userManagerService) {
45 this.um = userManagerService;