+/*
+ * Copyright (c) 2014 Contextream, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.lispflowmapping.implementation.authentication;
import java.nio.ByteBuffer;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
-import org.opendaylight.lispflowmapping.implementation.serializer.MapNotifySerializer;
-import org.opendaylight.lispflowmapping.implementation.serializer.MapRegisterSerializer;
-import org.opendaylight.lispflowmapping.type.lisp.MapNotify;
-import org.opendaylight.lispflowmapping.type.lisp.MapRegister;
+import org.opendaylight.lispflowmapping.interfaces.lisp.ILispAuthentication;
+import org.opendaylight.lispflowmapping.lisp.serializer.MapNotifySerializer;
+import org.opendaylight.lispflowmapping.lisp.serializer.MapRegisterSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LispMACAuthentication implements ILispAuthentication {
- protected static final Logger logger = LoggerFactory.getLogger(LispMACAuthentication.class);
+ protected static final Logger LOG = LoggerFactory.getLogger(LispMACAuthentication.class);
protected String algorithm;
private byte[] tempAuthenticationData;
authenticationLength = Mac.getInstance(algorithm).getMacLength();
tempAuthenticationData = new byte[authenticationLength];
} catch (NoSuchAlgorithmException e) {
- logger.error("No such MAC algorithm" + algorithm);
+ LOG.warn("No such MAC algorithm {}", algorithm, e);
}
}
public boolean validate(MapRegister mapRegister, String key) {
if (key == null) {
+ LOG.warn("The authentication key is null!");
return false;
}
ByteBuffer mapRegisterBuffer = MapRegisterSerializer.getInstance().serialize(mapRegister);
return mac.doFinal(data);
} catch (InvalidKeyException e) {
- logger.error("Invalid password" + key);
+ LOG.warn("Invalid password {}", key, e);
} catch (NoSuchAlgorithmException e) {
- logger.error("No such MAC algorithm" + algorithm);
+ LOG.warn("No such MAC algorithm {}", algorithm, e);
}
return null;
}