public static String idEncode( String id ) { return Text.escapeIllegalJcrChars( id ); }
public static void main(String[] args) { System.out.println(Text.escapeIllegalJcrChars("[]")); }
@Override @NotNull public String generateNodeName(@NotNull String authorizableId) { return Text.escapeIllegalJcrChars(authorizableId); } }
@Override @Nonnull public String generateNodeName(@Nonnull String authorizableId) { return Text.escapeIllegalJcrChars(authorizableId); } }
/** * * @param fileName * @param useMultiByte * @return */ public static String fileNameEncode( String fileName, boolean useMultiByte ) { if ( useMultiByte ) { return Text.escapeIllegalJcrChars( ISO9075.encode( fileName ) ); } else { return Text.escapeIllegalJcrChars( fileName ); } }
AcEntry(@NotNull NodeState node, @NotNull String accessControlledPath, int index, boolean isAllow, @NotNull PrivilegeBits privilegeBits, @NotNull Set<Restriction> restrictions) { this.accessControlledPath = accessControlledPath; this.index = index; this.principalName = Text.escapeIllegalJcrChars(node.getString(REP_PRINCIPAL_NAME)); this.privilegeBits = privilegeBits; this.isAllow = isAllow; this.restrictions = restrictions; }
AcEntry(@NotNull NodeState node, @NotNull String accessControlledPath, int index, boolean isAllow, @NotNull PrivilegeBits privilegeBits, @NotNull Set<Restriction> restrictions) { this.accessControlledPath = accessControlledPath; this.index = index; this.principalName = Text.escapeIllegalJcrChars(node.getString(REP_PRINCIPAL_NAME)); this.privilegeBits = privilegeBits; this.isAllow = isAllow; this.restrictions = restrictions; }
private AcEntry(@Nonnull NodeState node, @Nonnull String accessControlledPath, int index, boolean isAllow, @Nonnull PrivilegeBits privilegeBits, @Nonnull Set<Restriction> restrictions) { this.accessControlledPath = accessControlledPath; this.index = index; this.principalName = Text.escapeIllegalJcrChars(node.getString(REP_PRINCIPAL_NAME)); this.privilegeBits = privilegeBits; this.isAllow = isAllow; this.restrictions = restrictions; }
@NotNull public static Tree getPrincipalRoot(@NotNull Tree permissionsTree, @NotNull String principalName) { return permissionsTree.getChild(Text.escapeIllegalJcrChars(principalName)); }
@NotNull public static Tree getPrincipalRoot(@NotNull Tree permissionsTree, @NotNull String principalName) { return permissionsTree.getChild(Text.escapeIllegalJcrChars(principalName)); }
protected String toSafeName(String key) { return ISO9075.encode(Text.escapeIllegalJcrChars(key)); }
protected String toSafeName(String key) { String name = ISO9075.encode(Text.escapeIllegalJcrChars(key)); return name; }
protected String toSafeName(String key) { String name = ISO9075.encode(Text.escapeIllegalJcrChars(key)); return name; }
@Nonnull public static Tree getPrincipalRoot(@Nonnull Tree permissionsTree, @Nonnull String principalName) { return permissionsTree.getChild(Text.escapeIllegalJcrChars(principalName)); }
protected String toSafeName(String key) { return ISO9075.encode(Text.escapeIllegalJcrChars(key)); }
/** * * @param principal the principal * @return the path * @throws RepositoryException if an error occurs */ String getPathToAcNode(Principal principal) throws RepositoryException { StringBuffer princPath = new StringBuffer(acRootPath); if (principal instanceof ItemBasedPrincipal) { princPath.append(((ItemBasedPrincipal) principal).getPath()); } else { princPath.append("/"); princPath.append(Text.escapeIllegalJcrChars(principal.getName())); } return princPath.toString(); }
/** * * @param principal the principal * @return the path * @throws RepositoryException if an error occurs */ String getPathToAcNode(Principal principal) throws RepositoryException { StringBuffer princPath = new StringBuffer(acRootPath); if (principal instanceof ItemBasedPrincipal) { princPath.append(((ItemBasedPrincipal) principal).getPath()); } else { princPath.append("/"); princPath.append(Text.escapeIllegalJcrChars(principal.getName())); } return princPath.toString(); }
/** * Makes the intermediate path of an DN by splitting along the RDNs * @param dn the dn of the identity * @return the intermediate path or {@code null} if disabled by config */ private static String createDNPath(Dn dn) { StringBuilder path = new StringBuilder(); for (Rdn rnd: dn.getRdns()) { if (path.length() > 0) { path.append('/'); } path.append(Text.escapeIllegalJcrChars(rnd.toString())); } return path.toString(); }
@Test public void testIllegalChars() throws Exception { UserProvider userProvider = createUserProvider(); Map<String, String> m = new HashMap<String, String>(); m.put("z[x]", "/z/" + Text.escapeIllegalJcrChars("z[") + '/' + Text.escapeIllegalJcrChars("z[x]")); m.put("z*x", "/z/" + Text.escapeIllegalJcrChars("z*") + '/' + Text.escapeIllegalJcrChars("z*x")); m.put("z/x", "/z/" + Text.escapeIllegalJcrChars("z/") + '/' + Text.escapeIllegalJcrChars("z/x")); m.put("%\r|", '/' +Text.escapeIllegalJcrChars("%")+ '/' + Text.escapeIllegalJcrChars("%\r") + '/' + Text.escapeIllegalJcrChars("%\r|")); for (String uid : m.keySet()) { Tree user = userProvider.createUser(uid, null); root.commit(); assertEquals(defaultUserPath + m.get(uid), user.getPath()); assertEquals(uid, UserUtil.getAuthorizableId(user)); Tree ath = userProvider.getAuthorizable(uid); assertNotNull("Tree with id " + uid + " must exist.", ath); } }
@Test public void testDefault() { String[] hints = new String[] {"abc", "ABC", "[abc]", "abc[]", "a/b/c", "a,b,*","\\'\".;:abc", "{abc}", "a:bc"}; for (String hint : hints) { assertEquals(Text.escapeIllegalJcrChars(hint), AuthorizableNodeName.DEFAULT.generateNodeName(hint)); } } }