* Authentication realm : <b>opendaylight</b><br>
* Transport : <b>HTTP and HTTPS</b><br>
* <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in tomcat-server.xml after adding
+ * HTTPS Authentication is disabled by default. Administrator can enable it in tomcat-server.xml after adding
* a proper keystore / SSL certificate from a trusted authority.<br>
* More info : http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
*/
@Path("/")
public class StaticRoutingNorthbound {
+ private String username;
- private String username;
-
@Context
public void setSecurityContext(SecurityContext context) {
- username = context.getUserPrincipal().getName();
+ username = context.getUserPrincipal().getName();
}
protected String getUserName() {
return username;
}
-
-
+
+
private List<StaticRoute> getStaticRoutesInternal(String containerName) {
IForwardingStaticRouting staticRouting = (IForwardingStaticRouting) ServiceHelper
public StaticRoutes getStaticRoutes(
@PathParam("containerName") String containerName) {
- if(!NorthboundUtils.isAuthorized(getUserName(), containerName,
+ if(!NorthboundUtils.isAuthorized(getUserName(), containerName,
Privilege.WRITE, this)){
- throw new
+ throw new
UnauthorizedException("User is not authorized to perform this operation on container "
+ containerName);
}
@PathParam("containerName") String containerName,
@PathParam("name") String name) {
- if(!NorthboundUtils.isAuthorized(getUserName(), containerName,
+ if(!NorthboundUtils.isAuthorized(getUserName(), containerName,
Privilege.WRITE, this)){
- throw new
+ throw new
UnauthorizedException("User is not authorized to perform this operation on container "
+ containerName);
}
@PathParam(value = "name") String name,
@TypeHint(StaticRoute.class) JAXBElement<StaticRoute> staticRouteData) {
-
- if(!NorthboundUtils.isAuthorized(getUserName(), containerName,
+
+ if(!NorthboundUtils.isAuthorized(getUserName(), containerName,
Privilege.WRITE, this)){
- throw new
+ throw new
UnauthorizedException("User is not authorized to perform this operation on container "
+ containerName);
}
sRoute.getPrefix(), sRoute.getNextHop());
Status response = staticRouting.addStaticRoute(cfgObject);
if (response.isSuccess()) {
+ NorthboundUtils.auditlog("Static Route", username, "added", name, containerName);
return Response.status(Response.Status.CREATED).build();
}
throw new ResourceConflictException(response.getDescription());
public Response removeStaticRoute(
@PathParam(value = "containerName") String containerName,
@PathParam(value = "name") String name) {
-
- if(!NorthboundUtils.isAuthorized(getUserName(), containerName,
+
+ if(!NorthboundUtils.isAuthorized(getUserName(), containerName,
Privilege.WRITE, this)){
- throw new
+ throw new
UnauthorizedException("User is not authorized to perform this operation on container "
+ containerName);
}
Status status = staticRouting.removeStaticRoute(name);
if (status.isSuccess()) {
+ NorthboundUtils.auditlog("Static Route", username, "removed", name, containerName);
return Response.ok().build();
}
throw new ResourceNotFoundException(status.getDescription());