Merge pull request #1270 from jboeuf/server_security_context_factory

Refactoring of server context creation (incremental improvement).
diff --git a/src/core/security/factories.c b/src/core/security/factories.c
index 02267d5..3d9216a 100644
--- a/src/core/security/factories.c
+++ b/src/core/security/factories.c
@@ -50,3 +50,19 @@
   return grpc_secure_channel_create_with_factories(
       factories, GPR_ARRAY_SIZE(factories), creds, target, args);
 }
+
+grpc_security_status grpc_server_security_context_create(
+    grpc_server_credentials *creds, grpc_security_context **ctx) {
+  grpc_security_status status = GRPC_SECURITY_ERROR;
+
+  *ctx = NULL;
+  if (strcmp(creds->type, GRPC_CREDENTIALS_TYPE_SSL) == 0) {
+    status = grpc_ssl_server_security_context_create(
+        grpc_ssl_server_credentials_get_config(creds), ctx);
+  } else if (strcmp(creds->type,
+                    GRPC_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY) == 0) {
+    *ctx = grpc_fake_server_security_context_create();
+    status = GRPC_SECURITY_OK;
+  }
+  return status;
+}
diff --git a/src/core/security/security_context.h b/src/core/security/security_context.h
index 0b5821c..2b4e38f 100644
--- a/src/core/security/security_context.h
+++ b/src/core/security/security_context.h
@@ -206,10 +206,9 @@
     const grpc_secure_channel_factory *factories, size_t num_factories,
     grpc_credentials *creds, const char *target, const grpc_channel_args *args);
 
-/* Secure server creation. */
+/* Secure server context creation. */
 
-grpc_server *grpc_secure_server_create_internal(grpc_completion_queue *cq,
-                                                const grpc_channel_args *args,
-                                                grpc_security_context *ctx);
+grpc_security_status grpc_server_security_context_create(
+    grpc_server_credentials *creds, grpc_security_context **ctx);
 
 #endif  /* GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONTEXT_H */
diff --git a/src/core/security/server_secure_chttp2.c b/src/core/security/server_secure_chttp2.c
index 0812727..165ed54 100644
--- a/src/core/security/server_secure_chttp2.c
+++ b/src/core/security/server_secure_chttp2.c
@@ -141,16 +141,7 @@
 
   /* create security context */
   if (creds == NULL) goto error;
-
-  if (strcmp(creds->type, GRPC_CREDENTIALS_TYPE_SSL) == 0) {
-    status = grpc_ssl_server_security_context_create(
-        grpc_ssl_server_credentials_get_config(creds), &ctx);
-  } else if (strcmp(creds->type,
-                    GRPC_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY) == 0) {
-    ctx = grpc_fake_server_security_context_create();
-    status = GRPC_SECURITY_OK;
-  }
-
+  status = grpc_server_security_context_create(creds, &ctx);
   if (status != GRPC_SECURITY_OK) {
     gpr_log(GPR_ERROR,
             "Unable to create secure server with credentials of type %s.",