Merge "BUG 932 - Swagger HTTP POST contains incorrect object"
[controller.git] / opendaylight / netconf / netconf-testtool / src / main / java / org / opendaylight / controller / netconf / test / tool / AcceptingAuthProvider.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.netconf.test.tool;
10
11 import java.io.File;
12 import java.io.IOException;
13 import org.opendaylight.controller.netconf.ssh.authentication.AuthProvider;
14 import org.opendaylight.controller.netconf.ssh.authentication.PEMGenerator;
15
16 class AcceptingAuthProvider implements AuthProvider {
17     private final String privateKeyPEMString;
18
19     public AcceptingAuthProvider() {
20         try {
21             this.privateKeyPEMString = PEMGenerator.readOrGeneratePK(new File("PK"));
22         } catch (final IOException e) {
23             throw new RuntimeException(e);
24         }
25     }
26
27     @Override
28     public synchronized boolean authenticated(final String username, final String password) {
29         return true;
30     }
31
32     @Override
33     public char[] getPEMAsCharArray() {
34         return privateKeyPEMString.toCharArray();
35     }
36 }