From: Dave B. <bla...@us...> - 2011-03-14 13:40:01
|
Update of /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/wbem In directory vz-cvs-3.sog:/tmp/cvs-serv11501/src/org/sblim/cimclient/internal/wbem Modified Files: WBEMClientCIMXML.java Log Message: 3197423 - Server authentication with PegasusLocalAuthInfo failing Index: WBEMClientCIMXML.java =================================================================== RCS file: /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/wbem/WBEMClientCIMXML.java,v retrieving revision 1.62 retrieving revision 1.63 diff -u -d -r1.62 -r1.63 --- WBEMClientCIMXML.java 7 Mar 2011 14:20:04 -0000 1.62 +++ WBEMClientCIMXML.java 14 Mar 2011 13:39:58 -0000 1.63 @@ -53,6 +53,7 @@ * 3019252 2010-06-21 blaschke-oss Methods concatenate strings using + in a loop * 3028518 2010-07-14 blaschke-oss Additional StringBuilder use * 3185833 2011-02-18 blaschke-oss missing newline when logging request/response + * 3197423 2011-03-02 blaschke-oss Server authentication with PegasusLocalAuthInfo failing */ package org.sblim.cimclient.internal.wbem; @@ -200,32 +201,21 @@ boolean defaultAuthEnabled = WBEMConfiguration.getGlobalConfiguration() .isDefaultAuthorizationEnabled(); - String user = ""; - String password = ""; - if (credential == null - || principal == null - || principal.getName() == null - || (credential instanceof PasswordCredential && (((PasswordCredential) credential) - .getUserPassword() == null || ((PasswordCredential) credential) - .getUserPassword().length == 0)) - || (credential instanceof RoleCredential && (((RoleCredential) credential) - .getCredential() == null || ((RoleCredential) credential) - .getCredential().length == 0))) { - if (defaultAuthEnabled) { - logger.trace(Level.FINER, - "Empty credential or principal - Default IS enabled !"); - user = WBEMConfiguration.getGlobalConfiguration().getDefaultPrincipal(); - password = WBEMConfiguration.getGlobalConfiguration().getDefaultCredentials(); - } else { - logger.trace(Level.FINER, - "Empty credential or principal - Default NOT enabled !"); - } - } else { - user = principal.getName(); - password = (credential instanceof PasswordCredential) ? new String( - ((PasswordCredential) credential).getUserPassword()) : new String( - ((RoleCredential) credential).getCredential()); + String user = (principal != null) ? principal.getName() : ""; + String password = (credential != null && credential instanceof PasswordCredential) ? new String( + ((PasswordCredential) credential).getUserPassword()) + : ((credential != null && credential instanceof RoleCredential) ? new String( + ((RoleCredential) credential).getCredential()) : ""); + + if (defaultAuthEnabled && (user == null || user.length() == 0) + && password.length() == 0) { + logger.trace(Level.FINER, + "Principal and Credential not set - using default authorization!"); + + user = WBEMConfiguration.getGlobalConfiguration().getDefaultPrincipal(); + password = WBEMConfiguration.getGlobalConfiguration().getDefaultCredentials(); } + authInfo.setCredentials(new PasswordAuthentication(user, password.toCharArray())); this.iAuthorizationHandler = new AuthorizationHandler(); this.iAuthorizationHandler.addAuthorizationInfo(authInfo); |