ec86a7f0dadb4175a66638cda562706ce3229abb
[lispflowmapping.git] / mappingservice / implementation / src / main / java / org / opendaylight / lispflowmapping / implementation / MappingServiceShell.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc.  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;
9
10 import org.opendaylight.lispflowmapping.interfaces.mappingservice.IMappingService;
11 import org.opendaylight.lispflowmapping.interfaces.mappingservice.IMappingServiceShell;
12 import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkeyBuilder;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 /**
21  * @author Lorand Jakab
22  *
23  */
24 public class MappingServiceShell implements IMappingServiceShell {
25     protected static final Logger LOG = LoggerFactory.getLogger(MappingServiceShell.class);
26
27     private final IMappingService mappingService;
28
29     public MappingServiceShell(final IMappingService mappingService) {
30         this.mappingService = mappingService;
31     }
32
33     @Override
34     public String printMappings() {
35         return mappingService.printMappings();
36     }
37
38     @Override
39     public void addDefaultKeyIPv4() {
40         Eid eid = LispAddressUtil.toEid(new Ipv4Prefix("0.0.0.0/0"), null);
41         MappingAuthkey key = new MappingAuthkeyBuilder().setKeyType(1).setKeyString("password").build();
42         mappingService.addAuthenticationKey(eid, key);
43     }
44 }