Revision: 15184
Author: emmartins
Date: Thu Nov 11 02:55:08 2010
Log: adding option to enable local xcap authentication
http://code.google.com/p/mobicents/source/detail?r=15184

Modified:
/trunk/servers/sip-presence/xdm/server/core/configuration/jar/src/main/java/org/mobicents/slee/xdm/server/ServerConfiguration.java /trunk/servers/sip-presence/xdm/server/core/configuration/jar/src/main/java/org/mobicents/slee/xdm/server/ServerConfigurationMBean.java /trunk/servers/sip-presence/xdm/server/core/configuration/metadata/src/main/resources/META-INF/jboss-beans.xml /trunk/servers/sip-presence/xdm/server/core/xcap-control/sbb/src/main/java/org/openxdm/xcap/server/slee/AuthenticationProxySbb.java

=======================================
--- /trunk/servers/sip-presence/xdm/server/core/configuration/jar/src/main/java/org/mobicents/slee/xdm/server/ServerConfiguration.java Tue Nov 2 11:19:39 2010 +++ /trunk/servers/sip-presence/xdm/server/core/configuration/jar/src/main/java/org/mobicents/slee/xdm/server/ServerConfiguration.java Thu Nov 11 02:55:08 2010
@@ -17,6 +17,8 @@

        private String authenticationRealm;

+       private boolean localXcapAuthentication;
+
private static final ServerConfiguration INSTANCE = new ServerConfiguration();

        public static ServerConfiguration getInstance() {
@@ -103,4 +105,22 @@
                        authenticationRealm = getServerHost();
                }
        }
-}
+
+       /*
+        * (non-Javadoc)
+ * @see org.mobicents.slee.xdm.server.ServerConfigurationMBean#getLocalXcapAuthentication()
+        */
+       @Override
+       public boolean getLocalXcapAuthentication() {
+               return localXcapAuthentication;
+       }
+
+       /*
+        * (non-Javadoc)
+ * @see org.mobicents.slee.xdm.server.ServerConfigurationMBean#setLocalXcapAuthentication(boolean)
+        */
+       @Override
+       public void setLocalXcapAuthentication(boolean value) {
+               this.localXcapAuthentication = true;
+       }
+}
=======================================
--- /trunk/servers/sip-presence/xdm/server/core/configuration/jar/src/main/java/org/mobicents/slee/xdm/server/ServerConfigurationMBean.java Tue Nov 2 11:19:39 2010 +++ /trunk/servers/sip-presence/xdm/server/core/configuration/jar/src/main/java/org/mobicents/slee/xdm/server/ServerConfigurationMBean.java Thu Nov 11 02:55:08 2010
@@ -29,4 +29,8 @@

        public void setAuthenticationRealm(String realm);

-}
+       public boolean getLocalXcapAuthentication();
+
+       public void setLocalXcapAuthentication(boolean value);
+
+}
=======================================
--- /trunk/servers/sip-presence/xdm/server/core/configuration/metadata/src/main/resources/META-INF/jboss-beans.xml Tue Nov 2 11:19:39 2010 +++ /trunk/servers/sip-presence/xdm/server/core/configuration/metadata/src/main/resources/META-INF/jboss-beans.xml Thu Nov 11 02:55:08 2010
@@ -27,6 +27,9 @@
       <!-- the xcap root of the server, must begin with / -->
       <property name="xcapRoot">${xdm.server.xcap.root}</property>

+      <!-- enables authentication for local xcap requests -->
+      <property name="localXcapAuthentication">false</property>
+
<!-- realm for http digest user authentication, if not set the server host will be used
       <property name="authenticationRealm">...</property>
        -->
=======================================
--- /trunk/servers/sip-presence/xdm/server/core/xcap-control/sbb/src/main/java/org/openxdm/xcap/server/slee/AuthenticationProxySbb.java Wed Oct 27 02:33:23 2010 +++ /trunk/servers/sip-presence/xdm/server/core/xcap-control/sbb/src/main/java/org/openxdm/xcap/server/slee/AuthenticationProxySbb.java Thu Nov 11 02:55:08 2010
@@ -102,8 +102,21 @@
                 */
                try {
                        String user = null;
-                       
if(!request.getRemoteAddr().equals(request.getLocalAddr())) {
-                               // remote request, use http digest 
authentication
+ if(!CONFIGURATION.getLocalXcapAuthentication() && request.getRemoteAddr().equals(request.getLocalAddr())) {
+                               if (logger.isInfoEnabled()) {
+                                       logger.info("Skipping authentication for 
local request.");
+                               }
+                               // use asserted id header if present
+                               user = 
request.getHeader(HEADER_X_3GPP_Asserted_Identity);
+                               if (user == null) {
+                                       user = 
request.getHeader(HEADER_X_XCAP_Asserted_Identity);
+                               }
+                               if (logger.isInfoEnabled()) {
+                                       logger.info("Asserted user: "+user);
+                               }
+                       }
+                       else {
+                               // use http digest authentication
                                if (logger.isInfoEnabled()) {
                                        logger.info("Remote request, using http 
digest authentication");
                                }
@@ -124,19 +137,6 @@
                                        }
                                }
                        }
-                       else {
-                               if (logger.isInfoEnabled()) {
-                                       logger.info("Local request, skipping 
authentication");
-                               }
-                               // use asserted id header if present
-                               user = 
request.getHeader(HEADER_X_3GPP_Asserted_Identity);
-                               if (user == null) {
-                                       user = 
request.getHeader(HEADER_X_XCAP_Asserted_Identity);
-                               }
-                               if (logger.isInfoEnabled()) {
-                                       logger.info("Asserted user: "+user);
-                               }
-                       }
                        return user;
                } catch (Throwable e) {
                        throw new InternalServerErrorException(e.getMessage(), 
e);

Reply via email to