/*
- * Copyright (c) 2011, JANET(UK)
+ * Copyright (c) 2012, JANET(UK)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* EOF, and the user wouldn't know what went wrong.
*/
- printf ("Calling gss_accept_sec_context...\n");
+ // printf ("Calling gss_accept_sec_context...\n");
majorStatus = gss_accept_sec_context (&minorStatus,
&gssContext,
GSS_C_NO_CREDENTIAL,
static int ClientPrincipalIsAuthorizedForService (const char *inClientPrincipal)
{
int err = 0;
- krb5_context context = NULL;
- krb5_principal principal = NULL;
-
- if (!inClientPrincipal) { err = EINVAL; }
-
- if (!err) {
- err = krb5_init_context (&context);
- }
-
- if (!err) {
- err = krb5_parse_name (context, inClientPrincipal, &principal);
- }
-
- if (!err) {
/*
* Here is where the server checks to see if the client principal should
* be allowed to use your service. Typically it should check both the name
* realm may be trying to contact your service.
*/
err = 0;
- }
+
- if (principal) { krb5_free_principal (context, principal); }
- if (context ) { krb5_free_context (context); }
return err;
}
if (nameToken.value) { gss_release_buffer (&minorStatus, &nameToken); }
}
- if (!err) {
- /* Pull the service principal string out of the gss name */
- gss_buffer_desc nameToken;
-
- majorStatus = gss_display_name (&minorStatus,
- serviceName,
- &nameToken,
- NULL);
- if (majorStatus != GSS_S_COMPLETE) {
- err = minorStatus ? minorStatus : majorStatus;
- }
-
- if (!err) {
- servicePrincipal = malloc (nameToken.length + 1);
- if (servicePrincipal == NULL) { err = ENOMEM; }
- }
-
if (!err) {
- memcpy (servicePrincipal, nameToken.value, nameToken.length);
- servicePrincipal[nameToken.length] = '\0';
- }
+ // /* Pull the service principal string out of the gss name */
+ // gss_buffer_desc nameToken;
+ //
+ // majorStatus = gss_display_name (&minorStatus,
+ // serviceName,
+ // &nameToken,
+ // NULL);
+ // if (majorStatus != GSS_S_COMPLETE) {
+ // err = minorStatus ? minorStatus : majorStatus;
+ // }
+ //
+ // if (!err) {
+ // servic7ePrincipal = malloc (nameToken.length + 1);
+ // if (servicePrincipal == NULL) { err = ENOMEM; }
+ // }
+ //
+ // if (!err) {
+ // memcpy (servicePrincipal, nameToken.value, nameToken.length);
+ // servicePrincipal[nameToken.length] = '\0';
+ // }
- if (nameToken.value) { gss_release_buffer (&minorStatus, &nameToken); }
- }
+ // if (nameToken.value) { gss_release_buffer (&minorStatus, &nameToken); }
+ // }
- if (!err) {
- int authorizationErr = ServicePrincipalIsValidForService (servicePrincipal);
+// if (!err) {
+// int authorizationErr = ServicePrincipalIsValidForService (servicePr// incipal);
+//
+// if (!authorizationErr) {
+
+ int authorizationErr = 0;
+ authorizationErr = ClientPrincipalIsAuthorizedForService (clientPrincipal);
+
+// }
- if (!authorizationErr) {
- authorizationErr = ClientPrincipalIsAuthorizedForService (clientPrincipal);
+// printf ("'%s' is%s authorized for service '%s'\n",
+// clientPrincipal, authorizationErr ? " NOT" : "", servicePrincipal);
+//
+ *outAuthorized = !authorizationErr;
+ *outAuthorizationError = authorizationErr;
}
-
- printf ("'%s' is%s authorized for service '%s'\n",
- clientPrincipal, authorizationErr ? " NOT" : "", servicePrincipal);
-
- *outAuthorized = !authorizationErr;
- *outAuthorizationError = authorizationErr;
- }
if (serviceName ) { gss_release_name (&minorStatus, &serviceName); }
if (clientName ) { gss_release_name (&minorStatus, &clientName); }