Sonar: Utility classes shouldn't have public constructor
[lispflowmapping.git] / mappingservice / implementation / src / main / java / org / opendaylight / lispflowmapping / implementation / authentication / LispAuthenticationUtil.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 org.opendaylight.lispflowmapping.interfaces.lisp.ILispAuthentication;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister;
13
14 public final class LispAuthenticationUtil {
15     // Utility class, should not be instantiated
16     private LispAuthenticationUtil() {
17     }
18
19     public static boolean validate(MapRegister mapRegister, String key) {
20         short keyId = 0;
21         if (mapRegister.getKeyId() != null) {
22             keyId = mapRegister.getKeyId();
23         }
24         ILispAuthentication authentication = LispAuthenticationFactory.getAuthentication(LispKeyIDEnum.valueOf(keyId));
25         return authentication.validate(mapRegister, key);
26     }
27
28     public static byte[] createAuthenticationData(MapNotify mapNotify, String key) {
29         ILispAuthentication authentication = LispAuthenticationFactory.getAuthentication(LispKeyIDEnum.valueOf(mapNotify.getKeyId()));
30         return authentication.getAuthenticationData(mapNotify, key);
31     }
32
33 }