2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.lispflowmapping.northbound;
10 import java.util.List;
12 import javax.ws.rs.Consumes;
13 import javax.ws.rs.DELETE;
14 import javax.ws.rs.GET;
15 import javax.ws.rs.PUT;
16 import javax.ws.rs.Path;
17 import javax.ws.rs.PathParam;
18 import javax.ws.rs.Produces;
19 import javax.ws.rs.core.Context;
20 import javax.ws.rs.core.MediaType;
21 import javax.ws.rs.core.Response;
22 import javax.ws.rs.core.SecurityContext;
24 import org.codehaus.enunciate.jaxrs.ResponseCode;
25 import org.codehaus.enunciate.jaxrs.StatusCodes;
26 import org.codehaus.enunciate.jaxrs.TypeHint;
27 import org.opendaylight.controller.containermanager.IContainerManager;
28 import org.opendaylight.controller.northbound.commons.RestMessages;
29 import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
30 import org.opendaylight.controller.northbound.commons.exception.InternalServerErrorException;
31 import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
32 import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
33 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
34 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
35 import org.opendaylight.controller.sal.authorization.Privilege;
36 import org.opendaylight.controller.sal.utils.ServiceHelper;
37 import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
38 import org.opendaylight.lispflowmapping.type.AddressFamilyNumberEnum;
39 import org.opendaylight.lispflowmapping.type.LispCanonicalAddressFormatEnum;
40 import org.opendaylight.lispflowmapping.type.lisp.EidRecord;
41 import org.opendaylight.lispflowmapping.type.lisp.MapRequest;
42 import org.opendaylight.lispflowmapping.type.lisp.address.LispAddress;
43 import org.opendaylight.lispflowmapping.type.lisp.address.LispAddressGeneric;
44 import org.opendaylight.lispflowmapping.type.lisp.address.LispIpv4Address;
45 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapNotify;
46 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapReply;
47 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidtolocatorrecords.EidToLocatorRecord;
48 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.LispAddressContainer;
49 import org.slf4j.Logger;
50 import org.slf4j.LoggerFactory;
53 public class LispMappingNorthbound implements ILispmappingNorthbound {
54 protected static final Logger LOG = LoggerFactory.getLogger(LispMappingNorthbound.class);
55 private IFlowMapping mappingService;
57 private String userName;
59 // Based on code from controller project
61 public void setSecurityContext(SecurityContext context) {
62 if (context != null && context.getUserPrincipal() != null) {
63 userName = context.getUserPrincipal().getName();
67 protected String getUserName() {
71 public IFlowMapping getMappingService() {
72 return this.mappingService;
75 void setFlowMappingService(IFlowMapping mappingService) {
76 LOG.trace("FlowMapping set in LispNorthbound");
77 this.mappingService = mappingService;
80 void unsetFlowMappingService(IFlowMapping mappingService) {
81 LOG.trace("LispDAO was unset in LISP Northbound");
82 this.mappingService = null;
86 LOG.trace("LISP Northbound Service is initialized!");
90 LOG.info("LISP Northbound Service is up!");
94 LOG.info("LISP Northbound Service is down!");
97 public void destroy() {
98 LOG.trace("LISP Northbound Service is destroyed!");
99 mappingService = null;
102 // Based on code from controller project
103 private void handleContainerDoesNotExist(String containerName) {
104 IContainerManager containerManager = (IContainerManager) ServiceHelper.getGlobalInstance(IContainerManager.class, this);
105 if (containerManager == null) {
106 throw new ServiceUnavailableException("Container " + containerName + RestMessages.NOCONTAINER.toString());
109 List<String> containerNames = containerManager.getContainerNames();
110 for (String cName : containerNames) {
111 if (cName.trim().equalsIgnoreCase(containerName.trim())) {
116 throw new ResourceNotFoundException("Container " + containerName + " " + RestMessages.NOCONTAINER.toString());
119 private void authorizationCheck(String containerName, Privilege privilege) {
121 if (!NorthboundUtils.isAuthorized(getUserName(), containerName, privilege, this)) {
122 throw new UnauthorizedException("User is not authorized to perform this operation on container " + containerName);
126 private EidToLocatorRecord lookupEID(String containerName, int mask, LispAddress EID) {
128 ILispmappingNorthbound nbService = (ILispmappingNorthbound) ServiceHelper.getInstance(ILispmappingNorthbound.class, containerName, this);
130 MapRequest mapRequest = new MapRequest();
131 EidRecord EIDRecord = new EidRecord((byte) mask, EID);
132 mapRequest.addEidRecord(EIDRecord);
133 mapRequest.setSourceEid(new LispIpv4Address("127.0.0.1"));
135 org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRequest mr = YangTransformerNB.transformMapRequest(mapRequest);
138 mapReply = nbService.getMappingService().handleMapRequest(mr);
139 } catch (Exception e) {
140 throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error looking up the EID");
143 if (mapReply == null) {
144 throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error looking up the EID");
147 return mapReply.getEidToLocatorRecord().get(0);
150 private void keyCheck(IFlowMapping mappingService, MapRegisterNB mapRegisterNB) {
152 String usedKey = mapRegisterNB.getKey();
154 LispAddressGeneric lispAddressGeneric;
155 LispAddress lispAddress;
159 int numEidRecords = mapRegisterNB.getMapRegister().getEidToLocatorRecords().size();
161 for (int i = 0; i < numEidRecords; i++) {
163 lispAddressGeneric = mapRegisterNB.getMapRegister().getEidToLocatorRecords().get(i).getPrefixGeneric();
166 lispAddress = LispAddressConvertorNB.convertToLispAddress(lispAddressGeneric);
167 } catch (Exception e) {
168 throw new BadRequestException(RestMessages.INVALIDDATA.toString() + " : Address is not valid");
170 mask = mapRegisterNB.getMapRegister().getEidToLocatorRecords().get(i).getMaskLength();
172 storedKey = mappingService.getAuthenticationKey(YangTransformerNB.transformLispAddress(lispAddress), mask);
173 } catch (Exception e) {
174 throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error while retrieving the key");
177 if (!usedKey.equals(storedKey)) {
178 throw new UnauthorizedException("The key used to register the mapping " + "does not match with the stored key for that mapping");
184 * Add a mapping to the LISP mapping system
186 * @param containerName
187 * name of the container context in which the mapping needs to be
189 * @param mapRegisterNB
190 * JSON object that contains the mapping information
192 * @return Text plain confirming reception
198 * http://localhost:8080/lispflowmapping/nb/v2/default/mapping
200 * Request body in JSON:
206 * "wantMapNotify" : true,
207 * "proxyMapReply" : false,
208 * "eidToLocatorRecords" :
211 * "authoritative" : true,
214 * "ipAddress" : "10.0.0.1",
219 * "action" : "NoAction",
223 * "multicastPriority" : 3,
226 * "ipAddress" : "3.3.3.3",
230 * "multicastWeight" : 3,
231 * "rlocProbed" : false,
232 * "localLocator" : false,
247 @Path("/{containerName}/mapping")
249 @Consumes(MediaType.APPLICATION_JSON)
250 @StatusCodes({ @ResponseCode(code = 400, condition = "Invalid data passed"),
251 @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
252 @ResponseCode(code = 404, condition = "The containerName passed was not found"),
253 @ResponseCode(code = 500, condition = "Internal Server Error: Addition of mapping failed"),
254 @ResponseCode(code = 503, condition = "Service unavailable") })
255 public Response addMapping(@PathParam("containerName") String containerName, @TypeHint(MapRegisterNB.class) MapRegisterNB mapRegisterNB) {
257 handleContainerDoesNotExist(containerName);
259 authorizationCheck(containerName, Privilege.WRITE);
261 ILispmappingNorthbound nbService = (ILispmappingNorthbound) ServiceHelper.getInstance(ILispmappingNorthbound.class, containerName, this);
264 keyCheck(nbService.getMappingService(), mapRegisterNB);
266 LispAddressConvertorNB.convertGenericToLispAddresses(mapRegisterNB.getMapRegister());
267 } catch (Exception e) {
268 throw new BadRequestException(RestMessages.INVALIDDATA.toString() + " : Address is not valid");
270 // Always request MapNotify
271 mapRegisterNB.getMapRegister().setWantMapNotify(true);
273 org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRegister mr = null;
275 mr = YangTransformerNB.transformMapRegister(mapRegisterNB.getMapRegister());
276 } catch (Exception e) {
277 throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error while converting the map register");
282 mapNotify = nbService.getMappingService().handleMapRegister(mr);
283 } catch (Exception e) {
284 throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error while registering the mapping");
287 if (mapNotify == null) {
288 throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error while registering the mapping");
290 return Response.status(Response.Status.OK).build();
294 * Retrieve a mapping from the LISP mapping system
296 * @param containerName
297 * name of the container context from which the mapping is going
300 * Instance-ID of the address (0 if none)
303 * Address Family of the address (IPv4, IPv6 or MAC)
306 * Address of type defined by afi
309 * Network mask length
311 * @return EidToLocatorRecord as a JSON object
317 * http://localhost:8080/lispflowmapping/nb/v2/default/mapping/0/1/10.0.0.1/32
322 private LispAddressGeneric parseAddressURL(int iid, int afi, String address, int mask) {
323 LispAddressGeneric eidGeneric = new LispAddressGeneric(afi, address);
326 eidGeneric = new LispAddressGeneric(AddressFamilyNumberEnum.LCAF.getIanaCode(), eidGeneric);
327 eidGeneric.setLcafType(LispCanonicalAddressFormatEnum.SEGMENT.getLispCode());
328 eidGeneric.setInstanceId(iid);
334 private LispAddressGeneric parseSrcDstAddressURL(int iid, int afi, String srcAdd, int srcML, String dstAdd, int dstML) {
335 LispAddressGeneric srcGeneric = new LispAddressGeneric(afi, srcAdd);
336 LispAddressGeneric dstGeneric = new LispAddressGeneric(afi, dstAdd);
339 srcGeneric = new LispAddressGeneric(AddressFamilyNumberEnum.LCAF.getIanaCode(), srcGeneric);
340 srcGeneric.setLcafType(LispCanonicalAddressFormatEnum.SEGMENT.getLispCode());
341 srcGeneric.setInstanceId(iid);
343 dstGeneric = new LispAddressGeneric(AddressFamilyNumberEnum.LCAF.getIanaCode(), dstGeneric);
344 dstGeneric.setLcafType(LispCanonicalAddressFormatEnum.SEGMENT.getLispCode());
345 dstGeneric.setInstanceId(iid);
348 LispAddressGeneric address = new LispAddressGeneric(AddressFamilyNumberEnum.LCAF.getIanaCode());
350 address.setLcafType(LispCanonicalAddressFormatEnum.SOURCE_DEST.getLispCode());
351 address.setSrcAddress(srcGeneric);
352 address.setSrcMaskLength((byte) srcML);
353 address.setDstAddress(dstGeneric);
354 address.setDstMaskLength((byte) dstML);
359 @Path("/{containerName}/mapping/{iid}/{afi}/{address}/{mask}")
361 @Produces(MediaType.APPLICATION_JSON)
362 @StatusCodes({ @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
363 @ResponseCode(code = 400, condition = "Invalid data passed"),
364 @ResponseCode(code = 404, condition = "The containerName passed was not found"),
365 @ResponseCode(code = 500, condition = "Internal Server Error: Get mapping failed"),
366 @ResponseCode(code = 503, condition = "Service unavailable") })
367 public org.opendaylight.lispflowmapping.type.lisp.EidToLocatorRecord getMapping(@PathParam("containerName") String containerName,
368 @PathParam("iid") int iid, @PathParam("afi") int afi, @PathParam("address") String address, @PathParam("mask") int mask) {
370 handleContainerDoesNotExist(containerName);
372 authorizationCheck(containerName, Privilege.READ);
374 LispAddressGeneric eidGeneric = parseAddressURL(iid, afi, address, mask);
378 eid = LispAddressConvertorNB.convertToLispAddress(eidGeneric);
379 } catch (Exception e) {
380 throw new BadRequestException(RestMessages.INVALIDDATA.toString() + " : Address is not valid");
383 EidToLocatorRecord record = lookupEID(containerName, mask, eid);
385 org.opendaylight.lispflowmapping.type.lisp.EidToLocatorRecord legacyRecord = YangTransformerNB.reTransformEidToLocatorRecord(record);
386 LispAddressConvertorNB.convertRecordToGenericAddress(legacyRecord);
392 * Retrieve a mapping from the LISP mapping system, using Source-Destination
395 * @param containerName
396 * name of the container context from which the mapping is going
399 * Instance-ID of the addresses (0 if none)
402 * Address Family of the addresses (IPv4, IPv6 or MAC)
405 * Source address of type defined by afi
408 * Network mask length of the source address
411 * Destination address of type defined by afi
414 * Network mask length of the destination address
416 * @return EidToLocatorRecord as a JSON object
423 * http://localhost:8080/lispflowmapping/nb/v2/default/mapping/0/1/10.0.0.1/32/20.0.0.2/32
428 @Path("/{containerName}/mapping/{iid}/{afi}/{srcAdd}/{srcML}/{dstAdd}/{dstML}")
430 @Produces(MediaType.APPLICATION_JSON)
431 @StatusCodes({ @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
432 @ResponseCode(code = 404, condition = "The containerName passed was not found"),
433 @ResponseCode(code = 503, condition = "Service unavailable") })
434 public org.opendaylight.lispflowmapping.type.lisp.EidToLocatorRecord getMapping(@PathParam("containerName") String containerName,
435 @PathParam("iid") int iid, @PathParam("afi") int afi, @PathParam("srcAdd") String srcAdd, @PathParam("srcML") int srcML,
436 @PathParam("dstAdd") String dstAdd, @PathParam("dstML") int dstML) {
438 handleContainerDoesNotExist(containerName);
440 authorizationCheck(containerName, Privilege.READ);
442 LispAddressGeneric eidGeneric = parseSrcDstAddressURL(iid, afi, srcAdd, srcML, dstAdd, dstML);
444 int mask = 0; // Not used here
446 EidToLocatorRecord record = lookupEID(containerName, mask, LispAddressConvertorNB.convertToLispAddress(eidGeneric));
448 org.opendaylight.lispflowmapping.type.lisp.EidToLocatorRecord legacyRecord = YangTransformerNB.reTransformEidToLocatorRecord(record);
449 LispAddressConvertorNB.convertRecordToGenericAddress(legacyRecord);
455 * Set the authentication key for an EID prefix
457 * @param containerName
458 * name of the container context in which the key needs to be set
460 * JSON object that contains the key information
462 * @return Text plain confirming reception
468 * http://localhost:8080/lispflowmapping/nb/v2/default/key
470 * Request body in JSON:
477 * "ipAddress" : "10.0.0.1",
485 @Path("/{containerName}/key")
487 @Consumes(MediaType.APPLICATION_JSON)
488 @StatusCodes({ @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
489 @ResponseCode(code = 400, condition = "Invalid data passed"),
490 @ResponseCode(code = 404, condition = "The containerName passed was not found"),
491 @ResponseCode(code = 500, condition = "Internal Server Error: Addition of key failed"),
492 @ResponseCode(code = 503, condition = "Service unavailable") })
493 public Response addAuthKey(@PathParam("containerName") String containerName, @TypeHint(AuthKeyNB.class) AuthKeyNB authKeyNB) {
495 handleContainerDoesNotExist(containerName);
497 authorizationCheck(containerName, Privilege.WRITE);
499 LispAddress lispAddress;
501 lispAddress = LispAddressConvertorNB.convertToLispAddress(authKeyNB.getAddress());
502 } catch (Exception e) {
503 throw new BadRequestException(RestMessages.INVALIDDATA.toString() + " : Address is not valid");
505 ILispmappingNorthbound nbService = (ILispmappingNorthbound) ServiceHelper.getInstance(ILispmappingNorthbound.class, containerName, this);
509 nbService.getMappingService().addAuthenticationKey(YangTransformerNB.transformLispAddress(lispAddress), authKeyNB.getMaskLength(),
511 } catch (Exception e) {
512 throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error while adding the key");
515 return Response.status(Response.Status.OK).build();
519 * Retrieve the key used to register an EID prefix
521 * @param containerName
522 * name of the container context from which the key is going to
526 * Address Family of the address (IPv4, IPv6 or MAC)
529 * Address of type defined by afi
532 * Network mask length
534 * @return AuthKeyNB as a JSON object
540 * http://localhost:8080/lispflowmapping/nb/v2/default/key/0/1/10.0.0.1/32
545 @Path("/{containerName}/key/{iid}/{afi}/{address}/{mask}")
547 @Produces(MediaType.APPLICATION_JSON)
548 @StatusCodes({ @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
549 @ResponseCode(code = 400, condition = "Invalid data passed"),
550 @ResponseCode(code = 404, condition = "The containerName passed was not found"),
551 @ResponseCode(code = 500, condition = "Internal Server Error: Get key failed"),
552 @ResponseCode(code = 503, condition = "Service unavailable") })
553 public AuthKeyNB getAuthKey(@PathParam("containerName") String containerName, @PathParam("iid") int iid, @PathParam("afi") int afi,
554 @PathParam("address") String address, @PathParam("mask") int mask) {
556 handleContainerDoesNotExist(containerName);
558 authorizationCheck(containerName, Privilege.READ);
560 LispAddressGeneric lispAddressGeneric = parseAddressURL(iid, afi, address, mask);
562 LispAddress lispAddress;
565 lispAddress = LispAddressConvertorNB.convertToLispAddress(lispAddressGeneric);
566 } catch (Exception e) {
567 throw new BadRequestException(RestMessages.INVALIDDATA.toString() + " : Address is not valid");
569 ILispmappingNorthbound nbService = (ILispmappingNorthbound) ServiceHelper.getInstance(ILispmappingNorthbound.class, containerName, this);
573 key = nbService.getMappingService().getAuthenticationKey(YangTransformerNB.transformLispAddress(lispAddress), mask);
574 } catch (Exception e) {
575 throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error while retrieving the key");
579 throw new ResourceNotFoundException(RestMessages.NORESOURCE.toString() + " : The requested key was not found");
582 AuthKeyNB authKeyNB = new AuthKeyNB();
584 authKeyNB.setKey(key);
585 authKeyNB.setAddress(lispAddressGeneric);
586 authKeyNB.setMaskLength(mask);
592 * Retrieve a key used to register a Source-Destination LCAF EID prefix
594 * @param containerName
595 * name of the container context from which the key is going to
599 * Address Family of the addresses (IPv4, IPv6 or MAC)
602 * Source address of type defined by afi
605 * Network mask length of the source address
608 * Destination address of type defined by afi
611 * Network mask length of the destination address
613 * @return AuthKeyNB as a JSON object
620 * http://localhost:8080/lispflowmapping/nb/v2/default/key/0/1/10.0.0.1/32/20.0.0.2/32
625 @Path("/{containerName}/key/{iid}/{afi}/{srcAdd}/{srcML}/{dstAdd}/{dstML}")
627 @Produces(MediaType.APPLICATION_JSON)
628 @StatusCodes({ @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
629 @ResponseCode(code = 404, condition = "The containerName passed was not found"),
630 @ResponseCode(code = 503, condition = "Service unavailable") })
631 public AuthKeyNB getAuthKey(@PathParam("containerName") String containerName, @PathParam("iid") int iid, @PathParam("afi") int afi,
632 @PathParam("srcAdd") String srcAdd, @PathParam("srcML") int srcML, @PathParam("dstAdd") String dstAdd, @PathParam("dstML") int dstML) {
634 handleContainerDoesNotExist(containerName);
636 authorizationCheck(containerName, Privilege.READ);
638 LispAddressGeneric lispAddressGeneric = parseSrcDstAddressURL(iid, afi, srcAdd, srcML, dstAdd, dstML);
640 LispAddress lispAddress = LispAddressConvertorNB.convertToLispAddress(lispAddressGeneric);
642 ILispmappingNorthbound nbService = (ILispmappingNorthbound) ServiceHelper.getInstance(ILispmappingNorthbound.class, containerName, this);
644 int mask = 0; // Not used here
646 LispAddressContainer yangAddress = YangTransformerNB.transformLispAddress(lispAddress);
648 String key = nbService.getMappingService().getAuthenticationKey(yangAddress, mask);
651 throw new ResourceNotFoundException(RestMessages.NORESOURCE.toString() + " : The requested key was not found");
654 AuthKeyNB authKeyNB = new AuthKeyNB();
656 authKeyNB.setKey(key);
657 authKeyNB.setAddress(lispAddressGeneric);
658 authKeyNB.setMaskLength(mask);
664 * Delete the key used to register an EID prefix
666 * @param containerName
667 * name of the container context from which the key is going to
671 * Address Family of the address (IPv4, IPv6 or MAC)
674 * Address of type defined by afi
677 * Network mask length
679 * @return Text plain confirming deletion
685 * http://localhost:8080/lispflowmapping/nb/v2/default/key/0/1/10.0.0.1/32
690 @Path("/{containerName}/key/{iid}/{afi}/{address}/{mask}")
692 @StatusCodes({ @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
693 @ResponseCode(code = 400, condition = "Invalid data passed"),
694 @ResponseCode(code = 404, condition = "The containerName passed was not found"),
695 @ResponseCode(code = 500, condition = "Internal Server Error: Delete key failed"),
696 @ResponseCode(code = 503, condition = "Service unavailable") })
697 public Response delAuthKey(@PathParam("containerName") String containerName, @PathParam("afi") int afi, @PathParam("iid") int iid,
698 @PathParam("address") String address, @PathParam("mask") int mask) {
700 handleContainerDoesNotExist(containerName);
702 authorizationCheck(containerName, Privilege.WRITE);
704 LispAddressGeneric lispAddressGeneric = parseAddressURL(iid, afi, address, mask);
706 LispAddress lispAddress;
708 lispAddress = LispAddressConvertorNB.convertToLispAddress(lispAddressGeneric);
709 } catch (Exception e) {
710 throw new BadRequestException(RestMessages.INVALIDDATA.toString() + " : Address is not valid");
713 ILispmappingNorthbound nbService = (ILispmappingNorthbound) ServiceHelper.getInstance(ILispmappingNorthbound.class, containerName, this);
716 nbService.getMappingService().removeAuthenticationKey(YangTransformerNB.transformLispAddress(lispAddress), mask);
717 } catch (Exception e) {
718 throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error while deleting the key");
721 return Response.status(Response.Status.OK).build();
725 * Delete the key used to register an EID prefix
727 * @param containerName
728 * name of the container context from which the key is going to
732 * Address Family of the addresses (IPv4, IPv6 or MAC)
735 * Source address of type defined by afi
738 * Network mask length of the source address
741 * Destination address of type defined by afi
744 * Network mask length of the destination address
746 * @return AuthKeyNB as a JSON object
752 * http://localhost:8080/lispflowmapping/nb/v2/default/key/0/1/10.0.0.1/32/20.0.0.2/32
757 @Path("/{containerName}/key/{iid}/{afi}/{srcAdd}/{srcML}/{dstAdd}/{dstML}")
759 @StatusCodes({ @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
760 @ResponseCode(code = 400, condition = "Invalid data passed"),
761 @ResponseCode(code = 404, condition = "The containerName passed was not found"),
762 @ResponseCode(code = 500, condition = "Internal Server Error: Delete key failed"),
763 @ResponseCode(code = 503, condition = "Service unavailable") })
764 public Response delAuthKey(@PathParam("containerName") String containerName, @PathParam("iid") int iid, @PathParam("afi") int afi,
765 @PathParam("srcAdd") String srcAdd, @PathParam("srcML") int srcML, @PathParam("dstAdd") String dstAdd, @PathParam("dstML") int dstML) {
767 handleContainerDoesNotExist(containerName);
769 authorizationCheck(containerName, Privilege.WRITE);
771 LispAddressGeneric lispAddressGeneric = parseSrcDstAddressURL(iid, afi, srcAdd, srcML, dstAdd, dstML);
773 LispAddress lispAddress;
775 lispAddress = LispAddressConvertorNB.convertToLispAddress(lispAddressGeneric);
776 } catch (Exception e) {
777 throw new BadRequestException(RestMessages.INVALIDDATA.toString() + " : Address is not valid");
780 ILispmappingNorthbound nbService = (ILispmappingNorthbound) ServiceHelper.getInstance(ILispmappingNorthbound.class, containerName, this);
782 int mask = 0; // Not used here
785 nbService.getMappingService().removeAuthenticationKey(YangTransformerNB.transformLispAddress(lispAddress), mask);
786 } catch (Exception e) {
787 throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error while deleting the key");
790 return Response.status(Response.Status.OK).build();