/// <summary> /// Get the encoded username required to authenticate user to BWS. /// </summary> /// <returns>Returns a string containing the encoded username if successful, and a null otherwise.</returns> public static string getEncodedUserName(String username, Authenticator authenticator, CredentialType credentialType, String domain) { const string METHOD_NAME = "getEncodedUserName()"; const string BWS_API_NAME = "bwsUtilService.getEncodedUsername()"; logMessage("Entering {0}", METHOD_NAME); string returnValue = null; GetEncodedUsernameRequest request = new GetEncodedUsernameRequest(); request.metadata = REQUEST_METADATA; request.username = username; request.orgUid = REQUEST_METADATA.organizationUid; request.authenticator = authenticator; request.credentialType = credentialType; request.domain = domain; GetEncodedUsernameResponse response = null; try { logRequest(BWS_API_NAME); response = bwsUtilService.getEncodedUsername(request); logResponse(BWS_API_NAME, response.returnStatus.code, response.metadata); } catch (WebException e) { // Log and re-throw exception. logMessage("Exiting {0} with exception \"{1}\"", METHOD_NAME, e.Message); throw e; } if (response.returnStatus.code.Equals("SUCCESS")) { returnValue = response.encodedUsername; } else { logMessage("Error Message: \"{0}\"", response.returnStatus.message); } // BES12 returns a Base64 encoded string while BES10 does not. As a result, a BES10 encoded username // throws an exception when an attempt is made to decode from base64. The try block will log the decoded // username if run against a BES12 system and the catch then logs the actual value returned by BES10. try { logMessage("Decoded value of encoded username \"{0}\"", Encoding.Default.GetString(Convert.FromBase64String(returnValue))); } catch (Exception) { // Not actually base64 encoded. Show actual value logMessage("Value of encoded username \"{0}\"", returnValue); } logMessage("Exiting {0}", METHOD_NAME); return(returnValue); }
/// <summary> /// Get the encoded username required to authenticate user to BWS. /// </summary> /// <param name="username">A string containing the username to encode.</param> /// <param name="authenticator">The authenticator.</param> /// <returns>Returns a string containing the encoded username if successful, and a null message string /// otherwise.</returns> public static string GetEncodedUserName(string username, Authenticator authenticator) { const string methodName = "GetEncodedUserName()"; const string bwsApiName = "bwsUtilService.getEncodedUsername()"; logMessage("Entering {0}", methodName); string returnValue = null; GetEncodedUsernameRequest request = new GetEncodedUsernameRequest(); request.metadata = Metadata; request.username = username; request.orgUid = Metadata.organizationUid; request.authenticator = authenticator; CredentialType credentialType = new CredentialType(); credentialType.PASSWORD = true; credentialType.value = "PASSWORD"; request.credentialType = credentialType; GetEncodedUsernameResponse response = null; try { logRequest(bwsApiName); response = bwsUtilService.getEncodedUsername(request); logResponse(bwsApiName, response.returnStatus.code, response.metadata); } catch (WebException e) { // Log and re-throw exception. logMessage("Exiting {0} with exception \"{1}\"", methodName, e.Message); throw e; } if (response.returnStatus.code.Equals("SUCCESS")) { returnValue = response.encodedUsername; } else { logMessage("Error Message: \"{0}\"", response.returnStatus.message); } logMessage("Exiting {0} with value \"{1}\"", methodName, returnValue == null ? "null" : returnValue); return(returnValue); }
/// <summary> /// Get the encoded username required to authenticate user to BWS. /// </summary> /// <returns>Returns a string containing the encoded username if successful, and a null otherwise.</returns> public static string getEncodedUserName(String username, Authenticator authenticator, CredentialType credentialType, String domain) { const string METHOD_NAME = "getEncodedUserName()"; const string BWS_API_NAME = "bwsUtilService.getEncodedUsername()"; logMessage("Entering {0}", METHOD_NAME); string returnValue = null; GetEncodedUsernameRequest request = new GetEncodedUsernameRequest(); request.metadata = REQUEST_METADATA; request.username = username; request.orgUid = REQUEST_METADATA.organizationUid; request.authenticator = authenticator; request.credentialType = credentialType; request.domain = domain; GetEncodedUsernameResponse response = null; try { logRequest(BWS_API_NAME); response = bwsUtilService.getEncodedUsername(request); logResponse(BWS_API_NAME, response.returnStatus.code, response.metadata); } catch (WebException e) { // Log and re-throw exception. logMessage("Exiting {0} with exception \"{1}\"", METHOD_NAME, e.Message); throw e; } if (response.returnStatus.code.Equals("SUCCESS")) { returnValue = response.encodedUsername; } else { logMessage("Error Message: \"{0}\"", response.returnStatus.message); } logMessage("Exiting {0}", METHOD_NAME); return(returnValue); }
/// <summary> /// Get the encoded username required to authenticate user to BWS. /// </summary> /// <param name="username">A string containing the username to encode.</param> /// <param name="authenticator">The authenticator.</param> /// <returns>Returns a string containing the encoded username if successful, and a null message string /// otherwise.</returns> public static string GetEncodedUserName(string username, Authenticator authenticator) { const string methodName = "GetEncodedUserName()"; const string bwsApiName = "bwsUtilService.getEncodedUsername()"; logMessage("Entering {0}", methodName); string returnValue = null; GetEncodedUsernameRequest request = new GetEncodedUsernameRequest(); request.metadata = Metadata; request.username = username; request.orgUid = Metadata.organizationUid; request.authenticator = authenticator; CredentialType credentialType = new CredentialType(); credentialType.PASSWORD = true; credentialType.value = "PASSWORD"; request.credentialType = credentialType; GetEncodedUsernameResponse response = null; try { logRequest(bwsApiName); response = bwsUtilService.getEncodedUsername(request); logResponse(bwsApiName, response.returnStatus.code, response.metadata); } catch (WebException e) { // Log and re-throw exception. logMessage("Exiting {0} with exception \"{1}\"", methodName, e.Message); throw e; } if (response.returnStatus.code.Equals("SUCCESS")) { returnValue = response.encodedUsername; } else { logMessage("Error Message: \"{0}\"", response.returnStatus.message); } // UEM12 returns a Base64 encoded string while BES10 does not. As a result, a BES10 encoded username // throws an exception when an attempt is made to decode from base64. The try block will log the decoded // username if run against a UEM12 system and the catch then logs the actual value returned by BES10. try { logMessage("Decoded value of encoded username \"{0}\"", Encoding.Default.GetString(Convert.FromBase64String(returnValue))); } catch (Exception) { // Not actually base64 encoded. Show actual value logMessage("Value of encoded username \"{0}\"", returnValue); } logMessage("Exiting {0}", methodName); return(returnValue); }
/// <summary> /// Get the encoded username required to authenticate user to BWS. /// </summary> /// <param name="username">A string containing the username to encode.</param> /// <param name="authenticator">The authenticator.</param> /// <returns>Returns a string containing the encoded username if successful, and a null message string /// otherwise.</returns> public static string GetEncodedUserName(string username, Authenticator authenticator) { const string methodName = "GetEncodedUserName()"; const string bwsApiName = "bwsUtilService.getEncodedUsername()"; logMessage("Entering {0}", methodName); string returnValue = null; GetEncodedUsernameRequest request = new GetEncodedUsernameRequest(); request.metadata = Metadata; request.username = username; request.orgUid = Metadata.organizationUid; request.authenticator = authenticator; CredentialType credentialType = new CredentialType(); credentialType.PASSWORD = true; credentialType.value = "PASSWORD"; request.credentialType = credentialType; GetEncodedUsernameResponse response = null; try { logRequest(bwsApiName); response = bwsUtilService.getEncodedUsername(request); logResponse(bwsApiName, response.returnStatus.code, response.metadata); } catch (WebException e) { // Log and re-throw exception. logMessage("Exiting {0} with exception \"{1}\"", methodName, e.Message); throw e; } if (response.returnStatus.code.Equals("SUCCESS")) { returnValue = response.encodedUsername; } else { logMessage("Error Message: \"{0}\"", response.returnStatus.message); } logMessage("Exiting {0} with value \"{1}\"", methodName, returnValue == null ? "null" : returnValue); return returnValue; }
/// <summary> /// Get the encoded username required to authenticate user to BWS. /// </summary> /// <param name="username">A string containing the username to encode.</param> /// <param name="authenticator">The authenticator.</param> /// <returns>Returns a string containing the encoded username if successful, and a null message string /// otherwise.</returns> public static string GetEncodedUserName(string username, Authenticator authenticator) { const string methodName = "GetEncodedUserName()"; const string bwsApiName = "bwsUtilService.getEncodedUsername()"; Console.Error.WriteLine("Entering {0}", methodName); string returnValue = null; GetEncodedUsernameRequest request = new GetEncodedUsernameRequest(); request.metadata = Metadata; request.username = username; request.orgUid = Metadata.organizationUid; request.authenticator = authenticator; CredentialType credentialType = new CredentialType(); credentialType.PASSWORD = true; credentialType.value = "PASSWORD"; request.credentialType = credentialType; Console.Error.WriteLine("Calling {0}...", bwsApiName); GetEncodedUsernameResponse response = bwsUtilService.getEncodedUsername(request); Console.Error.WriteLine("...{0} returned \"{1}\"", bwsApiName, response.returnStatus.code); if (response.returnStatus.code.Equals("SUCCESS")) { returnValue = response.encodedUsername; } else { Console.Error.WriteLine("Error: Code: \"{0}\", Message: \"{1}\"", response.returnStatus.code, response.returnStatus.message); } Console.Error.WriteLine("Exiting {0} with value \"{1}\"", methodName, returnValue == null ? "null" : returnValue); return returnValue; }
/// <summary> /// Get the encoded username required to authenticate user to BWS. /// </summary> /// <returns>Returns a string containing the encoded username if successful, and a null otherwise.</returns> public static string getEncodedUserName(String username, Authenticator authenticator, CredentialType credentialType, String domain) { const string METHOD_NAME = "getEncodedUserName()"; const string BWS_API_NAME = "bwsUtilService.getEncodedUsername()"; logMessage("Entering {0}", METHOD_NAME); string returnValue = null; GetEncodedUsernameRequest request = new GetEncodedUsernameRequest(); request.metadata = REQUEST_METADATA; request.username = username; request.orgUid = REQUEST_METADATA.organizationUid; request.authenticator = authenticator; request.credentialType = credentialType; request.domain = domain; GetEncodedUsernameResponse response = null; try { logRequest(BWS_API_NAME); response = bwsUtilService.getEncodedUsername(request); logResponse(BWS_API_NAME, response.returnStatus.code, response.metadata); } catch (WebException e) { // Log and re-throw exception. logMessage("Exiting {0} with exception \"{1}\"", METHOD_NAME, e.Message); throw e; } if (response.returnStatus.code.Equals("SUCCESS")) { returnValue = response.encodedUsername; } else { logMessage("Error Message: \"{0}\"", response.returnStatus.message); } logMessage("Exiting {0}", METHOD_NAME); return returnValue; }
/// <summary> /// Get the encoded username required to authenticate user to BWS. /// </summary> /// <returns>Returns a string containing the encoded username if successful, and a null otherwise.</returns> public static string getEncodedUserName(String username, Authenticator authenticator, CredentialType credentialType, String domain) { const string METHOD_NAME = "getEncodedUserName()"; const string BWS_API_NAME = "bwsUtilService.getEncodedUsername()"; logMessage("Entering {0}", METHOD_NAME); string returnValue = null; GetEncodedUsernameRequest request = new GetEncodedUsernameRequest(); request.metadata = REQUEST_METADATA; request.username = username; request.orgUid = REQUEST_METADATA.organizationUid; request.authenticator = authenticator; request.credentialType = credentialType; request.domain = domain; GetEncodedUsernameResponse response = null; try { logRequest(BWS_API_NAME); response = bwsUtilService.getEncodedUsername(request); logResponse(BWS_API_NAME, response.returnStatus.code, response.metadata); } catch (WebException e) { // Log and re-throw exception. logMessage("Exiting {0} with exception \"{1}\"", METHOD_NAME, e.Message); throw e; } if (response.returnStatus.code.Equals("SUCCESS")) { returnValue = response.encodedUsername; } else { logMessage("Error Message: \"{0}\"", response.returnStatus.message); } // BES12 returns a Base64 encoded string while BES10 does not. As a result, a BES10 encoded username // throws an exception when an attempt is made to decode from base64. The try block will log the decoded // username if run against a BES12 system and the catch then logs the actual value returned by BES10. try { logMessage("Decoded value of encoded username \"{0}\"", Encoding.Default.GetString(Convert.FromBase64String(returnValue))); } catch(Exception) { // Not actually base64 encoded. Show actual value logMessage("Value of encoded username \"{0}\"", returnValue); } logMessage("Exiting {0}", METHOD_NAME); return returnValue; }