Few additional fixes to enable Client script access to Northbound. 66/1066/1
authorMadhu Venugopal <vmadhu@cisco.com>
Fri, 30 Aug 2013 21:55:01 +0000 (14:55 -0700)
committerMadhu Venugopal <vmadhu@cisco.com>
Fri, 30 Aug 2013 21:55:01 +0000 (14:55 -0700)
After Tomcat 7, httpOnly is true by default. This causes the httponly flag set on the Cookie.
This prevents the Scripts to access the cookie. setting it to false by default.
Due to the recent fix on disabling authentication for OPTIONS, if a script uses OPTIONS for an
NB-API, the username is null causing null pointer exception. Hence adding null pointer safety
checks on all the northbound APIs.

Change-Id: I726fd058b629c04695bf07d9fd52f6483d193b79
Signed-off-by: Madhu Venugopal <vmadhu@cisco.com>
opendaylight/distribution/opendaylight/src/main/resources/configuration/context.xml
opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthbound.java
opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java
opendaylight/northbound/networkconfiguration/bridgedomain/src/main/java/org/opendaylight/controller/networkconfig/bridgedomain/northbound/BridgeDomainNorthbound.java
opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthbound.java
opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java
opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthbound.java
opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthbound.java
opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundJAXRS.java

index 24c211ac47b5045dc7b71861ca8e256296ead095..90b9ddf1c8700d40407e5944de5eacafd59f1188 100644 (file)
@@ -1 +1 @@
-<Context crossContext="true" sessionCookiePath="/"/>
+<Context crossContext="true" sessionCookiePath="/" useHttpOnly="false"/>
index e863f99514adef7f8e339fd027c0f83d318b799f..2d270b44f98e23d65c0f03bddab1f913aabda7d5 100644 (file)
@@ -70,7 +70,7 @@ public class FlowProgrammerNorthbound {
 
     @Context
     public void setSecurityContext(SecurityContext context) {
 
     @Context
     public void setSecurityContext(SecurityContext context) {
-        username = context.getUserPrincipal().getName();
+        if (context != null && context.getUserPrincipal() != null) username = context.getUserPrincipal().getName();
     }
 
     protected String getUserName() {
     }
 
     protected String getUserName() {
index 2530d78416bf691dc2ea34bded2c8014fc574905..769461167c1036812ea33f17d0ffcf8f2b21a6c5 100644 (file)
@@ -78,7 +78,7 @@ public class HostTrackerNorthbound {
 
     @Context
     public void setSecurityContext(SecurityContext context) {
 
     @Context
     public void setSecurityContext(SecurityContext context) {
-        username = context.getUserPrincipal().getName();
+        if (context != null && context.getUserPrincipal() != null) username = context.getUserPrincipal().getName();
     }
 
     protected String getUserName() {
     }
 
     protected String getUserName() {
index 8aa1cf22fc780fe5a8937f580bfd50533e75ee7a..da7faa2c78d9cf9b4155ce244cbd190ea649b4a8 100644 (file)
@@ -56,7 +56,7 @@ public class BridgeDomainNorthbound {
 
     @Context
     public void setSecurityContext(SecurityContext context) {
 
     @Context
     public void setSecurityContext(SecurityContext context) {
-        username = context.getUserPrincipal().getName();
+        if (context != null && context.getUserPrincipal() != null) username = context.getUserPrincipal().getName();
     }
     protected String getUserName() {
         return username;
     }
     protected String getUserName() {
         return username;
index dceafac4abeb48facf3270a58322b1a5a1acc433..8462ef804ad0cce4c81819bd6b0369a675673566 100644 (file)
@@ -73,7 +73,7 @@ public class StaticRoutingNorthbound {
 
     @Context
     public void setSecurityContext(SecurityContext context) {
 
     @Context
     public void setSecurityContext(SecurityContext context) {
-        username = context.getUserPrincipal().getName();
+        if (context != null && context.getUserPrincipal() != null) username = context.getUserPrincipal().getName();
     }
     protected String getUserName() {
         return username;
     }
     protected String getUserName() {
         return username;
index acf6f864d1efb1a6c3192e31caff912707f6f214..a07f6435fe0e92e96d53eea61dd5abdffab921a3 100644 (file)
@@ -64,7 +64,7 @@ public class StatisticsNorthbound {
 
     @Context
     public void setSecurityContext(SecurityContext context) {
 
     @Context
     public void setSecurityContext(SecurityContext context) {
-        username = context.getUserPrincipal().getName();
+        if (context != null && context.getUserPrincipal() != null) username = context.getUserPrincipal().getName();
     }
 
     protected String getUserName() {
     }
 
     protected String getUserName() {
index 27650722460086fc227fb367ee1407026ddcf2d8..a5e805d396934ec719eb18086e069a25d7326788 100644 (file)
@@ -53,7 +53,7 @@ public class SubnetsNorthbound {
 
     @Context
     public void setSecurityContext(SecurityContext context) {
 
     @Context
     public void setSecurityContext(SecurityContext context) {
-        username = context.getUserPrincipal().getName();
+        if (context != null && context.getUserPrincipal() != null) username = context.getUserPrincipal().getName();
     }
 
     protected String getUserName() {
     }
 
     protected String getUserName() {
index 298a1c160056970241a08cd3c81294559a220f70..0f263ff38c4a4916f9745214b7022b5fdd37e328 100644 (file)
@@ -62,7 +62,7 @@ public class SwitchNorthbound {
 
     @Context
     public void setSecurityContext(SecurityContext context) {
 
     @Context
     public void setSecurityContext(SecurityContext context) {
-        username = context.getUserPrincipal().getName();
+        if (context != null && context.getUserPrincipal() != null) username = context.getUserPrincipal().getName();
     }
 
     protected String getUserName() {
     }
 
     protected String getUserName() {
index c4fb924d8a0b8aacd145f1ac43c02095b897808b..c20cb26885006f0f5a3234466bfb4445ed641033 100644 (file)
@@ -66,7 +66,7 @@ public class TopologyNorthboundJAXRS {
 
     @Context
     public void setSecurityContext(SecurityContext context) {
 
     @Context
     public void setSecurityContext(SecurityContext context) {
-        username = context.getUserPrincipal().getName();
+        if (context != null && context.getUserPrincipal() != null) username = context.getUserPrincipal().getName();
     }
 
     protected String getUserName() {
     }
 
     protected String getUserName() {