sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1768509 - in /sling/trunk/bundles/extensions/repoinit/parser/src: main/java/org/apache/sling/repoinit/parser/operations/ main/javacc/ test/java/org/apache/sling/repoinit/parser/test/ test/resources/testcases/
Date Mon, 07 Nov 2016 13:41:01 GMT
Author: bdelacretaz
Date: Mon Nov  7 13:41:00 2016
New Revision: 1768509

URL: http://svn.apache.org/viewvc?rev=1768509&view=rev
Log:
SLING-6219 - reponit grammar support for create/delete user

Added:
    sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/CreateUser.java
      - copied, changed from r1768500, sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/CreateServiceUser.java
    sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/DeleteUser.java
      - copied, changed from r1768500, sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/CreateServiceUser.java
    sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-60-output.txt
      - copied, changed from r1768500, sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-50.txt
    sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-60.txt
      - copied, changed from r1768500, sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-50.txt
Modified:
    sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/OperationVisitor.java
    sling/trunk/bundles/extensions/repoinit/parser/src/main/javacc/RepoInitGrammar.jjt
    sling/trunk/bundles/extensions/repoinit/parser/src/test/java/org/apache/sling/repoinit/parser/test/OperationToStringVisitor.java
    sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-99-output.txt
    sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-99.txt

Copied: sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/CreateUser.java
(from r1768500, sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/CreateServiceUser.java)
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/CreateUser.java?p2=sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/CreateUser.java&p1=sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/CreateServiceUser.java&r1=1768500&r2=1768509&rev=1768509&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/CreateServiceUser.java
(original)
+++ sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/CreateUser.java
Mon Nov  7 13:41:00 2016
@@ -17,13 +17,37 @@
 
 package org.apache.sling.repoinit.parser.operations;
 
