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 javax.ws.rs.Path;
17 import javax.ws.rs.core.Context;
18 import javax.ws.rs.core.SecurityContext;
19 import javax.ws.rs.core.UriInfo;
22 * OVSDB Northbound V3 REST API
26 public class OvsdbNorthboundV3 {
28 private UriInfo _uriInfo;
29 private String username;
32 public void setSecurityContext(SecurityContext context) {
33 if (context != null && context.getUserPrincipal() != null) {
34 username = context.getUserPrincipal().getName();
38 protected String getUserName() {
43 public NodeResource getNode(){
44 if (!NorthboundUtils.isAuthorized(getUserName(), "default", Privilege.WRITE, this)) {
45 throw new UnauthorizedException("User is not authorized to perform this operation");
47 return new NodeResource();