Specify the authentication credentials

You can specify and store your authentication credentials using the utilws web service so that the credentials are sent automatically with each request to the BlackBerry® Administration API. To log in, you can use any of the authenticator methods supported by your BlackBerry Administration Service. For example, you can use the internal authenticator to log in using the user account credentials stored by the BlackBerry Administration Service, or you can use an external authenticator, such as Microsoft® Active Directory®.
Before you begin: Retrieve the following strings:
  • userName string for the user account you want to use to log in to the BlackBerry Administration API
  • password string for the user account you want to use to log in to the BlackBerry Administration API
  1. Specify the encodeUsername() parameters. The following code sample uses the internal authenticator. To use an external authenticator, use the AUTHENTICATOR_TYPE_PLUG_IN enumeration and specify a string for the domain you want to use, and an integer for the identifier of the external authenticator. For example, for an Active Directory authenticator, specify the Active Directory domain name and the indentifer 111.To view the external authenticators available on your BlackBerry Administration Service, use the findAuthenticators() method in the utilws web service.
    ExternalAuthenticatorType authenticator = new ExternalAuthenticatorTypes();
    String domain = null;
    int identifier = 0;
    boolean identifierSpecified = true;
    String credentialType = "0";
  2. Invoke encodeUsername().
    String myEncodeUsername = utilWebService.encodeUsername(userName,domain,type,identifier,credentialType);
  3. Store the encoded credentials in each web service that you use. You do not need to attach the credentials to the utilws web service.
    BindingProvider bp = (BindingProvider) coreWebService;
    bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, myEncodeUsername);
    bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
    BindingProvider bp2 = (BindingProvider) emailExchangeWebService;
    bp2.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, myEncodeUsername);
    bp2.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
Next topic: Handling errors

Was this information helpful? Send us your comments.