2 * Copyright (c) 2014, 2015 Red Hat, 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
9 package org.opendaylight.ovsdb.northbound;
11 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
12 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
13 import org.opendaylight.controller.sal.authorization.Privilege;
15 import javax.ws.rs.Path;
16 import javax.ws.rs.core.Context;
17 import javax.ws.rs.core.SecurityContext;
18 import javax.ws.rs.core.UriInfo;
21 * OVSDB Northbound V3 REST API
25 public class OvsdbNorthboundV3 {
27 private UriInfo _uriInfo;
28 private String username;
31 public void setSecurityContext(SecurityContext context) {
32 if (context != null && context.getUserPrincipal() != null) {
33 username = context.getUserPrincipal().getName();
37 protected String getUserName() {
42 public NodeResource getNode(){
43 if (!NorthboundUtils.isAuthorized(getUserName(), "default", Privilege.WRITE, this)) {
44 throw new UnauthorizedException("User is not authorized to perform this operation");
46 return new NodeResource();