JUnit Test - LispSouthboundStatsTest
[lispflowmapping.git] / mappingservice / southbound / src / main / java / org / opendaylight / lispflowmapping / implementation / authentication / LispAuthenticationFactory.java
1 /*
2  * Copyright (c) 2014 Contextream, 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 package org.opendaylight.lispflowmapping.implementation.authentication;
9
10 import java.util.HashMap;
11 import java.util.Map;
12
13 import org.opendaylight.lispflowmapping.interfaces.lisp.ILispAuthentication;
14
15 public final class LispAuthenticationFactory {
16
17     private static Map<LispKeyIDEnum, ILispAuthentication> keyIDToAuthenticationMap;
18
19     // Class should not be instantiated
20     private LispAuthenticationFactory() {
21     }
22
23     private static void initializeMap() {
24         keyIDToAuthenticationMap = new HashMap<LispKeyIDEnum, ILispAuthentication>();
25         keyIDToAuthenticationMap.put(LispKeyIDEnum.NONE, LispNoAuthentication.getInstance());
26         keyIDToAuthenticationMap.put(LispKeyIDEnum.SHA1,
27                 new LispMACAuthentication(LispKeyIDEnum.SHA1.getAuthenticationName()));
28         keyIDToAuthenticationMap.put(LispKeyIDEnum.SHA256,
29                 new LispMACAuthentication(LispKeyIDEnum.SHA256.getAuthenticationName()));
30         keyIDToAuthenticationMap.put(LispKeyIDEnum.UNKNOWN, LispNoAuthentication.getInstance());
31
32     }
33
34     public static ILispAuthentication getAuthentication(LispKeyIDEnum keyID) {
35         if (keyIDToAuthenticationMap == null) {
36             initializeMap();
37         }
38         return keyIDToAuthenticationMap.get(keyID);
39     }
40
41 }