UserValidator(Tree parentBefore, Tree parentAfter, UserValidatorProvider provider) { this.parentBefore = parentBefore; this.parentAfter = parentAfter; this.provider = provider; authorizableType = (parentAfter == null) ? null : UserUtil.getType(parentAfter); }
UserImporter(ConfigurationParameters config) { importBehavior = UserUtil.getImportBehavior(config); }
/** * Returns {@code true} if the specified string doesn't start with a * valid algorithm name in curly brackets. * * @param password The string to be tested. * @return {@code true} if the specified string doesn't start with a * valid algorithm name in curly brackets. */ public static boolean isPlainTextPassword(@Nullable String password) { return extractAlgorithm(password) == null; }
@Test(expected=IllegalArgumentException.class) public void testGetAuthorizableIdWithTypeNotUser() { UserUtil.getAuthorizableId(createTree(UserConstants.NT_REP_GROUP, "id"), AuthorizableType.USER); }
/** * Generates a hash of the specified password with the default values * for algorithm, salt-size and number of iterations. * * @param password The password to be hashed. * @return The password hash. * @throws NoSuchAlgorithmException If {@link #DEFAULT_ALGORITHM} is not supported. * @throws UnsupportedEncodingException If utf-8 is not supported. */ public static String buildPasswordHash(@NotNull String password) throws NoSuchAlgorithmException, UnsupportedEncodingException { return buildPasswordHash(password, DEFAULT_ALGORITHM, DEFAULT_SALT_SIZE, DEFAULT_ITERATIONS); }
@Test public void testGetTypeFromTree2() { List<String> test = ImmutableList.of( UserConstants.NT_REP_AUTHORIZABLE, JcrConstants.NT_FILE ); for (String ntName : test) { assertNull(UserUtil.getType(createTree(ntName))); } }
@Override public <T extends Authorizable> T getAuthorizable(String id, Class<T> authorizableClass) throws RepositoryException { return UserUtil.castAuthorizable(getAuthorizable(id), authorizableClass); }
@Test(expected = NullPointerException.class) public void testGetAuthorizableIdNullTree() { UserUtil.getAuthorizableId(null); }
@Test(expected=IllegalArgumentException.class) public void testGetAuthorizableIdTypeNotUser() { UserUtil.getAuthorizableId(createTree(JcrConstants.NT_UNSTRUCTURED, "id"), AuthorizableType.USER); }
/** * Generates a hash of the specified password with the default values * for algorithm, salt-size and number of iterations. * * @param password The password to be hashed. * @return The password hash. * @throws NoSuchAlgorithmException If {@link #DEFAULT_ALGORITHM} is not supported. * @throws UnsupportedEncodingException If utf-8 is not supported. */ public static String buildPasswordHash(@Nonnull String password) throws NoSuchAlgorithmException, UnsupportedEncodingException { return buildPasswordHash(password, DEFAULT_ALGORITHM, DEFAULT_SALT_SIZE, DEFAULT_ITERATIONS); }
UserValidator(Tree parentBefore, Tree parentAfter, UserValidatorProvider provider) { this.parentBefore = parentBefore; this.parentAfter = parentAfter; this.provider = provider; authorizableType = (parentAfter == null) ? null : UserUtil.getType(parentAfter); }
UserImporter(ConfigurationParameters config) { importBehavior = UserUtil.getImportBehavior(config); }
/** * Returns {@code true} if the specified string doesn't start with a * valid algorithm name in curly brackets. * * @param password The string to be tested. * @return {@code true} if the specified string doesn't start with a * valid algorithm name in curly brackets. */ public static boolean isPlainTextPassword(@Nullable String password) { return extractAlgorithm(password) == null; }
@Test(expected=IllegalArgumentException.class) public void testGetAuthorizableIdTypeNotGroup() { UserUtil.getAuthorizableId(createTree(UserConstants.NT_REP_USER, "id"), AuthorizableType.GROUP); }
UserValidator(Tree parentBefore, Tree parentAfter, UserValidatorProvider provider) { this.parentBefore = parentBefore; this.parentAfter = parentAfter; this.provider = provider; authorizableType = (parentAfter == null) ? null : UserUtil.getType(parentAfter); }
UserImporter(ConfigurationParameters config) { importBehavior = UserUtil.getImportBehavior(config); }
@Test(expected=IllegalArgumentException.class) public void testGetAuthorizableIdWithTypeNotGrou() { UserUtil.getAuthorizableId(createTree(UserConstants.NT_REP_SYSTEM_USER, "id"), AuthorizableType.GROUP); }
@Test public void testGetAuthorizableIdNoAuthorizableType() { List<String> test = ImmutableList.of(UserConstants.NT_REP_AUTHORIZABLE, JcrConstants.NT_UNSTRUCTURED); for (String ntName : test) { assertNull(UserUtil.getAuthorizableId(createTree(ntName, "id"))); } }
@Test public void testGetAuthorizableIdFallback() { List<String> test = ImmutableList.of(UserConstants.NT_REP_GROUP, UserConstants.NT_REP_SYSTEM_USER, UserConstants.NT_REP_USER); for (String ntName : test) { assertEquals("nName", UserUtil.getAuthorizableId(createTree(ntName, null, "nName"))); } }
@Test public void testGetAuthorizableId() { List<String> test = ImmutableList.of(UserConstants.NT_REP_GROUP, UserConstants.NT_REP_SYSTEM_USER, UserConstants.NT_REP_USER); for (String ntName : test) { assertEquals("id", UserUtil.getAuthorizableId(createTree(ntName, "id"))); } }