X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-ssh%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fssh%2Fauthentication%2FAuthProvider.java;h=22dda95064c092c286a1046edc90595943485a0d;hp=a73dfdfd49eca56129a5ba0e98efb13fba001556;hb=91d7c1ee52322acad08e9f81228ac36b3aa684f5;hpb=0818295c3e0c6878853cb87285452854b565a6dd diff --git a/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/authentication/AuthProvider.java b/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/authentication/AuthProvider.java index a73dfdfd49..22dda95064 100644 --- a/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/authentication/AuthProvider.java +++ b/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/authentication/AuthProvider.java @@ -7,8 +7,6 @@ */ package org.opendaylight.controller.netconf.ssh.authentication; -import ch.ethz.ssh2.signature.RSAPrivateKey; -import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; @@ -17,26 +15,30 @@ import org.opendaylight.controller.sal.authorization.AuthResultEnum; import org.opendaylight.controller.sal.authorization.UserLevel; import org.opendaylight.controller.usermanager.IUserManager; import org.opendaylight.controller.usermanager.UserConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AuthProvider implements AuthProviderInterface { - private static RSAPrivateKey hostkey = null; private static IUserManager um; - private static final String DEAFULT_USER = "netconf"; - private static final String DEAFULT_PASSWORD = "netconf"; + private static final String DEFAULT_USER = "netconf"; + private static final String DEFAULT_PASSWORD = "netconf"; + private static InputStream privateKeyFileInputStream; + private static final Logger logger = LoggerFactory.getLogger(AuthProvider.class); - public AuthProvider(IUserManager ium) throws Exception { + public AuthProvider(IUserManager ium,InputStream privateKeyFileInputStream) throws Exception { this.um = ium; - if (this.um == null){ throw new Exception("No usermanager service available."); } + this.privateKeyFileInputStream = privateKeyFileInputStream; + List roles = new ArrayList(1); roles.add(UserLevel.SYSTEMADMIN.toString()); - this.um.addLocalUser(new UserConfig(DEAFULT_USER, DEAFULT_PASSWORD, roles)); + this.um.addLocalUser(new UserConfig(DEFAULT_USER, DEFAULT_PASSWORD, roles)); } @Override public boolean authenticated(String username, String password) throws Exception { @@ -51,15 +53,10 @@ public class AuthProvider implements AuthProviderInterface { } @Override - public char[] getPEMAsCharArray() { - - InputStream is = getClass().getResourceAsStream("/RSA.pk"); - try { - return IOUtils.toCharArray(is); - } catch (IOException e) { - e.printStackTrace(); - } - return null; + public char[] getPEMAsCharArray() throws Exception { + char [] PEM = IOUtils.toCharArray(privateKeyFileInputStream); + privateKeyFileInputStream.close(); + return PEM; } @Override