2 * Copyright (C) 2014 Red Hat, Inc. and others
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 * Authors : Madhu Venugopal
10 package org.opendaylight.ovsdb.northbound;
12 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
13 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
14 import org.opendaylight.controller.sal.authorization.Privilege;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 import javax.ws.rs.Path;
20 import javax.ws.rs.core.Context;
21 import javax.ws.rs.core.SecurityContext;
22 import javax.ws.rs.core.UriInfo;
25 * OVSDB Northbound V3 REST API
29 public class OvsdbNorthboundV3 {
30 protected static final Logger LOGGER = LoggerFactory.getLogger(OvsdbNorthboundV3.class);
33 private String username;
36 public void setSecurityContext(SecurityContext context) {
37 if (context != null && context.getUserPrincipal() != null) {
38 username = context.getUserPrincipal().getName();
42 protected String getUserName() {
47 public NodeResource getNode(){
48 if (!NorthboundUtils.isAuthorized(getUserName(), "default", Privilege.WRITE, this)) {
49 throw new UnauthorizedException("User is not authorized to perform this operation");
51 return new NodeResource();