diff --git a/auth_token/client/mechanisms/pwd/get.c b/auth_token/client/mechanisms/pwd/get.c index 47d1807c..f2b88546 100644 --- a/auth_token/client/mechanisms/pwd/get.c +++ b/auth_token/client/mechanisms/pwd/get.c @@ -58,7 +58,7 @@ GetUserCredentials( // Description: // Get authentication credentials for the specified realm. // -// L0 +// L2 //=======================================================================-- { CasaStatus retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, @@ -66,12 +66,13 @@ GetUserCredentials( CASA_STATUS_UNSUCCESSFUL); char *pUsername; char *pPassword; - int rcode = NSSCS_E_OBJECT_NOT_FOUND; - int32_t credtype = SSCS_CRED_TYPE_BASIC_F; - SSCS_BASIC_CREDENTIAL credential = {0}; - SSCS_SECRET_ID_T secretId = {0}; - SSCS_SECRET_ID_T sharedSecretId = {0}; - + int rcode = NSSCS_E_OBJECT_NOT_FOUND; + int32_t credtype = SSCS_CRED_TYPE_BASIC_F; + SSCS_BASIC_CREDENTIAL credential = {0}; + SSCS_SECRET_ID_T secretId = {0}; + SSCS_SECRET_ID_T sharedSecretId = {0}; + + DbgTrace(1, "-GetUserCredentials- Start\n", 0); // Initialize output parameters @@ -80,49 +81,49 @@ GetUserCredentials( // Get the length of the realm string into the secret id structure // and verify thatr it is not too long. - secretId.len = sscs_Utf8Strlen(pRealm) + 1; - if (secretId.len <= NSSCS_MAX_SECRET_ID_LEN) - { - // Set the secret id in the structure - sscs_Utf8Strcpy(secretId.id, pRealm); - - // Specify that we want the common name - credential.unFlags = USERNAME_TYPE_CN_F; - - // Now try to get the credentials - rcode = miCASAGetCredential(0, - &secretId, - NULL, - &credtype, //SSCS_CRED_TYPE_BASIC_F, - &credential, - NULL); - if (rcode != NSSCS_SUCCESS) - { - // There were no credentials for the realm, now try to obtain the - // desktop credentials. - secretId.len = sscs_Utf8Strlen("Desktop") + 1; - sscs_Utf8Strcpy(secretId.id, "Desktop"); - rcode = miCASAGetCredential(0, - &secretId, - NULL, - &credtype, //SSCS_CRED_TYPE_BASIC_F, - &credential, - NULL); - } - } - else - { + secretId.len = sscs_Utf8Strlen(pRealm) + 1; + if (secretId.len <= NSSCS_MAX_SECRET_ID_LEN) + { + // Set the secret id in the structure + sscs_Utf8Strcpy(secretId.id, pRealm); + + // Specify that we want the common name + credential.unFlags = USERNAME_TYPE_CN_F; + + // Now try to get the credentials + rcode = miCASAGetCredential(0, + &secretId, + NULL, + &credtype, + &credential, + NULL); + if (rcode != NSSCS_SUCCESS) + { + // There were no credentials for the realm, now try to obtain the + // desktop credentials. + secretId.len = sscs_Utf8Strlen("Desktop") + 1; + sscs_Utf8Strcpy(secretId.id, "Desktop"); + rcode = miCASAGetCredential(0, + &secretId, + NULL, + &credtype, + &credential, + NULL); + } + } + else + { DbgTrace(0, "-GetUserCredentials- Realm name too long\n", 0); retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, CASA_FACILITY_PWTOKEN, CASA_STATUS_UNSUCCESSFUL); - } - - // Proceed based on the result of the operatiosn above - if (rcode == NSSCS_SUCCESS - && credential.username != NULL - && credential.password != NULL) - { + } + + // Proceed based on the result of the operatiosn above + if (rcode == NSSCS_SUCCESS + && credential.username != NULL + && credential.password != NULL) + { // Allocate a buffer to return the username pUsername = (char*) malloc(strlen(credential.username) + 1); if (pUsername) @@ -144,8 +145,8 @@ GetUserCredentials( { DbgTrace(0, "-GetUserCredentials- Buffer allocation error\n", 0); retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, - CASA_FACILITY_PWTOKEN, - CASA_STATUS_INSUFFICIENT_RESOURCES); + CASA_FACILITY_PWTOKEN, + CASA_STATUS_INSUFFICIENT_RESOURCES); // Free the buffer allocated for the username free(pUsername); @@ -155,10 +156,10 @@ GetUserCredentials( { DbgTrace(0, "-GetUserCredentials- Buffer allocation error\n", 0); retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, - CASA_FACILITY_PWTOKEN, - CASA_STATUS_INSUFFICIENT_RESOURCES); + CASA_FACILITY_PWTOKEN, + CASA_STATUS_INSUFFICIENT_RESOURCES); } - } + } // Return the buffers to the caller if successful if (CASA_SUCCESS(retStatus)) @@ -224,7 +225,7 @@ AuthTokenIf_GetAuthToken( // Description: // Get authentication token to authenticate user to specified service. // -// L0 +// L2 //=======================================================================-- { CasaStatus retStatus; @@ -277,8 +278,6 @@ AuthTokenIf_GetAuthToken( if (encodedTokenLen > *pTokenBufLen) { // The buffer is not big enough - DbgTrace(1, "-AuthTokenIf_GetAuthToken- Insufficient buffer space provided\n", 0); - retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, CASA_FACILITY_PWTOKEN, CASA_STATUS_BUFFER_OVERFLOW); @@ -339,13 +338,14 @@ InitializeLibrary(void) // // Notes: // -// L0 +// L2 //=======================================================================-- { int retStatus = 0; DbgTrace(1, "-InitializeLibrary- Start\n", 0); + // Nothing to do at this time. DbgTrace(1, "-InitializeLibrary- End, retStatus = %08X\n", retStatus); diff --git a/auth_token/client/mechanisms/pwd/win32/platutils.c b/auth_token/client/mechanisms/pwd/win32/platutils.c deleted file mode 100644 index 869b581c..00000000 --- a/auth_token/client/mechanisms/pwd/win32/platutils.c +++ /dev/null @@ -1,35 +0,0 @@ -/*********************************************************************** - * - * Copyright (C) 2006 Novell, Inc. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com. - * - * Author: Juan Carlos Luciani - * - ***********************************************************************/ - -//===[ Include files ]===================================================== - -#include "internal.h" - -//===[ Type definitions ]================================================== - -//===[ Function prototypes ]=============================================== - -//===[ Global variables ]================================================== - -