You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2009/02/27 10:19:42 UTC
svn commit: r748454 [1/2] - in /incubator/sling/trunk: ./
bundles/jcr/jackrabbit-usermanager/ bundles/jcr/jackrabbit-usermanager/src/
bundles/jcr/jackrabbit-usermanager/src/main/
bundles/jcr/jackrabbit-usermanager/src/main/java/ bundles/jcr/jackrabbit-...
Author: fmeschbe
Date: Fri Feb 27 09:19:41 2009
New Revision: 748454
URL: http://svn.apache.org/viewvc?rev=748454&view=rev
Log:
SLING-875 add new jackrabbit-usermanager module (thanks Eric for providing)
Added:
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/ (with props)
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/LICENSE
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/NOTICE
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/README.txt (with props)
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/pom.xml (with props)
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/AbstractAuthorizableOperation.java (with props)
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/ChangePasswordOperation.java (with props)
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/CreateGroupOperation.java (with props)
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/CreateUserOperation.java (with props)
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/DeleteAuthorizableOperation.java (with props)
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/UpdateAuthorizableOperation.java (with props)
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/impl/
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/impl/DateParser.java (with props)
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/impl/RequestProperty.java (with props)
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/resource/
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/resource/AuthorizableResource.java (with props)
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/resource/AuthorizableResourceProvider.java (with props)
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/resource/AuthorizableValueMap.java (with props)
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/resources/
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/resources/META-INF/
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/resources/META-INF/LICENSE
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/resources/META-INF/NOTICE
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/resources/OSGI-INF/
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/resources/OSGI-INF/metatype/
incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/resources/OSGI-INF/metatype/metatype.properties (with props)
Modified:
incubator/sling/trunk/pom.xml
Propchange: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Feb 27 09:19:41 2009
@@ -0,0 +1,4 @@
+.classpath
+.project
+.settings
+target
Added: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/LICENSE
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/LICENSE?rev=748454&view=auto
==============================================================================
--- incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/LICENSE (added)
+++ incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/LICENSE Fri Feb 27 09:19:41 2009
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
Added: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/NOTICE
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/NOTICE?rev=748454&view=auto
==============================================================================
--- incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/NOTICE (added)
+++ incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/NOTICE Fri Feb 27 09:19:41 2009
@@ -0,0 +1,5 @@
+Apache Sling Jackrabbit UserManager Support
+Copyright 2008-2009 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
Added: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/README.txt
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/README.txt?rev=748454&view=auto
==============================================================================
--- incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/README.txt (added)
+++ incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/README.txt Fri Feb 27 09:19:41 2009
@@ -0,0 +1,37 @@
+Apache Sling Jackrabbit UserManager Support
+
+Provides ResourceProvider and SlingPostOperations for the Jackrabbit UserManager.
+
+Disclaimer
+==========
+Apache Sling is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Jackrabbit PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other
+successful ASF projects. While incubation status is not necessarily a reflection of
+the completeness or stability of the code, it does indicate that the project has yet
+to be fully endorsed by the ASF.
+
+Getting Started
+===============
+
+This component uses a Maven 2 (http://maven.apache.org/) build
+environment. It requires a Java 5 JDK (or higher) and Maven (http://maven.apache.org/)
+2.0.7 or later. We recommend to use the latest Maven version.
+
+If you have Maven 2 installed, you can compile and
+package the jar using the following command:
+
+ mvn package
+
+See the Maven 2 documentation for other build features.
+
+The latest source code for this component is available in the
+Subversion (http://subversion.tigris.org/) source repository of
+the Apache Software Foundation. If you have Subversion installed,
+you can checkout the latest source using the following command:
+
+ svn checkout http://svn.apache.org/repos/asf/incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager
+
+See the Subversion documentation for other source control features.
+
Propchange: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/README.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/pom.xml?rev=748454&view=auto
==============================================================================
--- incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/pom.xml (added)
+++ incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/pom.xml Fri Feb 27 09:19:41 2009
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>5-incubator-SNAPSHOT</version>
+ <relativePath>../../../parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>org.apache.sling.jcr.jackrabbit.usermanager</artifactId>
+ <packaging>bundle</packaging>
+ <version>2.0.0-incubator-SNAPSHOT</version>
+ <name>Apache Sling Jackrabbit UserManager Support</name>
+ <description>
+ Provides ResourceProvider and SlingPostOperations for the Jackrabbit
+ UserManager.
+ </description>
+
+ <scm>
+ <connection>
+ scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager
+ </connection>
+ <developerConnection>
+ scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager
+ </developerConnection>
+ <url>
+ http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager
+ </url>
+ </scm>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Private-Package>
+ org.apache.sling.jackrabbit.usermanager.*
+ </Private-Package>
+ <Sling-Initial-Content></Sling-Initial-Content>
+ <Sling-Nodetypes></Sling-Nodetypes>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <!-- No javadocs -->
+ <excludePackageNames>
+ org.apache.sling.jackrabbit.usermanager.post.impl
+ </excludePackageNames>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.api</artifactId>
+ <version>2.0.3-incubator-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.servlets.post</artifactId>
+ <version>2.0.3-incubator-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.jackrabbit.api</artifactId>
+ <version>2.0.3-incubator-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.base</artifactId>
+ <version>2.0.3-incubator-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-api</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Propchange: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/AbstractAuthorizableOperation.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/AbstractAuthorizableOperation.java?rev=748454&view=auto
==============================================================================
--- incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/AbstractAuthorizableOperation.java (added)
+++ incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/AbstractAuthorizableOperation.java Fri Feb 27 09:19:41 2009
@@ -0,0 +1,634 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.jackrabbit.usermanager.post;
+
+import java.io.UnsupportedEncodingException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Calendar;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.servlet.ServletException;
+
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.jackrabbit.api.security.user.Group;
+import org.apache.jackrabbit.util.Text;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.request.RequestParameter;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.servlets.HtmlResponse;
+import org.apache.sling.commons.osgi.OsgiUtil;
+import org.apache.sling.jackrabbit.usermanager.post.impl.DateParser;
+import org.apache.sling.jackrabbit.usermanager.post.impl.RequestProperty;
+import org.apache.sling.jackrabbit.usermanager.resource.AuthorizableResourceProvider;
+import org.apache.sling.servlets.post.AbstractSlingPostOperation;
+import org.apache.sling.servlets.post.Modification;
+import org.apache.sling.servlets.post.SlingPostConstants;
+import org.osgi.service.component.ComponentContext;
+
+
+/**
+ * Base class for operations that do work on authorizable resources
+ */
+public abstract class AbstractAuthorizableOperation extends AbstractSlingPostOperation {
+
+ /**
+ * @scr.property values.0="EEE MMM dd yyyy HH:mm:ss 'GMT'Z"
+ * values.1="yyyy-MM-dd'T'HH:mm:ss.SSSZ"
+ * values.2="yyyy-MM-dd'T'HH:mm:ss" values.3="yyyy-MM-dd"
+ * values.4="dd.MM.yyyy HH:mm:ss" values.5="dd.MM.yyyy"
+ */
+ private static final String PROP_DATE_FORMAT = "servlet.post.dateFormats";
+
+ private DateParser dateParser;
+
+
+ /**
+ * To be used for the encryption. E.g. for passwords in
+ * {@link javax.jcr.SimpleCredentials#getPassword()} SimpleCredentials}
+ * @scr.property valueRef="DEFAULT_PASSWORD_DIGEST_ALGORITHM"
+ */
+ private static final String PROP_PASSWORD_DIGEST_ALGORITHM = "password.digest.algorithm";
+ private static final String DEFAULT_PASSWORD_DIGEST_ALGORITHM = "sha1";
+ private String passwordDigestAlgoritm = null;
+
+ // ---------- SCR Integration ----------------------------------------------
+
+ protected void activate(ComponentContext context) {
+ Dictionary<?, ?> props = context.getProperties();
+
+ dateParser = new DateParser();
+ String[] dateFormats = OsgiUtil.toStringArray(props.get(PROP_DATE_FORMAT));
+ for (String dateFormat : dateFormats) {
+ dateParser.register(dateFormat);
+ }
+ Object propValue = props.get(PROP_PASSWORD_DIGEST_ALGORITHM);
+ if (propValue instanceof String) {
+ passwordDigestAlgoritm = (String)propValue;
+ } else {
+ passwordDigestAlgoritm = DEFAULT_PASSWORD_DIGEST_ALGORITHM;
+ }
+ }
+
+ protected void deactivate(ComponentContext context) {
+ dateParser = null;
+ passwordDigestAlgoritm = null;
+ }
+
+ protected String digestPassword(String pwd) throws IllegalArgumentException {
+ try {
+ StringBuffer password = new StringBuffer();
+ password.append("{").append(passwordDigestAlgoritm).append("}");
+ password.append(Text.digest(passwordDigestAlgoritm, pwd.getBytes("UTF-8")));
+ return password.toString();
+ } catch (NoSuchAlgorithmException e) {
+ throw new IllegalArgumentException(e.toString());
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalArgumentException(e.toString());
+ }
+ }
+
+
+ /**
+ * Update the group membership based on the ":member" request
+ * parameters. If the ":member" value ends with @Delete it is removed
+ * from the group membership, otherwise it is added to the group membership.
+ *
+ * @param request
+ * @param authorizable
+ * @throws RepositoryException
+ */
+ protected void updateGroupMembership(SlingHttpServletRequest request,
+ Authorizable authorizable, List<Modification> changes) throws RepositoryException {
+ if (authorizable.isGroup()) {
+ Group group = ((Group)authorizable);
+ String groupPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_GROUP_PREFIX + group.getID();
+
+ ResourceResolver resolver = request.getResourceResolver();
+ Resource baseResource = request.getResource();
+ boolean changed = false;
+
+ //first remove any members posted as ":member@Delete"
+ String[] membersToDelete = request.getParameterValues(SlingPostConstants.RP_PREFIX + "member" + SlingPostConstants.SUFFIX_DELETE);
+ if (membersToDelete != null) {
+ for (String member : membersToDelete) {
+ Resource res = resolver.getResource(baseResource, member);
+ if (res != null) {
+ Authorizable memberAuthorizable = res.adaptTo(Authorizable.class);
+ if (memberAuthorizable != null) {
+ group.removeMember(memberAuthorizable);
+ changed = true;
+ }
+ }
+
+ }
+ }
+
+ //second add any members posted as ":member"
+ String[] membersToAdd = request.getParameterValues(SlingPostConstants.RP_PREFIX + "member");
+ if (membersToAdd != null) {
+ for (String member : membersToAdd) {
+ Resource res = resolver.getResource(baseResource, member);
+ if (res != null) {
+ Authorizable memberAuthorizable = res.adaptTo(Authorizable.class);
+ if (memberAuthorizable != null) {
+ group.addMember(memberAuthorizable);
+ changed = true;
+ }
+ }
+ }
+ }
+
+ if (changed) {
+ //add an entry to the changes list to record the membership change
+ changes.add(Modification.onModified(groupPath + "/members"));
+ }
+ }
+ }
+
+
+
+ // ------ The methods below are based on the private methods from the ModifyOperation class -----
+
+ /**
+ * Collects the properties that form the content to be written back to the
+ * repository.
+ *
+ * NOTE: In the returned map, the key is the property name not a path.
+ *
+ * @throws RepositoryException if a repository error occurs
+ * @throws ServletException if an internal error occurs
+ */
+ protected Map<String, RequestProperty> collectContent(
+ SlingHttpServletRequest request, HtmlResponse response) {
+
+ boolean requireItemPrefix = requireItemPathPrefix(request);
+
+ // walk the request parameters and collect the properties
+ Map<String, RequestProperty> reqProperties = new HashMap<String, RequestProperty>();
+ for (Map.Entry<String, RequestParameter[]> e : request.getRequestParameterMap().entrySet()) {
+ final String paramName = e.getKey();
+
+ // do not store parameters with names starting with sling:post
+ if (paramName.startsWith(SlingPostConstants.RP_PREFIX)) {
+ continue;
+ }
+ // SLING-298: skip form encoding parameter
+ if (paramName.equals("_charset_")) {
+ continue;
+ }
+ // skip parameters that do not start with the save prefix
+ if (requireItemPrefix && !hasItemPathPrefix(paramName)) {
+ continue;
+ }
+
+ // ensure the paramName is an absolute property name
+ String propPath;
+ if (paramName.startsWith("./")) {
+ propPath = paramName.substring(2);
+ } else {
+ propPath = paramName;
+ }
+ if (propPath.indexOf('/') != -1) {
+ //only one path segment is valid here, so this paramter can't be used.
+ continue; //skip it.
+ }
+
+ // @TypeHint example
+ // <input type="text" name="./age" />
+ // <input type="hidden" name="./age@TypeHint" value="long" />
+ // causes the setProperty using the 'long' property type
+ if (propPath.endsWith(SlingPostConstants.TYPE_HINT_SUFFIX)) {
+ RequestProperty prop = getOrCreateRequestProperty(
+ reqProperties, propPath,
+ SlingPostConstants.TYPE_HINT_SUFFIX);
+
+ final RequestParameter[] rp = e.getValue();
+ if (rp.length > 0) {
+ prop.setTypeHintValue(rp[0].getString());
+ }
+
+ continue;
+ }
+
+ // @DefaultValue
+ if (propPath.endsWith(SlingPostConstants.DEFAULT_VALUE_SUFFIX)) {
+ RequestProperty prop = getOrCreateRequestProperty(
+ reqProperties, propPath,
+ SlingPostConstants.DEFAULT_VALUE_SUFFIX);
+
+ prop.setDefaultValues(e.getValue());
+
+ continue;
+ }
+
+ // SLING-130: VALUE_FROM_SUFFIX means take the value of this
+ // property from a different field
+ // @ValueFrom example:
+ // <input name="./Text@ValueFrom" type="hidden" value="fulltext" />
+ // causes the JCR Text property to be set to the value of the
+ // fulltext form field.
+ if (propPath.endsWith(SlingPostConstants.VALUE_FROM_SUFFIX)) {
+ RequestProperty prop = getOrCreateRequestProperty(
+ reqProperties, propPath,
+ SlingPostConstants.VALUE_FROM_SUFFIX);
+
+ // @ValueFrom params must have exactly one value, else ignored
+ if (e.getValue().length == 1) {
+ String refName = e.getValue()[0].getString();
+ RequestParameter[] refValues = request.getRequestParameters(refName);
+ if (refValues != null) {
+ prop.setValues(refValues);
+ }
+ }
+
+ continue;
+ }
+
+ // SLING-458: Allow Removal of properties prior to update
+ // @Delete example:
+ // <input name="./Text@Delete" type="hidden" />
+ // causes the JCR Text property to be deleted before update
+ if (propPath.endsWith(SlingPostConstants.SUFFIX_DELETE)) {
+ RequestProperty prop = getOrCreateRequestProperty(
+ reqProperties, propPath, SlingPostConstants.SUFFIX_DELETE);
+
+ prop.setDelete(true);
+
+ continue;
+ }
+
+ // SLING-455: @MoveFrom means moving content to another location
+ // @MoveFrom example:
+ // <input name="./Text@MoveFrom" type="hidden" value="/tmp/path" />
+ // causes the JCR Text property to be set by moving the /tmp/path
+ // property to Text.
+ if (propPath.endsWith(SlingPostConstants.SUFFIX_MOVE_FROM)) {
+ //don't support @MoveFrom here
+ continue;
+ }
+
+ // SLING-455: @CopyFrom means moving content to another location
+ // @CopyFrom example:
+ // <input name="./Text@CopyFrom" type="hidden" value="/tmp/path" />
+ // causes the JCR Text property to be set by copying the /tmp/path
+ // property to Text.
+ if (propPath.endsWith(SlingPostConstants.SUFFIX_COPY_FROM)) {
+ //don't support @CopyFrom here
+ continue;
+ }
+
+ // plain property, create from values
+ RequestProperty prop = getOrCreateRequestProperty(reqProperties,
+ propPath, null);
+ prop.setValues(e.getValue());
+ }
+
+ return reqProperties;
+ }
+
+
+ /**
+ * Returns the request property for the given property path. If such a
+ * request property does not exist yet it is created and stored in the
+ * <code>props</code>.
+ *
+ * @param props The map of already seen request properties.
+ * @param paramName The absolute path of the property including the
+ * <code>suffix</code> to be looked up.
+ * @param suffix The (optional) suffix to remove from the
+ * <code>paramName</code> before looking it up.
+ * @return The {@link RequestProperty} for the <code>paramName</code>.
+ */
+ private RequestProperty getOrCreateRequestProperty(
+ Map<String, RequestProperty> props, String paramName, String suffix) {
+ if (suffix != null && paramName.endsWith(suffix)) {
+ paramName = paramName.substring(0, paramName.length()
+ - suffix.length());
+ }
+
+ RequestProperty prop = props.get(paramName);
+ if (prop == null) {
+ prop = new RequestProperty(paramName);
+ props.put(paramName, prop);
+ }
+
+ return prop;
+ }
+
+
+ /**
+ * Removes all properties listed as {@link RequestProperty#isDelete()} from
+ * the authorizable.
+ *
+ * @param authorizable The <code>org.apache.jackrabbit.api.security.user.Authorizable</code>
+ * that should have properties deleted.
+ * @param reqProperties The map of request properties to check for
+ * properties to be removed.
+ * @param response The <code>HtmlResponse</code> to be updated with
+ * information on deleted properties.
+ * @throws RepositoryException Is thrown if an error occurrs checking or
+ * removing properties.
+ */
+ protected void processDeletes(Authorizable resource,
+ Map<String, RequestProperty> reqProperties,
+ List<Modification> changes) throws RepositoryException {
+
+ for (RequestProperty property : reqProperties.values()) {
+ if (property.isDelete()) {
+ if (resource.hasProperty(property.getName())) {
+ resource.removeProperty(property.getName());
+ changes.add(Modification.onDeleted(property.getPath()));
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Writes back the content
+ *
+ * @throws RepositoryException if a repository error occurs
+ * @throws ServletException if an internal error occurs
+ */
+ protected void writeContent(Session session, Authorizable authorizable,
+ Map<String, RequestProperty> reqProperties, List<Modification> changes)
+ throws RepositoryException {
+
+ for (RequestProperty prop : reqProperties.values()) {
+ if (prop.hasValues()) {
+ // skip jcr special properties
+ if (prop.getName().equals("jcr:primaryType")
+ || prop.getName().equals("jcr:mixinTypes")) {
+ continue;
+ }
+ if (authorizable.isGroup()) {
+ if (prop.getName().equals("groupId")) {
+ //skip these
+ continue;
+ }
+ } else {
+ if (prop.getName().equals("userId") ||
+ prop.getName().equals("pwd") ||
+ prop.getName().equals("pwdConfirm")) {
+ //skip these
+ continue;
+ }
+ }
+ if (prop.isFileUpload()) {
+ //don't handle files for user properties for now.
+ continue;
+ //uploadHandler.setFile(parent, prop, changes);
+ } else {
+ setPropertyAsIs(session, authorizable, prop, changes);
+ }
+ }
+ }
+ }
+
+ /**
+ * set property without processing, except for type hints
+ *
+ * @param parent the parent node
+ * @param prop the request property
+ * @throws RepositoryException if a repository error occurs.
+ */
+ private void setPropertyAsIs(Session session, Authorizable parent, RequestProperty prop, List<Modification> changes)
+ throws RepositoryException {
+
+ String parentPath;
+ if (parent.isGroup()) {
+ parentPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_GROUP_PREFIX + parent.getID();
+ } else {
+ parentPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_USER_PREFIX + parent.getID();
+ }
+
+
+ // no explicit typehint
+ int type = PropertyType.UNDEFINED;
+ if (prop.getTypeHint() != null) {
+ try {
+ type = PropertyType.valueFromName(prop.getTypeHint());
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ String[] values = prop.getStringValues();
+ if (values == null) {
+ // remove property
+ boolean removedProp = removePropertyIfExists(parent, prop.getName());
+ if (removedProp) {
+ changes.add(Modification.onDeleted(
+ parentPath + "/" + prop.getName()
+ ));
+ }
+ } else if (values.length == 0) {
+ // do not create new prop here, but clear existing
+ if (parent.hasProperty(prop.getName())) {
+ Value val = session.getValueFactory().createValue("");
+ parent.setProperty(prop.getName(), val);
+ changes.add(Modification.onModified(
+ parentPath + "/" + prop.getName()
+ ));
+ }
+ } else if (values.length == 1) {
+ boolean removedProp = removePropertyIfExists(parent, prop.getName());
+ // if the provided value is the empty string, we don't have to do anything.
+ if ( values[0].length() == 0 ) {
+ if ( removedProp ) {
+ changes.add(Modification.onDeleted(parentPath + "/" + prop.getName()));
+ }
+ } else {
+ // modify property
+ if (type == PropertyType.DATE) {
+ // try conversion
+ Calendar c = dateParser.parse(values[0]);
+ if (c != null) {
+ if ( prop.hasMultiValueTypeHint() ) {
+ final Value[] array = new Value[1];
+ array[0] = session.getValueFactory().createValue(c);
+ parent.setProperty(prop.getName(), array);
+ changes.add(Modification.onModified(
+ parentPath + "/" + prop.getName()
+ ));
+ } else {
+ Value cVal = session.getValueFactory().createValue(c);
+ parent.setProperty(prop.getName(), cVal);
+ changes.add(Modification.onModified(
+ parentPath + "/" + prop.getName()
+ ));
+ }
+ return;
+ }
+ // fall back to default behaviour
+ }
+ if ( type == PropertyType.UNDEFINED ) {
+ Value val = session.getValueFactory().createValue(values[0], PropertyType.STRING);
+ parent.setProperty(prop.getName(), val);
+ } else {
+ if ( prop.hasMultiValueTypeHint() ) {
+ final Value[] array = new Value[1];
+ array[0] = session.getValueFactory().createValue(values[0], type);
+ parent.setProperty(prop.getName(), array);
+ } else {
+ Value val = session.getValueFactory().createValue(values[0], type);
+ parent.setProperty(prop.getName(), val);
+ }
+ }
+ changes.add(Modification.onModified(parentPath + "/" + prop.getName()));
+ }
+ } else {
+ removePropertyIfExists(parent, prop.getName());
+ if (type == PropertyType.DATE) {
+ // try conversion
+ ValueFactory valFac = session.getValueFactory();
+ Value[] c = dateParser.parse(values, valFac);
+ if (c != null) {
+ parent.setProperty(prop.getName(), c);
+ changes.add(Modification.onModified(
+ parentPath + "/" + prop.getName()
+ ));
+ return;
+ }
+ // fall back to default behaviour
+ }
+
+ Value [] vals = new Value[values.length];
+ if ( type == PropertyType.UNDEFINED ) {
+ for(int i=0; i < values.length; i++) {
+ vals[i] = session.getValueFactory().createValue(values[i]);
+ }
+ } else {
+ for(int i=0; i < values.length; i++) {
+ vals[i] = session.getValueFactory().createValue(values[i], type);
+ }
+ }
+ parent.setProperty(prop.getName(), vals);
+ changes.add(Modification.onModified(parentPath + "/" + prop.getName()));
+ }
+
+ }
+
+ /**
+ * Removes the property with the given name from the parent resource if it
+ * exists.
+ *
+ * @param parent the parent resource
+ * @param name the name of the property to remove
+ * @return path of the property that was removed or <code>null</code> if
+ * it was not removed
+ * @throws RepositoryException if a repository error occurs.
+ */
+ private boolean removePropertyIfExists(Authorizable resource, String name) throws RepositoryException {
+ if (resource.getProperty(name) != null) {
+ resource.removeProperty(name);
+ return true;
+ }
+ return false;
+ }
+
+
+ /**
+ * Returns an iterator on <code>Resource</code> instances addressed in the
+ * {@link SlingPostConstants#RP_APPLY_TO} request parameter. If the request
+ * parameter is not set, <code>null</code> is returned. If the parameter
+ * is set with valid resources an empty iterator is returned. Any resources
+ * addressed in the {@link SlingPostConstants#RP_APPLY_TO} parameter is
+ * ignored.
+ *
+ * @param request The <code>SlingHttpServletRequest</code> object used to
+ * get the {@link SlingPostConstants#RP_APPLY_TO} parameter.
+ * @return The iterator of resources listed in the parameter or
+ * <code>null</code> if the parameter is not set in the request.
+ */
+ protected Iterator<Resource> getApplyToResources(
+ SlingHttpServletRequest request) {
+
+ String[] applyTo = request.getParameterValues(SlingPostConstants.RP_APPLY_TO);
+ if (applyTo == null) {
+ return null;
+ }
+
+ return new ApplyToIterator(request, applyTo);
+ }
+
+ private static class ApplyToIterator implements Iterator<Resource> {
+
+ private final ResourceResolver resolver;
+ private final Resource baseResource;
+ private final String[] paths;
+
+ private int pathIndex;
+
+ private Resource nextResource;
+
+ ApplyToIterator(SlingHttpServletRequest request, String[] paths) {
+ this.resolver = request.getResourceResolver();
+ this.baseResource = request.getResource();
+ this.paths = paths;
+ this.pathIndex = 0;
+
+ nextResource = seek();
+ }
+
+ public boolean hasNext() {
+ return nextResource != null;
+ }
+
+ public Resource next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+
+ Resource result = nextResource;
+ nextResource = seek();
+
+ return result;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ private Resource seek() {
+ while (pathIndex < paths.length) {
+ String path = paths[pathIndex];
+ pathIndex++;
+
+ Resource res = resolver.getResource(baseResource, path);
+ if (res != null) {
+ return res;
+ }
+ }
+
+ // no more elements in the array
+ return null;
+ }
+ }
+
+}
Propchange: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/AbstractAuthorizableOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/AbstractAuthorizableOperation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev Url
Added: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/ChangePasswordOperation.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/ChangePasswordOperation.java?rev=748454&view=auto
==============================================================================
--- incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/ChangePasswordOperation.java (added)
+++ incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/ChangePasswordOperation.java Fri Feb 27 09:19:41 2009
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.jackrabbit.usermanager.post;
+
+import java.util.List;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.jackrabbit.api.security.user.User;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.servlets.HtmlResponse;
+import org.apache.sling.servlets.post.Modification;
+
+/**
+ * Sling Post Operation implementation for updating the password of
+ * a user in the jackrabbit UserManager.
+ *
+ * @scr.component metatype="no" immediate="true"
+ * @scr.service interface="org.apache.sling.servlets.post.SlingPostOperation"
+ * @scr.property name="sling.post.operation" value="changePassword"
+ */
+public class ChangePasswordOperation extends AbstractAuthorizableOperation {
+
+ /* (non-Javadoc)
+ * @see org.apache.sling.servlets.post.AbstractSlingPostOperation#doRun(org.apache.sling.api.SlingHttpServletRequest, org.apache.sling.api.servlets.HtmlResponse, java.util.List)
+ */
+ @Override
+ protected void doRun(SlingHttpServletRequest request,
+ HtmlResponse response, List<Modification> changes)
+ throws RepositoryException {
+ Authorizable authorizable = null;
+ Resource resource = request.getResource();
+ if (resource != null) {
+ authorizable = resource.adaptTo(Authorizable.class);
+ }
+
+ //check that the user was located.
+ if (authorizable == null || authorizable.isGroup()) {
+ throw new RepositoryException("User to update could not be determined.");
+ }
+
+ if ("anonymous".equals(authorizable.getID())) {
+ throw new RepositoryException("Can not change the password of the anonymous user.");
+ }
+
+ Session session = request.getResourceResolver().adaptTo(Session.class);
+ if (session == null) {
+ throw new RepositoryException("JCR Session not found");
+ }
+
+ //check that the submitted parameter values have valid values.
+ String oldPwd = request.getParameter("oldPwd");
+ if (oldPwd == null || oldPwd.length() == 0) {
+ throw new RepositoryException("Old Password was not submitted");
+ }
+ String newPwd = request.getParameter("newPwd");
+ if (newPwd == null || newPwd.length() == 0) {
+ throw new RepositoryException("New Password was not submitted");
+ }
+ String newPwdConfirm = request.getParameter("newPwdConfirm");
+ if (!newPwd.equals(newPwdConfirm)) {
+ throw new RepositoryException("New Password does not match the confirmation password");
+ }
+
+ try {
+ String digestedOldPwd = digestPassword(oldPwd);
+ Value[] pwdProperty = ((User)authorizable).getProperty("rep:password");
+ if (pwdProperty != null && pwdProperty.length > 0) {
+ String repPasswordValue = pwdProperty[0].getString();
+ if (!digestedOldPwd.equals(repPasswordValue)) {
+ //submitted oldPwd value is not correct.
+ throw new RepositoryException("Old Password does not match");
+ }
+ }
+
+ ((User)authorizable).changePassword(digestPassword(newPwd));
+
+ changes.add(Modification.onModified(
+ resource.getPath() + "/rep:password"
+ ));
+ } catch (RepositoryException re) {
+ throw new RepositoryException("Failed to change user password.", re);
+ }
+ }
+}
Propchange: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/ChangePasswordOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/ChangePasswordOperation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev Url
Added: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/CreateGroupOperation.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/CreateGroupOperation.java?rev=748454&view=auto
==============================================================================
--- incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/CreateGroupOperation.java (added)
+++ incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/CreateGroupOperation.java Fri Feb 27 09:19:41 2009
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.jackrabbit.usermanager.post;
+
+import java.security.Principal;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.jackrabbit.api.security.user.Group;
+import org.apache.jackrabbit.api.security.user.UserManager;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.servlets.HtmlResponse;
+import org.apache.sling.jackrabbit.usermanager.post.impl.RequestProperty;
+import org.apache.sling.jackrabbit.usermanager.resource.AuthorizableResourceProvider;
+import org.apache.sling.jcr.base.util.AccessControlUtil;
+import org.apache.sling.servlets.post.Modification;
+import org.apache.sling.servlets.post.SlingPostConstants;
+
+/**
+ * Sling Post Operation implementation for creating a group in the jackrabbit
+ * UserManager.
+ *
+ * @scr.component metatype="no" immediate="true"
+ * @scr.service interface="org.apache.sling.servlets.post.SlingPostOperation"
+ * @scr.property name="sling.post.operation" value="createGroup"
+ */
+public class CreateGroupOperation extends AbstractAuthorizableOperation {
+
+ /* (non-Javadoc)
+ * @see org.apache.sling.servlets.post.AbstractSlingPostOperation#doRun(org.apache.sling.api.SlingHttpServletRequest, org.apache.sling.api.servlets.HtmlResponse, java.util.List)
+ */
+ @Override
+ protected void doRun(SlingHttpServletRequest request,
+ HtmlResponse response, List<Modification> changes)
+ throws RepositoryException {
+ Session session = request.getResourceResolver().adaptTo(Session.class);
+ if (session == null) {
+ throw new RepositoryException("JCR Session not found");
+ }
+
+ //check that the submitted parameter values have valid values.
+ final String principalName = request.getParameter(SlingPostConstants.RP_NODE_NAME);
+ if (principalName == null) {
+ throw new RepositoryException("Group name was not submitted");
+ }
+
+ try {
+ UserManager userManager = AccessControlUtil.getUserManager(session);
+ Authorizable authorizable = userManager.getAuthorizable(principalName);
+
+ if (authorizable != null) {
+ //principal already exists!
+ throw new RepositoryException("A principal already exists with the requested name: " + principalName);
+ } else {
+ Map<String, RequestProperty> reqProperties = collectContent(request, response);
+
+ Group group = userManager.createGroup(new Principal() {
+ public String getName() {
+ return principalName;
+ }
+ });
+
+ String groupPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_GROUP_PREFIX + group.getID();
+ response.setPath(groupPath);
+ response.setLocation(externalizePath(request, groupPath));
+ response.setParentLocation(externalizePath(request, AuthorizableResourceProvider.SYSTEM_USER_MANAGER_GROUP_PATH));
+ changes.add(Modification.onCreated(groupPath));
+
+ // write content from form
+ writeContent(session, group, reqProperties, changes);
+
+ //update the group memberships
+ updateGroupMembership(request, group, changes);
+ }
+ } catch (RepositoryException re) {
+ throw new RepositoryException("Failed to create new group.", re);
+ }
+ }
+}
Propchange: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/CreateGroupOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/CreateGroupOperation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev Url
Added: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/CreateUserOperation.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/CreateUserOperation.java?rev=748454&view=auto
==============================================================================
--- incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/CreateUserOperation.java (added)
+++ incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/CreateUserOperation.java Fri Feb 27 09:19:41 2009
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.jackrabbit.usermanager.post;
+
+import java.util.Dictionary;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.api.security.user.UserManager;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.servlets.HtmlResponse;
+import org.apache.sling.jackrabbit.usermanager.post.impl.RequestProperty;
+import org.apache.sling.jackrabbit.usermanager.resource.AuthorizableResourceProvider;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.jcr.base.util.AccessControlUtil;
+import org.apache.sling.servlets.post.Modification;
+import org.apache.sling.servlets.post.SlingPostConstants;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * Sling Post Operation implementation for creating a user in the jackrabbit
+ * UserManager.
+ *
+ * @scr.component immediate="true" label="%createUser.post.operation.name"
+ * description="%createUser.post.operation.description"
+ * @scr.service interface="org.apache.sling.servlets.post.SlingPostOperation"
+ * @scr.property name="sling.post.operation" value="createUser"
+ */
+public class CreateUserOperation extends AbstractAuthorizableOperation {
+
+ /** @scr.property label="%self.registration.enabled.name"
+ * description="%self.registration.enabled.description"
+ * valueRef="DEFAULT_SELF_REGISTRATION_ENABLED"
+ */
+ private static final String PROP_SELF_REGISTRATION_ENABLED = "self.registration.enabled";
+ private static final Boolean DEFAULT_SELF_REGISTRATION_ENABLED = Boolean.TRUE;
+
+ private Boolean selfRegistrationEnabled = DEFAULT_SELF_REGISTRATION_ENABLED;
+
+ /**
+ * The JCR Repository we access to resolve resources
+ *
+ * @scr.reference
+ */
+ private SlingRepository repository;
+
+ /** Returns the JCR repository used by this service. */
+ protected SlingRepository getRepository() {
+ return repository;
+ }
+
+ /**
+ * Returns an administrative session to the default workspace.
+ */
+ private Session getSession() throws RepositoryException {
+ return getRepository().loginAdministrative(null);
+ }
+
+ /**
+ * Return the administrative session and close it.
+ */
+ private void ungetSession(final Session session) {
+ if ( session != null ) {
+ try {
+ session.logout();
+ } catch (Throwable t) {
+ log.error("Unable to log out of session: " + t.getMessage(), t);
+ }
+ }
+ }
+
+
+ // ---------- SCR integration ---------------------------------------------
+
+ /**
+ * Activates this component.
+ *
+ * @param componentContext The OSGi <code>ComponentContext</code> of this
+ * component.
+ */
+ protected void activate(ComponentContext componentContext) {
+ super.activate(componentContext);
+ Dictionary<?, ?> props = componentContext.getProperties();
+ Object propValue = props.get(PROP_SELF_REGISTRATION_ENABLED);
+ if (propValue instanceof String) {
+ selfRegistrationEnabled = Boolean.parseBoolean((String)propValue);
+ } else {
+ selfRegistrationEnabled = DEFAULT_SELF_REGISTRATION_ENABLED;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.sling.servlets.post.AbstractSlingPostOperation#doRun(org.apache.sling.api.SlingHttpServletRequest, org.apache.sling.api.servlets.HtmlResponse, java.util.List)
+ */
+ @Override
+ protected void doRun(SlingHttpServletRequest request,
+ HtmlResponse response, List<Modification> changes)
+ throws RepositoryException {
+
+ //make sure user self-registration is enabled
+ if (!selfRegistrationEnabled) {
+ throw new RepositoryException("Sorry, registration of new users is not currently enabled. Please try again later.");
+ }
+
+ Session session = request.getResourceResolver().adaptTo(Session.class);
+ if (session == null) {
+ throw new RepositoryException("JCR Session not found");
+ }
+
+ //check that the submitted parameter values have valid values.
+ String principalName = request.getParameter(SlingPostConstants.RP_NODE_NAME);
+ if (principalName == null) {
+ throw new RepositoryException("User name was not submitted");
+ }
+ String pwd = request.getParameter("pwd");
+ if (pwd == null) {
+ throw new RepositoryException("Password was not submitted");
+ }
+ String pwdConfirm = request.getParameter("pwdConfirm");
+ if (!pwd.equals(pwdConfirm)) {
+ throw new RepositoryException("Password value does not match the confirmation password");
+ }
+
+ Session selfRegSession = null;
+ try {
+ selfRegSession = getSession();
+
+ UserManager userManager = AccessControlUtil.getUserManager(selfRegSession);
+ Authorizable authorizable = userManager.getAuthorizable(principalName);
+
+ if (authorizable != null) {
+ //user already exists!
+ throw new RepositoryException("A principal already exists with the requested name: " + principalName);
+ } else {
+ Map<String, RequestProperty> reqProperties = collectContent(request, response);
+
+ User user = userManager.createUser(principalName, digestPassword(pwd));
+ String userPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_USER_PREFIX + user.getID();
+ response.setPath(userPath);
+ response.setLocation(externalizePath(request, userPath));
+ response.setParentLocation(externalizePath(request, AuthorizableResourceProvider.SYSTEM_USER_MANAGER_USER_PATH));
+ changes.add(Modification.onCreated(userPath));
+
+ // write content from form
+ writeContent(selfRegSession, user, reqProperties, changes);
+
+ if (selfRegSession.hasPendingChanges()) {
+ selfRegSession.save();
+ }
+ }
+ } finally {
+ ungetSession(selfRegSession);
+ }
+ }
+}
Propchange: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/CreateUserOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/CreateUserOperation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev Url
Added: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/DeleteAuthorizableOperation.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/DeleteAuthorizableOperation.java?rev=748454&view=auto
==============================================================================
--- incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/DeleteAuthorizableOperation.java (added)
+++ incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/DeleteAuthorizableOperation.java Fri Feb 27 09:19:41 2009
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.jackrabbit.usermanager.post;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jcr.RepositoryException;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceNotFoundException;
+import org.apache.sling.api.servlets.HtmlResponse;
+import org.apache.sling.servlets.post.Modification;
+
+/**
+ * Sling Post Operation implementation for deleting users and/or groups from the
+ * jackrabbit UserManager.
+ *
+ * @scr.component metatype="no" immediate="true"
+ * @scr.service interface="org.apache.sling.servlets.post.SlingPostOperation"
+ * @scr.property name="sling.post.operation" value="deleteAuthorizable"
+ */
+public class DeleteAuthorizableOperation extends AbstractAuthorizableOperation {
+
+ /* (non-Javadoc)
+ * @see org.apache.sling.servlets.post.AbstractSlingPostOperation#doRun(org.apache.sling.api.SlingHttpServletRequest, org.apache.sling.api.servlets.HtmlResponse, java.util.List)
+ */
+ @Override
+ protected void doRun(SlingHttpServletRequest request,
+ HtmlResponse response, List<Modification> changes)
+ throws RepositoryException {
+
+ Iterator<Resource> res = getApplyToResources(request);
+ if (res == null) {
+ Resource resource = request.getResource();
+ Authorizable item = resource.adaptTo(Authorizable.class);
+ if (item == null) {
+ String msg = "Missing source " + resource.getPath() + " for delete";
+ response.setStatus(HttpServletResponse.SC_NOT_FOUND, msg);
+ throw new ResourceNotFoundException(msg);
+ }
+
+ item.remove();
+ changes.add(Modification.onDeleted(resource.getPath()));
+ } else {
+ while (res.hasNext()) {
+ Resource resource = res.next();
+ Authorizable item = resource.adaptTo(Authorizable.class);
+ if (item != null) {
+ item.remove();
+ changes.add(Modification.onDeleted(resource.getPath()));
+ }
+ }
+ }
+ }
+}
Propchange: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/DeleteAuthorizableOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/DeleteAuthorizableOperation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev Url
Added: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/UpdateAuthorizableOperation.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/UpdateAuthorizableOperation.java?rev=748454&view=auto
==============================================================================
--- incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/UpdateAuthorizableOperation.java (added)
+++ incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/UpdateAuthorizableOperation.java Fri Feb 27 09:19:41 2009
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.jackrabbit.usermanager.post;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.servlets.HtmlResponse;
+import org.apache.sling.jackrabbit.usermanager.post.impl.RequestProperty;
+import org.apache.sling.servlets.post.Modification;
+
+/**
+ * Sling Post Operation implementation for updating a user or group in the
+ * jackrabbit UserManager.
+ *
+ * @scr.component metatype="no" immediate="true"
+ * @scr.service interface="org.apache.sling.servlets.post.SlingPostOperation"
+ * @scr.property name="sling.post.operation" value="updateAuthorizable"
+ */
+public class UpdateAuthorizableOperation extends AbstractAuthorizableOperation {
+
+ /* (non-Javadoc)
+ * @see org.apache.sling.servlets.post.AbstractSlingPostOperation#doRun(org.apache.sling.api.SlingHttpServletRequest, org.apache.sling.api.servlets.HtmlResponse, java.util.List)
+ */
+ @Override
+ protected void doRun(SlingHttpServletRequest request,
+ HtmlResponse response, List<Modification> changes)
+ throws RepositoryException {
+ Authorizable authorizable = null;
+ Resource resource = request.getResource();
+ if (resource != null) {
+ authorizable = resource.adaptTo(Authorizable.class);
+ }
+
+ //check that the group was located.
+ if (authorizable == null) {
+ throw new RepositoryException("Authorizable to update could not be determined");
+ }
+
+ Session session = request.getResourceResolver().adaptTo(Session.class);
+ if (session == null) {
+ throw new RepositoryException("JCR Session not found");
+ }
+
+ Map<String, RequestProperty> reqProperties = collectContent(request, response);
+ try {
+ // cleanup any old content (@Delete parameters)
+ processDeletes(authorizable, reqProperties, changes);
+
+ // write content from form
+ writeContent(session, authorizable, reqProperties, changes);
+
+ //update the group memberships
+ if (authorizable.isGroup()) {
+ updateGroupMembership(request, authorizable, changes);
+ }
+ } catch (RepositoryException re) {
+ throw new RepositoryException("Failed to update authorizable.", re);
+ }
+ }
+}
Propchange: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/UpdateAuthorizableOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/UpdateAuthorizableOperation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev Url
Added: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/impl/DateParser.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/impl/DateParser.java?rev=748454&view=auto
==============================================================================
--- incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/impl/DateParser.java (added)
+++ incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/impl/DateParser.java Fri Feb 27 09:19:41 2009
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.jackrabbit.usermanager.post.impl;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Takes a string representation of a time-date string and tries for parse it
+ * using different formats.
+ */
+public class DateParser {
+
+ /**
+ * default log
+ */
+ private static final Logger log = LoggerFactory.getLogger(DateParser.class);
+
+ /**
+ * lits of formats
+ */
+ private final List<DateFormat> formats = new LinkedList<DateFormat>();
+
+ /**
+ * Registers a format string to the list of internally checked ones.
+ * Uses the {@link SimpleDateFormat}.
+ * @param format format as in {@link SimpleDateFormat}
+ * @throws IllegalArgumentException if the format is not valid.
+ */
+ public void register(String format) {
+ register(new SimpleDateFormat(format, Locale.US));
+ }
+
+ /**
+ * Registers a date format to the list of internally checked ones.
+ * @param format date format
+ */
+ public void register(DateFormat format) {
+ formats.add(format);
+ }
+
+ /**
+ * Parses the given source string and returns the respective calendar
+ * instance. If no format matches returns <code>null</code>.
+ * <p/>
+ * Note: method is synchronized because SimpleDateFormat is not.
+ *
+ * @param source date time source string
+ * @return calendar representation of the source or <code>null</code>
+ */
+ public synchronized Calendar parse(String source) {
+ for (DateFormat fmt: formats) {
+ try {
+ Date d = fmt.parse(source);
+ if (log.isDebugEnabled()) {
+ log.debug("Parsed " + source + " using " + fmt + " into " + d);
+ }
+ Calendar c = Calendar.getInstance();
+ c.setTime(d);
+ return c;
+ } catch (ParseException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed parsing " + source + " using " + fmt);
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Parses the given source strings and returns the respective calendar
+ * instances. If no format matches for any of the sources
+ * returns <code>null</code>.
+ * <p/>
+ * Note: method is synchronized because SimpleDateFormat is not.
+ *
+ * @param sources date time source strings
+ * @return calendar representations of the source or <code>null</code>
+ */
+ public synchronized Calendar[] parse(String sources[]) {
+ Calendar ret[] = new Calendar[sources.length];
+ for (int i=0; i< sources.length; i++) {
+ if ((ret[i] = parse(sources[i])) == null) {
+ return null;
+ }
+ }
+ return ret;
+ }
+
+ /**
+ * Parses the given source strings and returns the respective jcr date value
+ * instances. If no format matches for any of the sources
+ * returns <code>null</code>.
+ * <p/>
+ * Note: method is synchronized because SimpleDateFormat is not.
+ *
+ * @param sources date time source strings
+ * @param factory the value factory
+ * @return jcr date value representations of the source or <code>null</code>
+ */
+ public synchronized Value[] parse(String sources[], ValueFactory factory) {
+ Value ret[] = new Value[sources.length];
+ for (int i=0; i< sources.length; i++) {
+ Calendar c = parse(sources[i]);
+ if (c == null) {
+ return null;
+ }
+ ret[i] = factory.createValue(c);
+ }
+ return ret;
+ }
+}
\ No newline at end of file
Propchange: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/impl/DateParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/post/impl/DateParser.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev Url