| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
package org.itracker.services.implementations; |
| 20 |
|
|
| 21 |
|
import java.util.ArrayList; |
| 22 |
|
import java.util.Arrays; |
| 23 |
|
import java.util.Collection; |
| 24 |
|
import java.util.Date; |
| 25 |
|
import java.util.HashMap; |
| 26 |
|
import java.util.HashSet; |
| 27 |
|
import java.util.Iterator; |
| 28 |
|
import java.util.List; |
| 29 |
|
import java.util.Map; |
| 30 |
|
import java.util.Set; |
| 31 |
|
import java.util.TreeSet; |
| 32 |
|
|
| 33 |
|
import org.apache.log4j.Logger; |
| 34 |
|
import org.itracker.model.Issue; |
| 35 |
|
import org.itracker.model.Permission; |
| 36 |
|
import org.itracker.model.PermissionType; |
| 37 |
|
import org.itracker.model.Project; |
| 38 |
|
import org.itracker.model.User; |
| 39 |
|
import org.itracker.model.UserPreferences; |
| 40 |
|
import org.itracker.persistence.dao.NoSuchEntityException; |
| 41 |
|
import org.itracker.persistence.dao.PermissionDAO; |
| 42 |
|
import org.itracker.persistence.dao.ProjectDAO; |
| 43 |
|
import org.itracker.persistence.dao.ReportDAO; |
| 44 |
|
import org.itracker.persistence.dao.UserDAO; |
| 45 |
|
import org.itracker.persistence.dao.UserPreferencesDAO; |
| 46 |
|
import org.itracker.services.ConfigurationService; |
| 47 |
|
import org.itracker.services.ProjectService; |
| 48 |
|
import org.itracker.services.UserService; |
| 49 |
|
import org.itracker.services.authentication.PluggableAuthenticator; |
| 50 |
|
import org.itracker.services.exceptions.AuthenticatorException; |
| 51 |
|
import org.itracker.services.exceptions.PasswordException; |
| 52 |
|
import org.itracker.services.exceptions.UserException; |
| 53 |
|
import org.itracker.services.util.AuthenticationConstants; |
| 54 |
|
import org.itracker.services.util.ProjectUtilities; |
| 55 |
|
import org.itracker.services.util.UserUtilities; |
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
@see |
| 62 |
|
|
|
|
|
| 0% |
Uncovered Elements: 600 (600) |
Complexity: 151 |
Complexity Density: 0.35 |
|
| 63 |
|
public class UserServiceImpl implements UserService { |
| 64 |
|
|
| 65 |
|
private static final String DEFAULT_AUTHENTICATOR = |
| 66 |
|
"org.itracker.services.authentication.DefaultAuthenticator"; |
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
private String authenticatorClassName = null; |
| 71 |
|
private Class<?> authenticatorClass = null; |
| 72 |
|
private boolean allowSelfRegister = false; |
| 73 |
|
|
| 74 |
|
private static final Logger logger = Logger.getLogger(UserServiceImpl.class); |
| 75 |
|
|
| 76 |
|
private PermissionDAO permissionDAO = null; |
| 77 |
|
|
| 78 |
|
private UserDAO userDAO = null; |
| 79 |
|
private UserPreferencesDAO userPreferencesDAO = null; |
| 80 |
|
private ProjectService projectService; |
| 81 |
|
private ConfigurationService configurationService; |
| 82 |
|
|
| 83 |
|
|
| 84 |
|
@param |
| 85 |
|
@param |
| 86 |
|
@param |
| 87 |
|
@param |
| 88 |
|
@param |
| 89 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.2 |
|
| 90 |
0
|
public UserServiceImpl(ConfigurationService configurationService,... |
| 91 |
|
ProjectService projectService, |
| 92 |
|
UserDAO userDAO, |
| 93 |
|
PermissionDAO permissionDAO, |
| 94 |
|
UserPreferencesDAO userPreferencesDAO) { |
| 95 |
|
|
| 96 |
|
|
| 97 |
0
|
this.configurationService = configurationService; |
| 98 |
0
|
this.projectService = projectService; |
| 99 |
0
|
this.userDAO = userDAO; |
| 100 |
0
|
this.userPreferencesDAO = userPreferencesDAO; |
| 101 |
0
|
this.permissionDAO = permissionDAO; |
| 102 |
|
|
| 103 |
0
|
try { |
| 104 |
0
|
allowSelfRegister = configurationService.getBooleanProperty("allow_self_register", false); |
| 105 |
|
|
| 106 |
0
|
authenticatorClassName = configurationService.getProperty("authenticator_class", DEFAULT_AUTHENTICATOR); |
| 107 |
0
|
authenticatorClass = Class.forName(authenticatorClassName); |
| 108 |
|
} catch (ClassNotFoundException ex) { |
| 109 |
0
|
throw new RuntimeException(ex); |
| 110 |
|
} |
| 111 |
|
} |
| 112 |
|
|
| 113 |
|
@deprecated |
| 114 |
|
@param |
| 115 |
|
@param |
| 116 |
|
@param |
| 117 |
|
@param |
| 118 |
|
@param |
| 119 |
|
@param |
| 120 |
|
@param |
| 121 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 122 |
0
|
public UserServiceImpl(ConfigurationService configurationService,... |
| 123 |
|
ProjectService projectService, |
| 124 |
|
UserDAO userDAO, |
| 125 |
|
ProjectDAO projectDAO, |
| 126 |
|
ReportDAO reportDAO, |
| 127 |
|
PermissionDAO permissionDAO, |
| 128 |
|
UserPreferencesDAO userPreferencesDAO) { |
| 129 |
0
|
this(configurationService, projectService, userDAO, permissionDAO, userPreferencesDAO); |
| 130 |
|
} |
| 131 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 132 |
0
|
public User getUser(Integer userId) {... |
| 133 |
0
|
User user = userDAO.findByPrimaryKey(userId); |
| 134 |
0
|
return user; |
| 135 |
|
} |
| 136 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 137 |
0
|
public User getUserByLogin(String login) throws NoSuchEntityException {... |
| 138 |
0
|
User user = userDAO.findByLogin(login); |
| 139 |
0
|
if (user == null) |
| 140 |
0
|
throw new NoSuchEntityException("User " + login + " not found."); |
| 141 |
0
|
return user; |
| 142 |
|
} |
| 143 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 144 |
0
|
public String getUserPasswordByLogin(String login) {... |
| 145 |
0
|
User user = userDAO.findByLogin(login); |
| 146 |
0
|
return user.getPassword(); |
| 147 |
|
} |
| 148 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 149 |
0
|
public List<User> getAllUsers() {... |
| 150 |
0
|
List<User> users = userDAO.findAll(); |
| 151 |
|
|
| 152 |
0
|
return users; |
| 153 |
|
} |
| 154 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 155 |
0
|
public int getNumberUsers() {... |
| 156 |
0
|
Collection<User> users = userDAO.findAll(); |
| 157 |
0
|
return users.size(); |
| 158 |
|
} |
| 159 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 160 |
0
|
public List<User> getActiveUsers() {... |
| 161 |
0
|
List<User> users = userDAO.findActive(); |
| 162 |
|
|
| 163 |
0
|
return users; |
| 164 |
|
} |
| 165 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 166 |
0
|
public List<User> getSuperUsers() {... |
| 167 |
0
|
List<User> superUsers = userDAO.findSuperUsers(); |
| 168 |
0
|
return superUsers; |
| 169 |
|
} |
| 170 |
|
|
| 171 |
|
|
| 172 |
|
|
| 173 |
|
|
| 174 |
|
|
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| 179 |
|
|
| 180 |
|
|
| 181 |
|
|
| 182 |
|
|
| 183 |
|
|
| 184 |
|
|
| 185 |
|
|
| 186 |
|
|
| 187 |
|
|
| 188 |
|
|
| 189 |
|
|
| 190 |
|
|
| 191 |
|
|
| 192 |
|
|
| 193 |
|
|
| 194 |
|
|
| 195 |
|
|
| 196 |
|
|
| 197 |
|
|
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 10 |
Complexity Density: 0.43 |
|
| 198 |
0
|
public User createUser(User user) throws UserException {... |
| 199 |
0
|
try { |
| 200 |
0
|
if (user == null || user.getLogin() == null || user.getLogin().equals("")) { |
| 201 |
0
|
throw new UserException("User data was null, or login was empty."); |
| 202 |
|
} |
| 203 |
|
|
| 204 |
0
|
try { |
| 205 |
0
|
this.getUserByLogin(user.getLogin()); |
| 206 |
0
|
throw new UserException("User already exists with login: " + user.getLogin()); |
| 207 |
|
} catch (NoSuchEntityException e) { |
| 208 |
|
|
| 209 |
|
} |
| 210 |
|
|
| 211 |
0
|
try { |
| 212 |
0
|
PluggableAuthenticator authenticator = (PluggableAuthenticator) authenticatorClass.newInstance(); |
| 213 |
0
|
if (authenticator != null) { |
| 214 |
0
|
HashMap<String, Object> values = new HashMap<String, Object>(); |
| 215 |
0
|
values.put("userService", this); |
| 216 |
0
|
values.put("configurationService", configurationService); |
| 217 |
0
|
authenticator.initialize(values); |
| 218 |
0
|
authenticator.createProfile(user, null, AuthenticationConstants.AUTH_TYPE_UNKNOWN, |
| 219 |
|
AuthenticationConstants.REQ_SOURCE_UNKNOWN); |
| 220 |
|
} else { |
| 221 |
0
|
throw new AuthenticatorException("Unable to create new authenticator.", AuthenticatorException.SYSTEM_ERROR); |
| 222 |
|
} |
| 223 |
|
} catch (IllegalAccessException ex) { |
| 224 |
0
|
throw new AuthenticatorException( |
| 225 |
|
"Authenticator class " + authenticatorClassName + " can not be instantiated.", |
| 226 |
|
AuthenticatorException.SYSTEM_ERROR, ex); |
| 227 |
|
} catch (InstantiationException ex) { |
| 228 |
0
|
throw new AuthenticatorException( |
| 229 |
|
"Authenticator class " + authenticatorClassName + " can not be instantiated.", |
| 230 |
|
AuthenticatorException.SYSTEM_ERROR, ex); |
| 231 |
|
} catch (ClassCastException ex) { |
| 232 |
0
|
throw new AuthenticatorException("Authenticator class " + authenticatorClassName |
| 233 |
|
+ " does not extend the PluggableAuthenticator class.", |
| 234 |
|
AuthenticatorException.SYSTEM_ERROR, ex); |
| 235 |
|
} |
| 236 |
0
|
user.setStatus(UserUtilities.STATUS_ACTIVE); |
| 237 |
0
|
user.setRegistrationType(user.getRegistrationType()); |
| 238 |
|
|
| 239 |
|
|
| 240 |
0
|
userDAO.save(user); |
| 241 |
0
|
return user; |
| 242 |
|
} catch (AuthenticatorException ex) { |
| 243 |
0
|
throw new UserException("Could not create user.", ex); |
| 244 |
|
} |
| 245 |
|
|
| 246 |
|
} |
| 247 |
|
|
|
|
|
| 0% |
Uncovered Elements: 40 (40) |
Complexity: 9 |
Complexity Density: 0.26 |
|
| 248 |
0
|
public User updateUser(User user) throws UserException {... |
| 249 |
0
|
try { |
| 250 |
0
|
PluggableAuthenticator authenticator = (PluggableAuthenticator) authenticatorClass.newInstance(); |
| 251 |
0
|
if (authenticator != null) { |
| 252 |
0
|
HashMap<String, Object> values = new HashMap<String, Object>(); |
| 253 |
0
|
values.put("userService", this); |
| 254 |
0
|
values.put("configurationService", configurationService); |
| 255 |
0
|
authenticator.initialize(values); |
| 256 |
0
|
authenticator.updateProfile(user, AuthenticationConstants.UPDATE_TYPE_CORE, null, |
| 257 |
|
AuthenticationConstants.AUTH_TYPE_UNKNOWN, AuthenticationConstants.REQ_SOURCE_UNKNOWN); |
| 258 |
|
} else { |
| 259 |
0
|
logger.warn("updateUser: no authenticator, throwing AuthenticatorException"); |
| 260 |
0
|
throw new AuthenticatorException("Unable to create new authenticator.", |
| 261 |
|
AuthenticatorException.SYSTEM_ERROR); |
| 262 |
|
} |
| 263 |
|
} catch (IllegalAccessException ex) { |
| 264 |
0
|
logger.error("updateUser: IllegalAccessException caught, throwing AuthenticatorException", ex); |
| 265 |
0
|
throw new AuthenticatorException( |
| 266 |
|
"Authenticator class " + authenticatorClassName + " can not be instantiated.", |
| 267 |
|
AuthenticatorException.SYSTEM_ERROR, ex); |
| 268 |
|
} catch (InstantiationException ex) { |
| 269 |
0
|
logger.error("updateUser: InstantiationException caught, throwing AuthenticatorException", ex); |
| 270 |
0
|
throw new AuthenticatorException( |
| 271 |
|
"Authenticator class " + authenticatorClassName + " can not be instantiated.", |
| 272 |
|
AuthenticatorException.SYSTEM_ERROR, ex); |
| 273 |
|
} catch (ClassCastException ex) { |
| 274 |
0
|
logger.error("updateUser: ClassCastException caught, throwing AuthenticatorException", ex); |
| 275 |
0
|
throw new AuthenticatorException( |
| 276 |
|
"Authenticator class " + authenticatorClassName |
| 277 |
|
+ " does not extend the PluggableAuthenticator class.", |
| 278 |
|
AuthenticatorException.SYSTEM_ERROR, ex); |
| 279 |
|
} catch (AuthenticatorException ex) { |
| 280 |
0
|
logger.error("updateUser: AuthenticatorException caught, throwing AuthenticatorException", ex); |
| 281 |
0
|
throw new UserException("Unable to update user.", ex); |
| 282 |
|
} |
| 283 |
|
|
| 284 |
|
|
| 285 |
0
|
Integer id = user.getId(); |
| 286 |
0
|
userDAO.detach(user); |
| 287 |
|
|
| 288 |
0
|
User existinguser = userDAO.findByPrimaryKey(id); |
| 289 |
0
|
userDAO.refresh(existinguser); |
| 290 |
|
|
| 291 |
0
|
existinguser.setLogin(user.getLogin()); |
| 292 |
0
|
existinguser.setFirstName(user.getFirstName()); |
| 293 |
0
|
existinguser.setLastName(user.getLastName()); |
| 294 |
0
|
existinguser.setEmail(user.getEmail()); |
| 295 |
0
|
existinguser.setSuperUser(user.isSuperUser()); |
| 296 |
|
|
| 297 |
0
|
existinguser.setStatus(user.getStatus()); |
| 298 |
|
|
| 299 |
|
|
| 300 |
|
|
| 301 |
|
|
| 302 |
0
|
if (user.getPassword() != null && (!user.getPassword().equals(""))) { |
| 303 |
|
|
| 304 |
0
|
if (logger.isInfoEnabled()) { |
| 305 |
0
|
logger.info("updateUser: setting new password for " + user.getLogin()); |
| 306 |
|
} |
| 307 |
0
|
existinguser.setPassword(user.getPassword()); |
| 308 |
|
} |
| 309 |
|
|
| 310 |
0
|
userDAO.saveOrUpdate(existinguser); |
| 311 |
|
|
| 312 |
|
|
| 313 |
|
|
| 314 |
0
|
return existinguser; |
| 315 |
|
} |
| 316 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 317 |
0
|
public String generateUserPassword(User user) throws PasswordException {... |
| 318 |
0
|
String password = UserUtilities.generatePassword(); |
| 319 |
0
|
user.setPassword(UserUtilities.encryptPassword(password)); |
| 320 |
0
|
return password; |
| 321 |
|
|
| 322 |
|
} |
| 323 |
|
|
|
|
|
| 0% |
Uncovered Elements: 48 (48) |
Complexity: 9 |
Complexity Density: 0.22 |
|
| 324 |
0
|
public UserPreferences updateUserPreferences(UserPreferences userPrefs) throws UserException {... |
| 325 |
0
|
UserPreferences newUserPrefs = new UserPreferences(); |
| 326 |
|
|
| 327 |
0
|
try { |
| 328 |
0
|
User user = userPrefs.getUser(); |
| 329 |
|
|
| 330 |
0
|
newUserPrefs = userPreferencesDAO.findByUserId(user.getId()); |
| 331 |
|
|
| 332 |
0
|
if (newUserPrefs == null) { |
| 333 |
0
|
newUserPrefs = new UserPreferences(); |
| 334 |
|
} |
| 335 |
0
|
newUserPrefs.setSaveLogin(userPrefs.getSaveLogin()); |
| 336 |
0
|
newUserPrefs.setUserLocale(userPrefs.getUserLocale()); |
| 337 |
0
|
newUserPrefs.setNumItemsOnIndex(userPrefs.getNumItemsOnIndex()); |
| 338 |
0
|
newUserPrefs.setNumItemsOnIssueList(userPrefs.getNumItemsOnIssueList()); |
| 339 |
0
|
newUserPrefs.setShowClosedOnIssueList(userPrefs.getShowClosedOnIssueList()); |
| 340 |
0
|
newUserPrefs.setSortColumnOnIssueList(userPrefs.getSortColumnOnIssueList()); |
| 341 |
0
|
newUserPrefs.setHiddenIndexSections(userPrefs.getHiddenIndexSections()); |
| 342 |
|
|
| 343 |
0
|
newUserPrefs.setRememberLastSearch(userPrefs.getRememberLastSearch()); |
| 344 |
0
|
newUserPrefs.setUseTextActions(userPrefs.getUseTextActions()); |
| 345 |
|
|
| 346 |
|
|
| 347 |
0
|
newUserPrefs.setUser(user); |
| 348 |
|
|
| 349 |
0
|
if (userPrefs.isNew()) { |
| 350 |
0
|
newUserPrefs.setCreateDate(new Date()); |
| 351 |
0
|
newUserPrefs.setLastModifiedDate(userPrefs.getCreateDate()); |
| 352 |
|
|
| 353 |
|
|
| 354 |
0
|
user.setPreferences(newUserPrefs); |
| 355 |
0
|
userDAO.saveOrUpdate(user); |
| 356 |
|
} else { |
| 357 |
0
|
this.userPreferencesDAO.saveOrUpdate(newUserPrefs); |
| 358 |
0
|
newUserPrefs = userPreferencesDAO.findByUserId(user.getId()); |
| 359 |
0
|
user.setUserPreferences(newUserPrefs); |
| 360 |
|
} |
| 361 |
|
|
| 362 |
0
|
try { |
| 363 |
0
|
PluggableAuthenticator authenticator = |
| 364 |
|
(PluggableAuthenticator) authenticatorClass.newInstance(); |
| 365 |
|
|
| 366 |
0
|
if (authenticator != null) { |
| 367 |
0
|
HashMap<String, Object> values = new HashMap<String, Object>(); |
| 368 |
0
|
values.put("userService", this); |
| 369 |
0
|
values.put("configurationService", configurationService); |
| 370 |
0
|
authenticator.initialize(values); |
| 371 |
0
|
authenticator.updateProfile(user, AuthenticationConstants.UPDATE_TYPE_PREFERENCE, null, |
| 372 |
|
AuthenticationConstants.AUTH_TYPE_UNKNOWN, AuthenticationConstants.REQ_SOURCE_UNKNOWN); |
| 373 |
|
} else { |
| 374 |
0
|
throw new AuthenticatorException("Unable to create new authenticator.", |
| 375 |
|
AuthenticatorException.SYSTEM_ERROR); |
| 376 |
|
} |
| 377 |
|
} catch (IllegalAccessException ex) { |
| 378 |
0
|
throw new AuthenticatorException( |
| 379 |
|
"Authenticator class " + authenticatorClassName + " can not be instantiated.", |
| 380 |
|
AuthenticatorException.SYSTEM_ERROR, ex); |
| 381 |
|
} catch (InstantiationException ex) { |
| 382 |
0
|
throw new AuthenticatorException( |
| 383 |
|
"Authenticator class " + authenticatorClassName + " can not be instantiated.", |
| 384 |
|
AuthenticatorException.SYSTEM_ERROR, ex); |
| 385 |
|
} catch (ClassCastException ex) { |
| 386 |
0
|
throw new AuthenticatorException( |
| 387 |
|
"Authenticator class " + authenticatorClassName |
| 388 |
|
+ " does not extend the PluggableAuthenticator class.", |
| 389 |
|
AuthenticatorException.SYSTEM_ERROR, ex); |
| 390 |
|
} |
| 391 |
|
|
| 392 |
0
|
if (newUserPrefs != null) |
| 393 |
0
|
return newUserPrefs; |
| 394 |
|
|
| 395 |
|
} catch (AuthenticatorException ex) { |
| 396 |
0
|
throw new UserException("Unable to create new preferences.", ex); |
| 397 |
|
} |
| 398 |
|
|
| 399 |
0
|
return userPrefs; |
| 400 |
|
|
| 401 |
|
} |
| 402 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 403 |
0
|
public void clearOwnedProjects(User user) {... |
| 404 |
0
|
user.getProjects().clear(); |
| 405 |
0
|
userDAO.save(user); |
| 406 |
|
} |
| 407 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 408 |
0
|
public List<User> findUsersForProjectByPermissionTypeList(Integer projectID, Integer[] permissionTypes) {... |
| 409 |
0
|
return userDAO.findUsersForProjectByAllPermissionTypeList(projectID, permissionTypes); |
| 410 |
|
} |
| 411 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 412 |
0
|
public List<User> getUsersWithPermissionLocal(Integer projectId, int permissionType) {... |
| 413 |
|
|
| 414 |
0
|
List<User> users = new ArrayList<User>(); |
| 415 |
|
|
| 416 |
0
|
if (projectId != null) { |
| 417 |
0
|
List<Permission> permissions = permissionDAO.findByProjectIdAndPermission( |
| 418 |
|
projectId, permissionType); |
| 419 |
|
|
| 420 |
0
|
for (Permission permission : permissions) { |
| 421 |
0
|
users.add(permission.getUser()); |
| 422 |
|
} |
| 423 |
|
|
| 424 |
|
} |
| 425 |
|
|
| 426 |
0
|
return users; |
| 427 |
|
|
| 428 |
|
} |
| 429 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 430 |
0
|
public List<Permission> getUserPermissionsLocal(User user) {... |
| 431 |
0
|
List<Permission> permissions = permissionDAO.findByUserId(user.getId()); |
| 432 |
0
|
return permissions; |
| 433 |
|
} |
| 434 |
|
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 7 |
Complexity Density: 0.41 |
|
| 435 |
0
|
public List<Permission> getPermissionsByUserId(Integer userId) {... |
| 436 |
0
|
List<Permission> permissions = new ArrayList<Permission>(); |
| 437 |
|
|
| 438 |
0
|
User user = getUser(userId); |
| 439 |
0
|
if (user != null) { |
| 440 |
0
|
try { |
| 441 |
0
|
PluggableAuthenticator authenticator = (PluggableAuthenticator) authenticatorClass.newInstance(); |
| 442 |
0
|
if (authenticator != null) { |
| 443 |
0
|
HashMap<String, Object> values = new HashMap<String, Object>(); |
| 444 |
0
|
values.put("userService", this); |
| 445 |
0
|
values.put("configurationService", configurationService); |
| 446 |
0
|
authenticator.initialize(values); |
| 447 |
0
|
permissions = authenticator.getUserPermissions(user, AuthenticationConstants.REQ_SOURCE_UNKNOWN); |
| 448 |
|
} |
| 449 |
0
|
logger.debug("Found " + permissions.size() + " permissions for user " + user.getLogin()); |
| 450 |
|
} catch (IllegalAccessException ex) { |
| 451 |
0
|
throw new RuntimeException("Authenticator class " |
| 452 |
|
+ authenticatorClassName + " can not be instantiated.", ex); |
| 453 |
|
} catch (InstantiationException ex) { |
| 454 |
0
|
throw new RuntimeException("Authenticator class " |
| 455 |
|
+ authenticatorClassName + " can not be instantiated.", ex); |
| 456 |
|
} catch (ClassCastException ex) { |
| 457 |
0
|
throw new RuntimeException("Authenticator class " + authenticatorClassName |
| 458 |
|
+ " does not extend the PluggableAuthenticator class.", ex); |
| 459 |
|
} catch (AuthenticatorException ex) { |
| 460 |
0
|
throw new RuntimeException("Authenticator exception: ", ex); |
| 461 |
|
} |
| 462 |
|
} |
| 463 |
0
|
return permissions; |
| 464 |
|
} |
| 465 |
|
|
|
|
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 7 |
Complexity Density: 0.29 |
|
| 466 |
0
|
public boolean updateAuthenticator(Integer userId, List<Permission> permissions) {... |
| 467 |
0
|
boolean successful = false; |
| 468 |
|
|
| 469 |
0
|
try { |
| 470 |
0
|
User user = userDAO.findByPrimaryKey(userId); |
| 471 |
0
|
user.getPermissions().addAll(permissions); |
| 472 |
|
|
| 473 |
0
|
try { |
| 474 |
0
|
PluggableAuthenticator authenticator = (PluggableAuthenticator) authenticatorClass.newInstance(); |
| 475 |
0
|
if (authenticator != null) { |
| 476 |
0
|
HashMap<String, Object> values = new HashMap<String, Object>(); |
| 477 |
0
|
values.put("userService", this); |
| 478 |
0
|
values.put("configurationService", configurationService); |
| 479 |
0
|
authenticator.initialize(values); |
| 480 |
0
|
if (authenticator |
| 481 |
|
.updateProfile(user, AuthenticationConstants.UPDATE_TYPE_PERMISSION_SET, null, |
| 482 |
|
AuthenticationConstants.AUTH_TYPE_UNKNOWN, |
| 483 |
|
AuthenticationConstants.REQ_SOURCE_UNKNOWN)) { |
| 484 |
|
|
| 485 |
|
} |
| 486 |
|
} else { |
| 487 |
0
|
logger.error("Unable to create new authenticator."); |
| 488 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 489 |
|
} |
| 490 |
0
|
successful = true; |
| 491 |
|
} catch (IllegalAccessException iae) { |
| 492 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 493 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 494 |
|
} catch (InstantiationException ie) { |
| 495 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 496 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 497 |
|
} catch (ClassCastException cce) { |
| 498 |
0
|
logger.error("Authenticator class " + authenticatorClassName |
| 499 |
|
+ " does not extend the PluggableAuthenticator class."); |
| 500 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 501 |
|
} |
| 502 |
|
|
| 503 |
|
} catch (AuthenticatorException ae) { |
| 504 |
0
|
logger.warn("Error setting user (" + userId + ") permissions. AuthenticatorException.", ae); |
| 505 |
0
|
successful = false; |
| 506 |
|
} |
| 507 |
|
|
| 508 |
0
|
return successful; |
| 509 |
|
} |
| 510 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.4 |
|
| 511 |
0
|
public boolean addUserPermissions(Integer userId, List<Permission> newPermissions) {... |
| 512 |
0
|
boolean successful = false; |
| 513 |
0
|
if (newPermissions == null || newPermissions.size() == 0) { |
| 514 |
0
|
return successful; |
| 515 |
|
} |
| 516 |
|
|
| 517 |
0
|
try { |
| 518 |
0
|
newPermissions.addAll(getUserPermissionsLocal(getUser(userId))); |
| 519 |
0
|
setUserPermissions(userId, newPermissions); |
| 520 |
0
|
successful = true; |
| 521 |
|
} catch (AuthenticatorException ae) { |
| 522 |
0
|
logger.warn("Error setting user (" + userId + ") permissions. AuthenticatorException.", ae); |
| 523 |
0
|
successful = false; |
| 524 |
|
} |
| 525 |
|
|
| 526 |
0
|
return successful; |
| 527 |
|
} |
| 528 |
|
|
| 529 |
|
|
| 530 |
|
|
| 531 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 532 |
0
|
private static final Permission find(Collection<Permission> permissions, Permission permission) {... |
| 533 |
|
|
| 534 |
0
|
Iterator<Permission> permssionsIt = permissions.iterator(); |
| 535 |
0
|
while (permssionsIt.hasNext()) { |
| 536 |
0
|
Permission permission2 = (Permission) permssionsIt.next(); |
| 537 |
0
|
if (Permission.PERMISSION_PROPERTIES_COMPARATOR.compare(permission, permission2) == 0) { |
| 538 |
|
|
| 539 |
0
|
return permission2; |
| 540 |
|
} |
| 541 |
|
} |
| 542 |
0
|
return null; |
| 543 |
|
} |
| 544 |
|
|
| 545 |
|
|
| 546 |
|
@param |
| 547 |
|
@param |
| 548 |
|
|
|
|
|
| 0% |
Uncovered Elements: 45 (45) |
Complexity: 8 |
Complexity Density: 0.24 |
|
| 549 |
0
|
public boolean setUserPermissions(final Integer userId, final List<Permission> newPermissions) {... |
| 550 |
|
|
| 551 |
0
|
boolean hasChanges = false; |
| 552 |
|
|
| 553 |
|
|
| 554 |
0
|
TreeSet<Permission> pSet = new TreeSet<Permission>(Permission.PERMISSION_PROPERTIES_COMPARATOR); |
| 555 |
0
|
pSet.addAll(newPermissions); |
| 556 |
|
|
| 557 |
|
|
| 558 |
0
|
User usermodel = this.getUser(userId); |
| 559 |
|
|
| 560 |
0
|
Set<Permission> current = new TreeSet<Permission>(Permission.PERMISSION_PROPERTIES_COMPARATOR); |
| 561 |
|
|
| 562 |
0
|
current.addAll(usermodel.getPermissions()); |
| 563 |
|
|
| 564 |
|
|
| 565 |
0
|
Set<Permission> remove = new TreeSet<Permission>(Permission.PERMISSION_PROPERTIES_COMPARATOR); |
| 566 |
0
|
remove.addAll(current); |
| 567 |
0
|
remove.removeAll(pSet); |
| 568 |
|
|
| 569 |
0
|
Set<Permission> add = new TreeSet<Permission>(Permission.PERMISSION_PROPERTIES_COMPARATOR); |
| 570 |
0
|
add.addAll(pSet); |
| 571 |
0
|
add.removeAll(current); |
| 572 |
|
|
| 573 |
|
|
| 574 |
0
|
Permission p; |
| 575 |
0
|
Iterator<Permission> pIt = remove.iterator(); |
| 576 |
0
|
while (pIt.hasNext()) { |
| 577 |
0
|
p = find(usermodel.getPermissions(), (Permission) pIt.next()); |
| 578 |
0
|
if (null == p) { |
| 579 |
0
|
continue; |
| 580 |
|
} |
| 581 |
0
|
if (usermodel.getPermissions().contains(p)) { |
| 582 |
0
|
usermodel.getPermissions().remove(p); |
| 583 |
0
|
permissionDAO.delete(p); |
| 584 |
0
|
hasChanges = true; |
| 585 |
|
} |
| 586 |
|
} |
| 587 |
|
|
| 588 |
0
|
pIt = add.iterator(); |
| 589 |
0
|
while (pIt.hasNext()) { |
| 590 |
0
|
p = pIt.next(); |
| 591 |
0
|
if (null == find(usermodel.getPermissions(), p) && !usermodel.getPermissions().contains(p)) { |
| 592 |
0
|
p.setUser(usermodel); |
| 593 |
0
|
usermodel.getPermissions().add(p); |
| 594 |
0
|
permissionDAO.save(p); |
| 595 |
0
|
hasChanges = true; |
| 596 |
|
} |
| 597 |
|
} |
| 598 |
|
|
| 599 |
0
|
if (hasChanges) { |
| 600 |
0
|
userDAO.saveOrUpdate(usermodel); |
| 601 |
|
} |
| 602 |
|
|
| 603 |
0
|
return hasChanges; |
| 604 |
|
} |
| 605 |
|
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 5 |
Complexity Density: 0.45 |
|
| 606 |
0
|
public boolean removeUserPermissions(Integer userId, List<Permission> newPermissions) {... |
| 607 |
0
|
boolean successful = false; |
| 608 |
0
|
if (newPermissions == null || newPermissions.size() == 0) { |
| 609 |
0
|
return successful; |
| 610 |
|
} |
| 611 |
|
|
| 612 |
0
|
try { |
| 613 |
0
|
for (Iterator<Permission> delIterator = newPermissions.iterator(); delIterator.hasNext();) { |
| 614 |
0
|
Permission permission = (Permission) delIterator.next(); |
| 615 |
0
|
permissionDAO.delete(permission); |
| 616 |
|
} |
| 617 |
|
|
| 618 |
0
|
successful = true; |
| 619 |
|
|
| 620 |
|
} catch (AuthenticatorException ae) { |
| 621 |
0
|
logger.warn("Error setting user (" + userId + ") permissions. AuthenticatorException.", ae); |
| 622 |
0
|
successful = false; |
| 623 |
|
} |
| 624 |
|
|
| 625 |
0
|
return successful; |
| 626 |
|
} |
| 627 |
|
|
|
|
|
| 0% |
Uncovered Elements: 52 (52) |
Complexity: 13 |
Complexity Density: 0.38 |
|
| 628 |
0
|
@Deprecated... |
| 629 |
|
public Map<Integer, Set<PermissionType>> getUsersMapOfProjectIdsAndSetOfPermissionTypes(User user, int reqSource) { |
| 630 |
0
|
Map<Integer, Set<PermissionType>> permissionsMap = new HashMap<Integer, Set<PermissionType>>(); |
| 631 |
|
|
| 632 |
0
|
if (user == null) { |
| 633 |
0
|
return permissionsMap; |
| 634 |
|
} |
| 635 |
|
|
| 636 |
0
|
List<Permission> permissionList = new ArrayList<Permission>(); |
| 637 |
|
|
| 638 |
0
|
try { |
| 639 |
0
|
PluggableAuthenticator authenticator = |
| 640 |
|
(PluggableAuthenticator) authenticatorClass.newInstance(); |
| 641 |
|
|
| 642 |
0
|
if (authenticator != null) { |
| 643 |
0
|
HashMap<String, Object> values = new HashMap<String, Object>(); |
| 644 |
0
|
values.put("userService", this); |
| 645 |
0
|
values.put("configurationService", configurationService); |
| 646 |
0
|
authenticator.initialize(values); |
| 647 |
0
|
permissionList = authenticator.getUserPermissions(user, (reqSource == 0 ? AuthenticationConstants.REQ_SOURCE_UNKNOWN : reqSource)); |
| 648 |
|
} |
| 649 |
0
|
logger.debug("Found " + permissionList.size() + " permissions for user " + user.getLogin()); |
| 650 |
|
} catch (IllegalAccessException iae) { |
| 651 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 652 |
|
} catch (InstantiationException ie) { |
| 653 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 654 |
|
} catch (ClassCastException cce) { |
| 655 |
0
|
logger.error("Authenticator class " + authenticatorClassName |
| 656 |
|
+ " does not extend the PluggableAuthenticator class."); |
| 657 |
|
} catch (AuthenticatorException ae) { |
| 658 |
0
|
logger.error("Authenticator exception: " + ae.getMessage()); |
| 659 |
0
|
logger.debug("Authenticator exception: ", ae); |
| 660 |
|
} |
| 661 |
|
|
| 662 |
0
|
permissionsMap = UserUtilities.mapPermissionTypesByProjectId(permissionList); |
| 663 |
|
|
| 664 |
0
|
if (allowSelfRegister) { |
| 665 |
0
|
List<Project> projects = projectService.getAllProjects(); |
| 666 |
|
|
| 667 |
0
|
for (int i = 0; i < projects.size(); i++) { |
| 668 |
0
|
Project project = projects.get(i); |
| 669 |
|
|
| 670 |
0
|
if (project.getOptions() >= ProjectUtilities.OPTION_ALLOW_SELF_REGISTERED_CREATE) { |
| 671 |
0
|
Set<PermissionType> projectPermissions = permissionsMap.get(project.getId()); |
| 672 |
|
|
| 673 |
0
|
if (projectPermissions == null) { |
| 674 |
0
|
projectPermissions = new HashSet<PermissionType>(); |
| 675 |
0
|
permissionsMap.put(project.getId(), projectPermissions); |
| 676 |
|
} |
| 677 |
|
|
| 678 |
0
|
if (ProjectUtilities.hasOption(ProjectUtilities.OPTION_ALLOW_SELF_REGISTERED_CREATE, project.getOptions())) { |
| 679 |
0
|
projectPermissions.add(PermissionType.ISSUE_VIEW_USERS); |
| 680 |
0
|
projectPermissions.add(PermissionType.ISSUE_CREATE); |
| 681 |
|
} |
| 682 |
|
|
| 683 |
0
|
if (ProjectUtilities.hasOption(ProjectUtilities.OPTION_ALLOW_SELF_REGISTERED_VIEW_ALL, project.getOptions())) { |
| 684 |
0
|
projectPermissions.add(PermissionType.ISSUE_VIEW_ALL); |
| 685 |
|
} |
| 686 |
|
} |
| 687 |
|
} |
| 688 |
|
} |
| 689 |
|
|
| 690 |
0
|
return permissionsMap; |
| 691 |
|
} |
| 692 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 693 |
0
|
public List<User> getUsersWithProjectPermission(Integer projectId, int permissionType) {... |
| 694 |
0
|
return getUsersWithProjectPermission(projectId, permissionType, true); |
| 695 |
|
} |
| 696 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 697 |
0
|
public List<User> getUsersWithProjectPermission(Integer projectId, int permissionType, boolean activeOnly) {... |
| 698 |
0
|
return getUsersWithAnyProjectPermission(projectId, new int[]{permissionType}, activeOnly); |
| 699 |
|
} |
| 700 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 701 |
0
|
public List<User> getUsersWithAnyProjectPermission(Integer projectId, int[] permissionTypes) {... |
| 702 |
0
|
return getUsersWithAnyProjectPermission(projectId, permissionTypes, true); |
| 703 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 704 |
0
|
public Collection<User> getUsersWithAnyProjectPermission(Integer projectId, Integer[] permissionTypes) {... |
| 705 |
0
|
int[] perm = new int[permissionTypes.length]; |
| 706 |
|
|
| 707 |
0
|
for (int i = 0; i < permissionTypes.length; i++) { |
| 708 |
0
|
perm[i] = permissionTypes[i]; |
| 709 |
|
} |
| 710 |
|
|
| 711 |
0
|
return getUsersWithAnyProjectPermission(projectId, perm, true); |
| 712 |
|
} |
| 713 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 714 |
0
|
public List<User> getUsersWithAnyProjectPermission(Integer projectId, int[] permissionTypes, boolean activeOnly) {... |
| 715 |
0
|
return getUsersWithProjectPermission(projectId, permissionTypes, false, activeOnly); |
| 716 |
|
} |
| 717 |
|
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 7 |
Complexity Density: 0.44 |
|
| 718 |
0
|
public List<User> getUsersWithProjectPermission(Integer projectId, int[] permissionTypes, boolean requireAll,... |
| 719 |
|
boolean activeOnly) { |
| 720 |
0
|
List<User> userList = new ArrayList<User>(); |
| 721 |
|
|
| 722 |
0
|
try { |
| 723 |
|
|
| 724 |
0
|
PluggableAuthenticator authenticator = (PluggableAuthenticator) authenticatorClass.newInstance(); |
| 725 |
|
|
| 726 |
0
|
if (authenticator != null) { |
| 727 |
0
|
Map<String, Object> values = new HashMap<String, Object>(); |
| 728 |
0
|
values.put("userService", this); |
| 729 |
0
|
values.put("configurationService", configurationService); |
| 730 |
0
|
authenticator.initialize(values); |
| 731 |
|
|
| 732 |
0
|
userList = authenticator.getUsersWithProjectPermission(projectId, permissionTypes, requireAll, activeOnly, |
| 733 |
|
AuthenticationConstants.REQ_SOURCE_UNKNOWN); |
| 734 |
|
|
| 735 |
|
} |
| 736 |
|
|
| 737 |
0
|
if (logger.isDebugEnabled()) { |
| 738 |
0
|
logger.debug("getUsersWithProjectPermission: Found " + userList.size() + " users with project " + projectId + " permissions " |
| 739 |
0
|
+ Arrays.toString(permissionTypes) + (requireAll ? "[AllReq," : "[AnyReq,") |
| 740 |
0
|
+ (activeOnly ? "ActiveUsersOnly]" : "AllUsers]")); |
| 741 |
|
} |
| 742 |
|
|
| 743 |
|
|
| 744 |
|
} catch (IllegalAccessException iae) { |
| 745 |
0
|
logger.error("getUsersWithProjectPermission: Authenticator class " + authenticatorClassName + " can not be instantiated.", iae); |
| 746 |
|
} catch (InstantiationException ie) { |
| 747 |
0
|
logger.error("getUsersWithProjectPermission: Authenticator class " + authenticatorClassName + " can not be instantiated.", ie); |
| 748 |
|
} catch (ClassCastException cce) { |
| 749 |
0
|
logger.error("getUsersWithProjectPermission: Authenticator class " + authenticatorClassName |
| 750 |
|
+ " does not extend the PluggableAuthenticator class.", cce); |
| 751 |
|
} catch (AuthenticatorException ae) { |
| 752 |
0
|
logger.error("getUsersWithProjectPermission: Authenticator exception caught.", ae); |
| 753 |
|
} |
| 754 |
|
|
| 755 |
0
|
return userList; |
| 756 |
|
} |
| 757 |
|
|
|
|
|
| 0% |
Uncovered Elements: 39 (39) |
Complexity: 9 |
Complexity Density: 0.39 |
|
| 758 |
0
|
public List<User> getPossibleOwners(Issue issue, Integer projectId, Integer userId) {... |
| 759 |
0
|
HashSet<User> users = new HashSet<User>(); |
| 760 |
|
|
| 761 |
0
|
List<User> editUsers = getUsersWithProjectPermission(projectId, UserUtilities.PERMISSION_EDIT, true); |
| 762 |
0
|
for (int i = 0; i < editUsers.size(); i++) { |
| 763 |
0
|
users.add(editUsers.get(i)); |
| 764 |
|
} |
| 765 |
0
|
List<User> otherUsers = getUsersWithProjectPermission(projectId, new int[]{UserUtilities.PERMISSION_EDIT_USERS, UserUtilities.PERMISSION_ASSIGNABLE}, true, true); |
| 766 |
0
|
for (int i = 0; i < otherUsers.size(); i++) { |
| 767 |
0
|
users.add(otherUsers.get(i)); |
| 768 |
|
} |
| 769 |
|
|
| 770 |
0
|
if (issue != null) { |
| 771 |
|
|
| 772 |
|
|
| 773 |
0
|
User creator = issue.getCreator(); |
| 774 |
|
|
| 775 |
0
|
if (UserUtilities.hasPermission(getUsersMapOfProjectIdsAndSetOfPermissionTypes(creator, 0), projectId, |
| 776 |
|
UserUtilities.PERMISSION_EDIT_USERS)) { |
| 777 |
0
|
users.add(creator); |
| 778 |
|
} |
| 779 |
0
|
if (issue.getOwner() != null) { |
| 780 |
0
|
User owner = issue.getOwner(); |
| 781 |
0
|
users.add(owner); |
| 782 |
|
} |
| 783 |
0
|
} else if (userId != null) { |
| 784 |
|
|
| 785 |
0
|
User creator = getUser(userId); |
| 786 |
0
|
if (UserUtilities.hasPermission(getUsersMapOfProjectIdsAndSetOfPermissionTypes(creator, 0), projectId, |
| 787 |
|
UserUtilities.PERMISSION_EDIT_USERS)) { |
| 788 |
0
|
users.add(creator); |
| 789 |
|
} |
| 790 |
|
} |
| 791 |
|
|
| 792 |
0
|
int i = 0; |
| 793 |
0
|
List<User> userList = new ArrayList<User>(); |
| 794 |
0
|
for (Iterator<User> iter = users.iterator(); iter.hasNext(); i++) { |
| 795 |
0
|
userList.add((User) iter.next()); |
| 796 |
|
} |
| 797 |
0
|
return userList; |
| 798 |
|
} |
| 799 |
|
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.31 |
|
| 800 |
0
|
public User checkLogin(String login, Object authentication, int authType, int reqSource)... |
| 801 |
|
throws AuthenticatorException { |
| 802 |
0
|
try { |
| 803 |
0
|
PluggableAuthenticator authenticator = (PluggableAuthenticator) authenticatorClass.newInstance(); |
| 804 |
0
|
if (authenticator != null) { |
| 805 |
0
|
HashMap<String, Object> values = new HashMap<String, Object>(); |
| 806 |
0
|
values.put("userService", this); |
| 807 |
0
|
values.put("configurationService", configurationService); |
| 808 |
0
|
authenticator.initialize(values); |
| 809 |
0
|
return authenticator.checkLogin(login, authentication, authType, |
| 810 |
0
|
(reqSource == 0 ? AuthenticationConstants.REQ_SOURCE_UNKNOWN : reqSource)); |
| 811 |
|
} |
| 812 |
|
|
| 813 |
0
|
logger.error("Unable to create new authenticator."); |
| 814 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 815 |
|
} catch (IllegalAccessException iae) { |
| 816 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 817 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 818 |
|
} catch (InstantiationException ie) { |
| 819 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 820 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 821 |
|
} catch (ClassCastException cce) { |
| 822 |
0
|
logger.error("Authenticator class " + authenticatorClassName |
| 823 |
|
+ " does not extend the PluggableAuthenticator class."); |
| 824 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 825 |
|
} |
| 826 |
|
} |
| 827 |
|
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 6 |
Complexity Density: 0.33 |
|
| 828 |
0
|
public boolean allowRegistration(User user, Object authentication, int authType, int reqSource)... |
| 829 |
|
throws AuthenticatorException { |
| 830 |
0
|
try { |
| 831 |
0
|
PluggableAuthenticator authenticator = (PluggableAuthenticator) authenticatorClass.newInstance(); |
| 832 |
0
|
if (authenticator != null) { |
| 833 |
0
|
HashMap<String, Object> values = new HashMap<String, Object>(); |
| 834 |
0
|
values.put("userService", this); |
| 835 |
0
|
values.put("configurationService", configurationService); |
| 836 |
0
|
authenticator.initialize(values); |
| 837 |
0
|
if (authenticator.allowProfileCreation(user, authentication, authType, |
| 838 |
0
|
(reqSource == 0 ? AuthenticationConstants.REQ_SOURCE_UNKNOWN : reqSource))) { |
| 839 |
0
|
return authenticator.allowRegistration(user, authentication, authType, |
| 840 |
0
|
(reqSource == 0 ? AuthenticationConstants.REQ_SOURCE_UNKNOWN : reqSource)); |
| 841 |
|
} |
| 842 |
0
|
return false; |
| 843 |
|
} |
| 844 |
|
|
| 845 |
0
|
logger.error("Unable to create new authenticator."); |
| 846 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 847 |
|
} catch (IllegalAccessException iae) { |
| 848 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 849 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 850 |
|
} catch (InstantiationException ie) { |
| 851 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 852 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 853 |
|
} catch (ClassCastException cce) { |
| 854 |
0
|
logger.error("Authenticator class " + authenticatorClassName |
| 855 |
|
+ " does not extend the PluggableAuthenticator class."); |
| 856 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 857 |
|
} |
| 858 |
|
} |
| 859 |
|
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.31 |
|
| 860 |
0
|
public boolean allowProfileCreation(User user, Object authentication, int authType, int reqSource)... |
| 861 |
|
throws AuthenticatorException { |
| 862 |
0
|
try { |
| 863 |
0
|
PluggableAuthenticator authenticator = (PluggableAuthenticator) authenticatorClass.newInstance(); |
| 864 |
0
|
if (authenticator != null) { |
| 865 |
0
|
HashMap<String, Object> values = new HashMap<String, Object>(); |
| 866 |
0
|
values.put("userService", this); |
| 867 |
0
|
values.put("configurationService", configurationService); |
| 868 |
0
|
authenticator.initialize(values); |
| 869 |
0
|
return authenticator.allowProfileCreation(user, authentication, authType, |
| 870 |
0
|
(reqSource == 0 ? AuthenticationConstants.REQ_SOURCE_UNKNOWN : reqSource)); |
| 871 |
|
} |
| 872 |
|
|
| 873 |
0
|
logger.error("Unable to create new authenticator."); |
| 874 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 875 |
|
} catch (IllegalAccessException iae) { |
| 876 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 877 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 878 |
|
} catch (InstantiationException ie) { |
| 879 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 880 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 881 |
|
} catch (ClassCastException cce) { |
| 882 |
0
|
logger.error("Authenticator class " + authenticatorClassName |
| 883 |
|
+ " does not extend the PluggableAuthenticator class."); |
| 884 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 885 |
|
} |
| 886 |
|
} |
| 887 |
|
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.31 |
|
| 888 |
0
|
public boolean allowProfileUpdates(User user, Object authentication, int authType, int reqSource)... |
| 889 |
|
throws AuthenticatorException { |
| 890 |
0
|
try { |
| 891 |
0
|
PluggableAuthenticator authenticator = (PluggableAuthenticator) authenticatorClass.newInstance(); |
| 892 |
0
|
if (authenticator != null) { |
| 893 |
0
|
HashMap<String, Object> values = new HashMap<String, Object>(); |
| 894 |
0
|
values.put("userService", this); |
| 895 |
0
|
values.put("configurationService", configurationService); |
| 896 |
0
|
authenticator.initialize(values); |
| 897 |
0
|
return authenticator.allowProfileUpdates(user, authentication, authType, |
| 898 |
0
|
(reqSource == 0 ? AuthenticationConstants.REQ_SOURCE_UNKNOWN : reqSource)); |
| 899 |
|
} |
| 900 |
|
|
| 901 |
0
|
logger.error("Unable to create new authenticator."); |
| 902 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 903 |
|
} catch (IllegalAccessException iae) { |
| 904 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 905 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 906 |
|
} catch (InstantiationException ie) { |
| 907 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 908 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 909 |
|
} catch (ClassCastException cce) { |
| 910 |
0
|
logger.error("Authenticator class " + authenticatorClassName |
| 911 |
|
+ " does not extend the PluggableAuthenticator class."); |
| 912 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 913 |
|
} |
| 914 |
|
} |
| 915 |
|
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.31 |
|
| 916 |
0
|
public boolean allowPasswordUpdates(User user, Object authentication, int authType, int reqSource)... |
| 917 |
|
throws AuthenticatorException { |
| 918 |
0
|
try { |
| 919 |
0
|
PluggableAuthenticator authenticator = (PluggableAuthenticator) authenticatorClass.newInstance(); |
| 920 |
0
|
if (authenticator != null) { |
| 921 |
0
|
HashMap<String, Object> values = new HashMap<String, Object>(); |
| 922 |
0
|
values.put("userService", this); |
| 923 |
0
|
values.put("configurationService", configurationService); |
| 924 |
0
|
authenticator.initialize(values); |
| 925 |
0
|
return authenticator.allowPasswordUpdates(user, authentication, authType, |
| 926 |
0
|
(reqSource == 0 ? AuthenticationConstants.REQ_SOURCE_UNKNOWN : reqSource)); |
| 927 |
|
} |
| 928 |
|
|
| 929 |
0
|
logger.error("Unable to create new authenticator."); |
| 930 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 931 |
|
} catch (IllegalAccessException iae) { |
| 932 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 933 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 934 |
|
} catch (InstantiationException ie) { |
| 935 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 936 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 937 |
|
} catch (ClassCastException cce) { |
| 938 |
0
|
logger.error("Authenticator class " + authenticatorClassName |
| 939 |
|
+ " does not extend the PluggableAuthenticator class."); |
| 940 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 941 |
|
} |
| 942 |
|
} |
| 943 |
|
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.31 |
|
| 944 |
0
|
public boolean allowPermissionUpdates(User user, Object authentication, int authType, int reqSource)... |
| 945 |
|
throws AuthenticatorException { |
| 946 |
0
|
try { |
| 947 |
0
|
PluggableAuthenticator authenticator = (PluggableAuthenticator) authenticatorClass.newInstance(); |
| 948 |
0
|
if (authenticator != null) { |
| 949 |
0
|
HashMap<String, Object> values = new HashMap<String, Object>(); |
| 950 |
0
|
values.put("userService", this); |
| 951 |
0
|
values.put("configurationService", configurationService); |
| 952 |
0
|
authenticator.initialize(values); |
| 953 |
0
|
return authenticator.allowPermissionUpdates(user, authentication, authType, |
| 954 |
0
|
(reqSource == 0 ? AuthenticationConstants.REQ_SOURCE_UNKNOWN : reqSource)); |
| 955 |
|
} |
| 956 |
|
|
| 957 |
0
|
logger.error("Unable to create new authenticator."); |
| 958 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 959 |
|
} catch (IllegalAccessException iae) { |
| 960 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 961 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 962 |
|
} catch (InstantiationException ie) { |
| 963 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 964 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 965 |
|
} catch (ClassCastException cce) { |
| 966 |
0
|
logger.error("Authenticator class " + authenticatorClassName |
| 967 |
|
+ " does not extend the PluggableAuthenticator class."); |
| 968 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 969 |
|
} |
| 970 |
|
} |
| 971 |
|
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.31 |
|
| 972 |
0
|
public boolean allowPreferenceUpdates(User user, Object authentication, int authType, int reqSource)... |
| 973 |
|
throws AuthenticatorException { |
| 974 |
0
|
try { |
| 975 |
0
|
PluggableAuthenticator authenticator = (PluggableAuthenticator) authenticatorClass.newInstance(); |
| 976 |
0
|
if (authenticator != null) { |
| 977 |
0
|
HashMap<String, Object> values = new HashMap<String, Object>(); |
| 978 |
0
|
values.put("userService", this); |
| 979 |
0
|
values.put("configurationService", configurationService); |
| 980 |
0
|
authenticator.initialize(values); |
| 981 |
0
|
return authenticator.allowPreferenceUpdates(user, authentication, authType, |
| 982 |
0
|
(reqSource == 0 ? AuthenticationConstants.REQ_SOURCE_UNKNOWN : reqSource)); |
| 983 |
|
} |
| 984 |
|
|
| 985 |
0
|
logger.error("Unable to create new authenticator."); |
| 986 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 987 |
|
} catch (IllegalAccessException iae) { |
| 988 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 989 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 990 |
|
} catch (InstantiationException ie) { |
| 991 |
0
|
logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated."); |
| 992 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 993 |
|
} catch (ClassCastException cce) { |
| 994 |
0
|
logger.error("Authenticator class " + authenticatorClassName |
| 995 |
|
+ " does not extend the PluggableAuthenticator class."); |
| 996 |
0
|
throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR); |
| 997 |
|
} |
| 998 |
|
} |
| 999 |
|
|
| 1000 |
|
|
| 1001 |
|
|
| 1002 |
|
|
| 1003 |
|
|
| 1004 |
|
} |