-public class CreateServiceUser extends ServiceUserOperation {
-    public CreateServiceUser(String username) {
-        super(username);
+public class CreateUser extends Operation {
+    private final String username;
+    private final String passwordEncoding;
+    private final String password;
+
+    /** Operation that creates a user.
+     * @param username the name of the user to create
+     * @param passwordEncoding optional encoding for the supplied password
+     * @param password optional password
+     */
+    public CreateUser(String username, String passwordEncoding, String password) {
+        this.username = username;
+        this.passwordEncoding = passwordEncoding;
+        this.password = password;
     }
 
     @Override
     public void accept(OperationVisitor v) {
-        v.visitCreateServiceUser(this);
+        v.visitCreateUser(this);
+    }
+
+    @Override
+    protected String getParametersDescription() {
+        final StringBuilder sb = new StringBuilder(username);
+        if(password != null) {
+            if(passwordEncoding == null) {
+                sb.append(" (with password)");
+            } else {
+                sb.append(" (with encoded password)");
+            }
+        }
+        return sb.toString();
     }
 }

Copied: sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/DeleteUser.java
(from r1768500, sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/CreateServiceUser.java)
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/DeleteUser.java?p2=sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/DeleteUser.java&p1=sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/CreateServiceUser.java&r1=1768500&r2=1768509&rev=1768509&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/CreateServiceUser.java
(original)
+++ sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/DeleteUser.java
Mon Nov  7 13:41:00 2016
@@ -17,13 +17,23 @@
 
 package org.apache.sling.repoinit.parser.operations;
 
-public class CreateServiceUser extends ServiceUserOperation {
-    public CreateServiceUser(String username) {
-        super(username);
+public class DeleteUser extends Operation {
+    private final String username;
+
+    /** Operation that deletes a user.
+     * @param username the name of the user to delete
+     */
+    public DeleteUser(String username) {
+        this.username = username;
     }
 
     @Override
     public void accept(OperationVisitor v) {
-        v.visitCreateServiceUser(this);
+        v.visitDeleteUser(this);
+    }
+
+    @Override
+    protected String getParametersDescription() {
+        return username;
     }
 }

Modified: sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/OperationVisitor.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/OperationVisitor.java?rev=1768509&r1=1768508&r2=1768509&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/OperationVisitor.java
(original)
+++ sling/trunk/bundles/extensions/repoinit/parser/src/main/java/org/apache/sling/repoinit/parser/operations/OperationVisitor.java
Mon Nov  7 13:41:00 2016
@@ -18,6 +18,8 @@
 package org.apache.sling.repoinit.parser.operations;
 
 public interface OperationVisitor {
+    void visitCreateUser(CreateUser u);
+    void visitDeleteUser(DeleteUser u);
     void visitCreateServiceUser(CreateServiceUser s);
     void visitDeleteServiceUser(DeleteServiceUser s);
     void visitSetAclPrincipal(SetAclPrincipals s);

Modified: sling/trunk/bundles/extensions/repoinit/parser/src/main/javacc/RepoInitGrammar.jjt
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/repoinit/parser/src/main/javacc/RepoInitGrammar.jjt?rev=1768509&r1=1768508&r2=1768509&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/repoinit/parser/src/main/javacc/RepoInitGrammar.jjt (original)
+++ sling/trunk/bundles/extensions/repoinit/parser/src/main/javacc/RepoInitGrammar.jjt Mon
Nov  7 13:41:00 2016
@@ -69,9 +69,13 @@ TOKEN:
 |   < NODETYPES: "nodetypes" >
 |   < REGISTER: "register" >
 |   < NAMESPACE: "namespace" >
+|   < WITH: "with" >
+|   < PASSWORD: "password" >
 |   < START_TEXTBLOCK: "<<===" > : TEXTBLOCK
 |   < LPAREN: "(" >
 |   < RPAREN: ")" >
+|   < LCURLY: "{" >
+|   < RCURLY: "}" >
 |   < COMMA: "," >
 |   < STAR: "*" >
 
@@ -105,6 +109,8 @@ List<Operation> parse() :
         | createPathStatement(result)
         | registerNamespaceStatement(result)
         | registerNodetypesStatement(result)
+        | createUserStatement(result)
+        | deleteUserStatement(result)
         | blankLine() 
     ) * 
     <EOF>
@@ -333,4 +339,36 @@ void registerNodetypesStatement(List<Ope
     {
         result.add(new RegisterNodetypes(b.toString()));
     }
+}
+
+void createUserStatement(List<Operation> result) :
+{
+    Token user = null;
+    Token encoding = null;
+    Token password = null;
+}
+{
+    <CREATE> <USER> 
+    ( user = <STRING> )
+    ( <WITH> <PASSWORD> ( <LCURLY> encoding = <STRING> <RCURLY>
)? password = <STRING> )?
+    
+    {
+        result.add(new CreateUser(user.image, 
+            (encoding == null ? null : encoding.image), 
+            (password == null ? null : password.image)
+        ));
+    }
+}
+
+void deleteUserStatement(List<Operation> result) :
+{
+    Token user = null;
+}
+{
+    <DELETE> <USER> 
+    ( user = <STRING> )
+
+    {
+        result.add(new DeleteUser(user.image));
+    }
 }
\ No newline at end of file

Modified: sling/trunk/bundles/extensions/repoinit/parser/src/test/java/org/apache/sling/repoinit/parser/test/OperationToStringVisitor.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/repoinit/parser/src/test/java/org/apache/sling/repoinit/parser/test/OperationToStringVisitor.java?rev=1768509&r1=1768508&r2=1768509&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/repoinit/parser/src/test/java/org/apache/sling/repoinit/parser/test/OperationToStringVisitor.java
(original)
+++ sling/trunk/bundles/extensions/repoinit/parser/src/test/java/org/apache/sling/repoinit/parser/test/OperationToStringVisitor.java
Mon Nov  7 13:41:00 2016
@@ -23,7 +23,9 @@ import java.util.Collection;
 import org.apache.sling.repoinit.parser.operations.AclLine;
 import org.apache.sling.repoinit.parser.operations.CreatePath;
 import org.apache.sling.repoinit.parser.operations.CreateServiceUser;
+import org.apache.sling.repoinit.parser.operations.CreateUser;
 import org.apache.sling.repoinit.parser.operations.DeleteServiceUser;
+import org.apache.sling.repoinit.parser.operations.DeleteUser;
 import org.apache.sling.repoinit.parser.operations.RegisterNodetypes;
 import org.apache.sling.repoinit.parser.operations.OperationVisitor;
 import org.apache.sling.repoinit.parser.operations.RegisterNamespace;
@@ -52,6 +54,16 @@ class OperationToStringVisitor implement
     }
 
     @Override
+    public void visitCreateUser(CreateUser u) {
+        out.println(u.toString());
+    }
+
+    @Override
+    public void visitDeleteUser(DeleteUser u) {
+        out.println(u.toString());
+    }
+
+    @Override
     public void visitSetAclPrincipal(SetAclPrincipals s) {
         out.print(s.getClass().getSimpleName());
         out.print(" for ");

Copied: sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-60-output.txt
(from r1768500, sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-50.txt)
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-60-output.txt?p2=sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-60-output.txt&p1=sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-50.txt&r1=1768500&r2=1768509&rev=1768509&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-50.txt
(original)
+++ sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-60-output.txt
Mon Nov  7 13:41:00 2016
@@ -1,37 +1,6 @@
-# Test parsing embedded CNDs
-
-register nodetypes
-<<===
-    <slingevent='http://sling.apache.org/jcr/event/1.0'>
-    <nt='http://www.jcp.org/jcr/nt/1.0'>
-    <mix='http://www.jcp.org/jcr/mix/1.0'>
-    
-    [slingevent:Event] > nt:unstructured, nt:hierarchyNode
-      - slingevent:topic (string)
-      - slingevent:application (string)
-      - slingevent:created (date)
-      - slingevent:properties (binary)
-      
-    [slingevent:Job] > slingevent:Event, mix:lockable
-      - slingevent:processor (string)
-      - slingevent:id (string)
-      - slingevent:finished (date)
-     
-    [slingevent:TimedEvent] > slingevent:Event, mix:lockable
-      - slingevent:processor (string)
-      - slingevent:id (string)
-      - slingevent:expression (string)
-      - slingevent:date (date)
-      - slingevent:period (long)
-===>>
-
-register nodetypes
-<<===
-Just one line, not indented
-===>>
-
-register nodetypes
-<<===
-<< Using line prefixes
-<< to avoid conflicts with Sling provisioning model parser
-===>>
+DeleteUser userB
+CreateUser userB
+CreateUser userC (with password)
+CreateUser userD (with encoded password)
+CreateUser userE (with encoded password)
+CreateUser one_with-more-chars.ok:/123456 (with encoded password)
\ No newline at end of file

Copied: sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-60.txt
(from r1768500, sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-50.txt)
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-60.txt?p2=sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-60.txt&p1=sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-50.txt&r1=1768500&r2=1768509&rev=1768509&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-50.txt
(original)
+++ sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-60.txt
Mon Nov  7 13:41:00 2016
@@ -1,37 +1,11 @@
-# Test parsing embedded CNDs
+# Test create/delete user statements
 
-register nodetypes
-<<===
-    <slingevent='http://sling.apache.org/jcr/event/1.0'>
-    <nt='http://www.jcp.org/jcr/nt/1.0'>
-    <mix='http://www.jcp.org/jcr/mix/1.0'>
-    
-    [slingevent:Event] > nt:unstructured, nt:hierarchyNode
-      - slingevent:topic (string)
-      - slingevent:application (string)
-      - slingevent:created (date)
-      - slingevent:properties (binary)
-      
-    [slingevent:Job] > slingevent:Event, mix:lockable
-      - slingevent:processor (string)
-      - slingevent:id (string)
-      - slingevent:finished (date)
-     
-    [slingevent:TimedEvent] > slingevent:Event, mix:lockable
-      - slingevent:processor (string)
-      - slingevent:id (string)
-      - slingevent:expression (string)
-      - slingevent:date (date)
-      - slingevent:period (long)
-===>>
+delete user userB
+create user userB
 
-register nodetypes
-<<===
-Just one line, not indented
-===>>
+create user userC with password some_password
+create user userD with password {SHA-256}dc460da4ad72c482231e28e688e01f2778a88ce31a08826899d54ef7183998b5
 
-register nodetypes
-<<===
-<< Using line prefixes
-<< to avoid conflicts with Sling provisioning model parser
-===>>
+create user userE with password {someEncoding} afdgwdsdf
+
+create user one_with-more-chars.ok:/123456 with password {encoding_with.ok-:/12345} pw-with.ok-:/13456
\ No newline at end of file

Modified: sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-99-output.txt
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-99-output.txt?rev=1768509&r1=1768508&r2=1768509&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-99-output.txt
(original)
+++ sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-99-output.txt
Mon Nov  7 13:41:00 2016
@@ -23,4 +23,6 @@ RegisterNodetypes:
  [slingevent:Event] > nt:unstructured, nt:hierarchyNode
       - slingevent:topic (string)
       - slingevent:properties (binary)
+CreateUser userE (with encoded password)
+CreateUser one_with-more-chars.ok:/123456 (with encoded password)
 CreateServiceUser the-last-one
\ No newline at end of file

Modified: sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-99.txt
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-99.txt?rev=1768509&r1=1768508&r2=1768509&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-99.txt
(original)
+++ sling/trunk/bundles/extensions/repoinit/parser/src/test/resources/testcases/test-99.txt
Mon Nov  7 13:41:00 2016
@@ -42,4 +42,6 @@ register nodetypes
       - slingevent:properties (binary)
 ===>>
 
+create user userE with password {someEncoding} afdgwdsdf
+create user one_with-more-chars.ok:/123456 with password {encoding_with.ok-:/12345} pw-with.ok-:/13456
 create service user the-last-one
\ No newline at end of file



Mime
View raw message