Add security 1.0 spec. Thanks Roberto for the patch
git-svn-id: https://svn.apache.org/repos/asf/geronimo/specs/trunk@1851799 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/geronimo-security_1.0_spec/LICENSE b/geronimo-security_1.0_spec/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/geronimo-security_1.0_spec/LICENSE
@@ -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.
diff --git a/geronimo-security_1.0_spec/NOTICE b/geronimo-security_1.0_spec/NOTICE
new file mode 100644
index 0000000..c4f2da6
--- /dev/null
+++ b/geronimo-security_1.0_spec/NOTICE
@@ -0,0 +1,5 @@
+Apache Geronimo
+Copyright 2003-2019 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/geronimo-security_1.0_spec/pom.xml b/geronimo-security_1.0_spec/pom.xml
new file mode 100644
index 0000000..d504a04
--- /dev/null
+++ b/geronimo-security_1.0_spec/pom.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.geronimo.genesis</groupId>
+ <artifactId>genesis-java8-flava</artifactId>
+ <version>2.3</version>
+ </parent>
+
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-security_1.0_spec</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Geronimo Security Spec 1.0</name>
+ <version>1.0-SNAPSHOT</version>
+
+ <description>Apache Geronimo implementation of the JSR-375</description>
+ <url>http://geronimo.apache.org/maven/${siteId}/${project.version}</url>
+
+ <distributionManagement>
+ <site>
+ <id>apache-website</id>
+ <url>${site.deploy.url}/maven/${siteId}/${project.version}</url>
+ </site>
+ </distributionManagement>
+
+ <properties>
+ <siteId>specs/${project.artifactId}</siteId>
+ </properties>
+
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/geronimo/specs/trunk/geronimo-security_1.0_spec/</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/geronimo/specs/trunk/geronimo-security_1.0_spec/
+ </developerConnection>
+ <url>http://svn.apache.org/viewcvs.cgi/geronimo/specs/trunk/geronimo-security_1.0_spec/</url>
+ </scm>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jaspic_1.0_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-servlet_3.0_spec</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jcdi_2.0_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-interceptor_1.2_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>3.5.0</version>
+ <configuration>
+ <instructions>
+ <Export-Package>javax.security*;version=1.0</Export-Package>
+ <Provide-Capability><![CDATA[
+ osgi.contract;osgi.contract=JavaSecurity;uses:="${packages;NAMED;javax.*}";version:List<Version>='1.0'
+ ]]></Provide-Capability>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/AuthenticationException.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/AuthenticationException.java
new file mode 100644
index 0000000..e30ba20
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/AuthenticationException.java
@@ -0,0 +1,39 @@
+/*
+ * 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 javax.security.enterprise;
+
+import java.security.GeneralSecurityException;
+
+public class AuthenticationException extends GeneralSecurityException {
+ private static final long serialVersionUID = 1L;
+
+ public AuthenticationException() {
+ super();
+ }
+
+ public AuthenticationException(String message) {
+ super(message);
+ }
+
+ public AuthenticationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public AuthenticationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/AuthenticationStatus.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/AuthenticationStatus.java
new file mode 100644
index 0000000..208eb59
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/AuthenticationStatus.java
@@ -0,0 +1,24 @@
+/*
+ * 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 javax.security.enterprise;
+
+public enum AuthenticationStatus {
+ NOT_DONE,
+ SEND_CONTINUE,
+ SUCCESS,
+ SEND_FAILURE
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/CallerPrincipal.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/CallerPrincipal.java
new file mode 100644
index 0000000..e02b801
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/CallerPrincipal.java
@@ -0,0 +1,35 @@
+/*
+ * 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 javax.security.enterprise;
+
+import java.io.Serializable;
+import java.security.Principal;
+
+public class CallerPrincipal implements Principal, Serializable {
+ private static final long serialVersionUID = -6951555039431667786L;
+
+ private final String name;
+
+ public CallerPrincipal(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/SecurityContext.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/SecurityContext.java
new file mode 100644
index 0000000..2282fcd
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/SecurityContext.java
@@ -0,0 +1,36 @@
+/*
+ * 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 javax.security.enterprise;
+
+import javax.security.enterprise.authentication.mechanism.http.AuthenticationParameters;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.security.Principal;
+import java.util.Set;
+
+public interface SecurityContext {
+ Principal getCallerPrincipal();
+
+ <T extends Principal> Set<T> getPrincipalsByType(Class<T> pType);
+
+ boolean isCallerInRole(String role);
+
+ boolean hasAccessToWebResource(String resource, String... methods);
+
+ AuthenticationStatus authenticate(HttpServletRequest request, HttpServletResponse response,
+ AuthenticationParameters parameters);
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/AuthenticationParameters.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/AuthenticationParameters.java
new file mode 100644
index 0000000..ac03426
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/AuthenticationParameters.java
@@ -0,0 +1,68 @@
+/*
+ * 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 javax.security.enterprise.authentication.mechanism.http;
+
+import javax.security.enterprise.credential.Credential;
+
+public class AuthenticationParameters {
+ private Credential credential;
+ private boolean newAuthentication;
+ private boolean rememberMe;
+
+ public static AuthenticationParameters withParams() {
+ return new AuthenticationParameters();
+ }
+
+ public AuthenticationParameters credential(Credential credential) {
+ setCredential(credential);
+ return this;
+ }
+
+ public AuthenticationParameters newAuthentication(boolean newAuthentication) {
+ setNewAuthentication(newAuthentication);
+ return this;
+ }
+
+ public AuthenticationParameters rememberMe(boolean rememberMe) {
+ setRememberMe(rememberMe);
+ return this;
+ }
+
+ public Credential getCredential() {
+ return credential;
+ }
+
+ public void setCredential(Credential credential) {
+ this.credential = credential;
+ }
+
+ public boolean isNewAuthentication() {
+ return newAuthentication;
+ }
+
+ public void setNewAuthentication(boolean newAuthentication) {
+ this.newAuthentication = newAuthentication;
+ }
+
+ public boolean isRememberMe() {
+ return rememberMe;
+ }
+
+ public void setRememberMe(boolean rememberMe) {
+ this.rememberMe = rememberMe;
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/AutoApplySession.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/AutoApplySession.java
new file mode 100644
index 0000000..291c726
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/AutoApplySession.java
@@ -0,0 +1,39 @@
+/*
+ * 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 javax.security.enterprise.authentication.mechanism.http;
+
+import javax.enterprise.util.AnnotationLiteral;
+import javax.interceptor.InterceptorBinding;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Inherited
+@InterceptorBinding
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface AutoApplySession {
+ @SuppressWarnings("all")
+ public static final class Literal extends AnnotationLiteral<AutoApplySession> implements AutoApplySession {
+ private static final long serialVersionUID = 1L;
+
+ public static final Literal INSTANCE = new Literal();
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/BasicAuthenticationMechanismDefinition.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/BasicAuthenticationMechanismDefinition.java
new file mode 100644
index 0000000..badf841
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/BasicAuthenticationMechanismDefinition.java
@@ -0,0 +1,29 @@
+/*
+ * 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 javax.security.enterprise.authentication.mechanism.http;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface BasicAuthenticationMechanismDefinition {
+ String realmName() default "";
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/CustomFormAuthenticationMechanismDefinition.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/CustomFormAuthenticationMechanismDefinition.java
new file mode 100644
index 0000000..a3e981d
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/CustomFormAuthenticationMechanismDefinition.java
@@ -0,0 +1,31 @@
+/*
+ * 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 javax.security.enterprise.authentication.mechanism.http;
+
+import javax.enterprise.util.Nonbinding;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface CustomFormAuthenticationMechanismDefinition {
+ @Nonbinding
+ LoginToContinue loginToContinue();
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/FormAuthenticationMechanismDefinition.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/FormAuthenticationMechanismDefinition.java
new file mode 100644
index 0000000..22b5cfe
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/FormAuthenticationMechanismDefinition.java
@@ -0,0 +1,31 @@
+/*
+ * 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 javax.security.enterprise.authentication.mechanism.http;
+
+import javax.enterprise.util.Nonbinding;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface FormAuthenticationMechanismDefinition {
+ @Nonbinding
+ LoginToContinue loginToContinue();
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpAuthenticationMechanism.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpAuthenticationMechanism.java
new file mode 100644
index 0000000..03f7282
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpAuthenticationMechanism.java
@@ -0,0 +1,42 @@
+/*
+ * 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 javax.security.enterprise.authentication.mechanism.http;
+
+import javax.security.enterprise.AuthenticationException;
+import javax.security.enterprise.AuthenticationStatus;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import static javax.security.enterprise.AuthenticationStatus.SUCCESS;
+
+public interface HttpAuthenticationMechanism {
+
+ AuthenticationStatus validateRequest(HttpServletRequest request, HttpServletResponse response,
+ HttpMessageContext httpMessageContext)
+ throws AuthenticationException;
+
+ default AuthenticationStatus secureResponse(HttpServletRequest request, HttpServletResponse response,
+ HttpMessageContext httpMessageContext)
+ throws AuthenticationException {
+ return SUCCESS;
+ }
+
+ default void cleanSubject(HttpServletRequest request, HttpServletResponse response,
+ HttpMessageContext httpMessageContext) {
+ httpMessageContext.cleanClientSubject();
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpAuthenticationMechanismWrapper.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpAuthenticationMechanismWrapper.java
new file mode 100644
index 0000000..352677b
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpAuthenticationMechanismWrapper.java
@@ -0,0 +1,57 @@
+/*
+ * 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 javax.security.enterprise.authentication.mechanism.http;
+
+import javax.security.enterprise.AuthenticationException;
+import javax.security.enterprise.AuthenticationStatus;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class HttpAuthenticationMechanismWrapper implements HttpAuthenticationMechanism {
+ private final HttpAuthenticationMechanism httpAuthenticationMechanism;
+
+ public HttpAuthenticationMechanismWrapper(final HttpAuthenticationMechanism httpAuthenticationMechanism) {
+ this.httpAuthenticationMechanism = httpAuthenticationMechanism;
+ }
+
+ public HttpAuthenticationMechanism getWrapped() {
+ return httpAuthenticationMechanism;
+ }
+
+ @Override
+ public AuthenticationStatus validateRequest(HttpServletRequest request,
+ HttpServletResponse response,
+ HttpMessageContext httpMessageContext)
+ throws AuthenticationException {
+ return getWrapped().validateRequest(request, response, httpMessageContext);
+ }
+
+ @Override
+ public AuthenticationStatus secureResponse(HttpServletRequest request,
+ HttpServletResponse response,
+ HttpMessageContext httpMessageContext)
+ throws AuthenticationException {
+ return getWrapped().secureResponse(request, response, httpMessageContext);
+ }
+
+ @Override
+ public void cleanSubject(HttpServletRequest request,
+ HttpServletResponse response,
+ HttpMessageContext httpMessageContext) {
+ getWrapped().cleanSubject(request, response, httpMessageContext);
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpMessageContext.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpMessageContext.java
new file mode 100644
index 0000000..5fc4fb3
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpMessageContext.java
@@ -0,0 +1,77 @@
+/*
+ * 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 javax.security.enterprise.authentication.mechanism.http;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.message.MessageInfo;
+import javax.security.enterprise.AuthenticationStatus;
+import javax.security.enterprise.identitystore.CredentialValidationResult;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.security.Principal;
+import java.util.Set;
+
+public interface HttpMessageContext {
+ boolean isProtected();
+
+ boolean isAuthenticationRequest();
+
+ boolean isRegisterSession();
+
+ void setRegisterSession(String callerName, Set<String> groups);
+
+ void cleanClientSubject();
+
+ AuthenticationParameters getAuthParameters();
+
+ CallbackHandler getHandler();
+
+ MessageInfo getMessageInfo();
+
+ Subject getClientSubject();
+
+ HttpServletRequest getRequest();
+
+ void setRequest(HttpServletRequest request);
+
+ HttpMessageContext withRequest(HttpServletRequest request);
+
+ HttpServletResponse getResponse();
+
+ void setResponse(HttpServletResponse response);
+
+ AuthenticationStatus redirect(String location);
+
+ AuthenticationStatus forward(String path);
+
+ AuthenticationStatus responseUnauthorized();
+
+ AuthenticationStatus responseNotFound();
+
+ AuthenticationStatus notifyContainerAboutLogin(String callername, Set<String> groups);
+
+ AuthenticationStatus notifyContainerAboutLogin(Principal principal, Set<String> groups);
+
+ AuthenticationStatus notifyContainerAboutLogin(CredentialValidationResult result);
+
+ AuthenticationStatus doNothing();
+
+ Principal getCallerPrincipal();
+
+ Set<String> getGroups();
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpMessageContextWrapper.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpMessageContextWrapper.java
new file mode 100644
index 0000000..137f11c
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpMessageContextWrapper.java
@@ -0,0 +1,159 @@
+/*
+ * 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 javax.security.enterprise.authentication.mechanism.http;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.message.MessageInfo;
+import javax.security.enterprise.AuthenticationStatus;
+import javax.security.enterprise.identitystore.CredentialValidationResult;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.security.Principal;
+import java.util.Set;
+
+public class HttpMessageContextWrapper implements HttpMessageContext {
+ private final HttpMessageContext httpMessageContext;
+
+ public HttpMessageContextWrapper(final HttpMessageContext httpMessageContext) {
+ this.httpMessageContext = httpMessageContext;
+ }
+
+ public HttpMessageContext getWrapped() {
+ return httpMessageContext;
+ }
+
+ @Override
+ public boolean isProtected() {
+ return getWrapped().isProtected();
+ }
+
+ @Override
+ public boolean isAuthenticationRequest() {
+ return getWrapped().isAuthenticationRequest();
+ }
+
+ @Override
+ public boolean isRegisterSession() {
+ return getWrapped().isRegisterSession();
+ }
+
+ @Override
+ public void setRegisterSession(final String callerName, final Set<String> groups) {
+ getWrapped().setRegisterSession(callerName, groups);
+ }
+
+ @Override
+ public void cleanClientSubject() {
+ getWrapped().cleanClientSubject();
+ }
+
+ @Override
+ public AuthenticationParameters getAuthParameters() {
+ return getWrapped().getAuthParameters();
+ }
+
+ @Override
+ public CallbackHandler getHandler() {
+ return getWrapped().getHandler();
+ }
+
+ @Override
+ public MessageInfo getMessageInfo() {
+ return getWrapped().getMessageInfo();
+ }
+
+ @Override
+ public Subject getClientSubject() {
+ return getWrapped().getClientSubject();
+ }
+
+ @Override
+ public HttpServletRequest getRequest() {
+ return getWrapped().getRequest();
+ }
+
+ @Override
+ public void setRequest(final HttpServletRequest request) {
+ getWrapped().setRequest(request);
+ }
+
+ @Override
+ public HttpMessageContext withRequest(final HttpServletRequest request) {
+ return getWrapped().withRequest(request);
+ }
+
+ @Override
+ public HttpServletResponse getResponse() {
+ return getWrapped().getResponse();
+ }
+
+ @Override
+ public void setResponse(final HttpServletResponse response) {
+ getWrapped().setResponse(response);
+ }
+
+ @Override
+ public AuthenticationStatus redirect(final String location) {
+ return getWrapped().redirect(location);
+ }
+
+ @Override
+ public AuthenticationStatus forward(final String path) {
+ return getWrapped().forward(path);
+ }
+
+ @Override
+ public AuthenticationStatus responseUnauthorized() {
+ return getWrapped().responseUnauthorized();
+ }
+
+ @Override
+ public AuthenticationStatus responseNotFound() {
+ return getWrapped().responseNotFound();
+ }
+
+ @Override
+ public AuthenticationStatus notifyContainerAboutLogin(final String callername, final Set<String> groups) {
+ return getWrapped().notifyContainerAboutLogin(callername, groups);
+ }
+
+ @Override
+ public AuthenticationStatus notifyContainerAboutLogin(final Principal principal, final Set<String> groups) {
+ return getWrapped().notifyContainerAboutLogin(principal, groups);
+ }
+
+ @Override
+ public AuthenticationStatus notifyContainerAboutLogin(final CredentialValidationResult result) {
+ return getWrapped().notifyContainerAboutLogin(result);
+ }
+
+ @Override
+ public AuthenticationStatus doNothing() {
+ return getWrapped().doNothing();
+ }
+
+ @Override
+ public Principal getCallerPrincipal() {
+ return getWrapped().getCallerPrincipal();
+ }
+
+ @Override
+ public Set<String> getGroups() {
+ return getWrapped().getGroups();
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/LoginToContinue.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/LoginToContinue.java
new file mode 100644
index 0000000..37faac9
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/LoginToContinue.java
@@ -0,0 +1,124 @@
+/*
+ * 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 javax.security.enterprise.authentication.mechanism.http;
+
+import javax.enterprise.util.AnnotationLiteral;
+import javax.enterprise.util.Nonbinding;
+import javax.interceptor.InterceptorBinding;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Inherited
+@InterceptorBinding
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface LoginToContinue {
+ @Nonbinding
+ String loginPage() default "/login";
+
+ @Nonbinding
+ boolean useForwardToLogin() default true;
+
+ @Nonbinding
+ String useForwardToLoginExpression() default "";
+
+ @Nonbinding
+ String errorPage() default "/login-error";
+
+ @SuppressWarnings("all") final class Literal extends AnnotationLiteral<LoginToContinue> implements LoginToContinue {
+ private static final long serialVersionUID = 1L;
+
+ private final String loginPage;
+ private final boolean useForwardToLogin;
+ private final String useForwardToLoginExpression;
+ private final String errorPage;
+
+ public static LiteralBuilder builder() {
+ return new LiteralBuilder();
+ }
+
+ public static class LiteralBuilder {
+ private String loginPage = "/login";
+ private boolean useForwardToLogin = true;
+ private String useForwardToLoginExpression;
+ private String errorPage = "/login-error";
+
+ public LiteralBuilder loginPage(String loginPage) {
+ this.loginPage = loginPage;
+ return this;
+ }
+
+ public LiteralBuilder useForwardToLogin(boolean useForwardToLogin) {
+ this.useForwardToLogin = useForwardToLogin;
+ return this;
+ }
+
+ public LiteralBuilder useForwardToLoginExpression(String useForwardToLoginExpression) {
+ this.useForwardToLoginExpression = useForwardToLoginExpression;
+ return this;
+ }
+
+ public LiteralBuilder errorPage(String errorPage) {
+ this.errorPage = errorPage;
+ return this;
+ }
+
+ public Literal build() {
+ return new Literal(
+ loginPage,
+ useForwardToLogin,
+ useForwardToLoginExpression,
+ errorPage);
+ }
+ }
+
+ public Literal(String loginPage,
+ boolean useForwardToLogin,
+ String useForwardToLoginExpression,
+ String errorPage) {
+ this.loginPage = loginPage;
+ this.useForwardToLogin = useForwardToLogin;
+ this.useForwardToLoginExpression = useForwardToLoginExpression;
+ this.errorPage = errorPage;
+ }
+
+ @Override
+ public String loginPage() {
+ return loginPage;
+ }
+
+ @Override
+ public boolean useForwardToLogin() {
+ return useForwardToLogin;
+ }
+
+ @Override
+ public String useForwardToLoginExpression() {
+ return useForwardToLoginExpression;
+ }
+
+ @Override
+ public String errorPage() {
+ return errorPage;
+ }
+
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/RememberMe.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/RememberMe.java
new file mode 100644
index 0000000..065e54f
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/authentication/mechanism/http/RememberMe.java
@@ -0,0 +1,216 @@
+/*
+ * 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 javax.security.enterprise.authentication.mechanism.http;
+
+import javax.enterprise.util.AnnotationLiteral;
+import javax.enterprise.util.Nonbinding;
+import javax.interceptor.InterceptorBinding;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Inherited
+@InterceptorBinding
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface RememberMe {
+ @Nonbinding
+ int cookieMaxAgeSeconds() default 86400;
+
+ @Nonbinding
+ String cookieMaxAgeSecondsExpression() default "";
+
+ @Nonbinding
+ boolean cookieSecureOnly() default true;
+
+ @Nonbinding
+ String cookieSecureOnlyExpression() default "";
+
+ @Nonbinding
+ boolean cookieHttpOnly() default true;
+
+ @Nonbinding
+ String cookieHttpOnlyExpression() default "";
+
+ @Nonbinding
+ String cookieName() default "JREMEMBERMEID";
+
+ @Nonbinding
+ boolean isRememberMe() default true;
+
+ @Nonbinding
+ String isRememberMeExpression() default "";
+
+ @SuppressWarnings("all")
+ final class Literal extends AnnotationLiteral<RememberMe> implements RememberMe {
+ private static final long serialVersionUID = 1L;
+
+ private final int cookieMaxAgeSeconds;
+ private final String cookieMaxAgeSecondsExpression;
+ private final boolean cookieSecureOnly;
+ private final String cookieSecureOnlyExpression;
+ private final boolean cookieHttpOnly;
+ private final String cookieHttpOnlyExpression;
+ private final String cookieName;
+ private final boolean isRememberMe;
+ private final String isRememberMeExpression;
+
+ public static LiteralBuilder builder() {
+ return new LiteralBuilder();
+ }
+
+ public static class LiteralBuilder {
+ private int cookieMaxAgeSeconds = 86400;
+ private String cookieMaxAgeSecondsExpression;
+ private boolean cookieSecureOnly = true;
+ private String cookieSecureOnlyExpression;
+ private boolean cookieHttpOnly = true;
+ private String cookieHttpOnlyExpression;
+ private String cookieName = "JREMEMBERMEID";
+ private boolean isRememberMe = true;
+ private String isRememberMeExpression;
+
+ public LiteralBuilder cookieMaxAgeSeconds(int cookieMaxAgeSeconds) {
+ this.cookieMaxAgeSeconds = cookieMaxAgeSeconds;
+ return this;
+ }
+
+ public LiteralBuilder cookieMaxAgeSecondsExpression(String cookieMaxAgeSecondsExpression) {
+ this.cookieMaxAgeSecondsExpression = cookieMaxAgeSecondsExpression;
+ return this;
+ }
+
+ public LiteralBuilder cookieSecureOnly(boolean cookieSecureOnly) {
+ this.cookieSecureOnly = cookieSecureOnly;
+ return this;
+
+ }
+
+ public LiteralBuilder cookieSecureOnlyExpression(String cookieSecureOnlyExpression) {
+ this.cookieSecureOnlyExpression = cookieSecureOnlyExpression;
+ return this;
+ }
+
+ public LiteralBuilder cookieHttpOnly(boolean cookieHttpOnly) {
+ this.cookieHttpOnly = cookieHttpOnly;
+ return this;
+ }
+
+ public LiteralBuilder cookieHttpOnlyExpression(String cookieHttpOnlyExpression) {
+ this.cookieHttpOnlyExpression = cookieHttpOnlyExpression;
+ return this;
+ }
+
+ public LiteralBuilder cookieName(String cookieName) {
+ this.cookieName = cookieName;
+ return this;
+ }
+
+ public LiteralBuilder isRememberMe(boolean isRememberMe) {
+ this.isRememberMe = isRememberMe;
+ return this;
+ }
+
+ public LiteralBuilder isRememberMeExpression(String isRememberMeExpression) {
+ this.isRememberMeExpression = isRememberMeExpression;
+ return this;
+ }
+
+ public Literal build() {
+ return new Literal(
+ cookieMaxAgeSeconds,
+ cookieMaxAgeSecondsExpression,
+ cookieSecureOnly,
+ cookieSecureOnlyExpression,
+ cookieHttpOnly,
+ cookieHttpOnlyExpression,
+ cookieName,
+ isRememberMe,
+ isRememberMeExpression);
+ }
+ }
+
+ public Literal(int cookieMaxAgeSeconds,
+ String cookieMaxAgeSecondsExpression,
+ boolean cookieSecureOnly,
+ String cookieSecureOnlyExpression,
+ boolean cookieHttpOnly,
+ String cookieHttpOnlyExpression,
+ String cookieName,
+ boolean isRememberMe,
+ String isRememberMeExpression) {
+
+ this.cookieMaxAgeSeconds = cookieMaxAgeSeconds;
+ this.cookieMaxAgeSecondsExpression = cookieMaxAgeSecondsExpression;
+ this.cookieSecureOnly = cookieSecureOnly;
+ this.cookieSecureOnlyExpression = cookieSecureOnlyExpression;
+ this.cookieHttpOnly = cookieHttpOnly;
+ this.cookieHttpOnlyExpression = cookieHttpOnlyExpression;
+ this.cookieName = cookieName;
+ this.isRememberMe = isRememberMe;
+ this.isRememberMeExpression = isRememberMeExpression;
+ }
+
+ @Override
+ public boolean cookieHttpOnly() {
+ return cookieHttpOnly;
+ }
+
+ @Override
+ public String cookieHttpOnlyExpression() {
+ return cookieHttpOnlyExpression;
+ }
+
+ @Override
+ public int cookieMaxAgeSeconds() {
+ return cookieMaxAgeSeconds;
+ }
+
+ @Override
+ public String cookieMaxAgeSecondsExpression() {
+ return cookieMaxAgeSecondsExpression;
+ }
+
+ @Override
+ public boolean cookieSecureOnly() {
+ return cookieSecureOnly;
+ }
+
+ @Override
+ public String cookieSecureOnlyExpression() {
+ return cookieSecureOnlyExpression;
+ }
+
+ @Override
+ public String cookieName() {
+ return cookieName;
+ }
+
+ @Override
+ public boolean isRememberMe() {
+ return isRememberMe;
+ }
+
+ @Override
+ public String isRememberMeExpression() {
+ return isRememberMeExpression;
+ }
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/AbstractClearableCredential.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/AbstractClearableCredential.java
new file mode 100644
index 0000000..8b9ac9c
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/AbstractClearableCredential.java
@@ -0,0 +1,39 @@
+/*
+ * 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 javax.security.enterprise.credential;
+
+public abstract class AbstractClearableCredential implements Credential {
+
+ private volatile boolean cleared = false;
+
+ @Override
+ public final boolean isCleared() {
+ return cleared;
+ }
+
+ protected final void setCleared() {
+ this.cleared = true;
+ }
+
+ @Override
+ public final void clear() {
+ clearCredential();
+ setCleared();
+ }
+
+ protected abstract void clearCredential();
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/BasicAuthenticationCredential.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/BasicAuthenticationCredential.java
new file mode 100644
index 0000000..1d05f1b
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/BasicAuthenticationCredential.java
@@ -0,0 +1,67 @@
+/*
+ * 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 javax.security.enterprise.credential;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Base64;
+
+public class BasicAuthenticationCredential extends UsernamePasswordCredential {
+
+ public BasicAuthenticationCredential(String authorizationHeader) {
+ super(parseUsername(authorizationHeader), parsePassword(authorizationHeader));
+ }
+
+ private static String decodeHeader(String authorizationHeader) {
+ final String basicAuthCharset = "US-ASCII";
+
+ if (null == authorizationHeader) {
+ throw new NullPointerException("authorization header");
+ }
+
+ if (authorizationHeader.isEmpty()) {
+ throw new IllegalArgumentException("authorization header is empty");
+ }
+
+ final Base64.Decoder decoder = Base64.getMimeDecoder();
+ byte[] decodedBytes = decoder.decode(authorizationHeader);
+ try {
+ return new String(decodedBytes, basicAuthCharset);
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalStateException("Unknown Charset: " + basicAuthCharset, e);
+ }
+ }
+
+ private static String parseUsername(String authorizationHeader) {
+ String decodedAuthorizationHeader = decodeHeader(authorizationHeader);
+ int delimiterIndex = decodedAuthorizationHeader.indexOf(':');
+ if (delimiterIndex > -1) {
+ return decodedAuthorizationHeader.substring(0, delimiterIndex);
+ } else {
+ return decodedAuthorizationHeader;
+ }
+ }
+
+ private static Password parsePassword(String authorizationHeader) {
+ String decodedAuthorizationHeader = decodeHeader(authorizationHeader);
+ int delimiterIndex = decodedAuthorizationHeader.indexOf(':');
+ if (delimiterIndex > -1) {
+ return new Password(decodedAuthorizationHeader.substring(delimiterIndex + 1));
+ } else {
+ return new Password("");
+ }
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/CallerOnlyCredential.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/CallerOnlyCredential.java
new file mode 100644
index 0000000..325a9e0
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/CallerOnlyCredential.java
@@ -0,0 +1,29 @@
+/*
+ * 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 javax.security.enterprise.credential;
+
+public class CallerOnlyCredential implements Credential {
+ private final String caller;
+
+ public CallerOnlyCredential(String caller) {
+ this.caller = caller;
+ }
+
+ public String getCaller() {
+ return caller;
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/Credential.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/Credential.java
new file mode 100644
index 0000000..2a063af
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/Credential.java
@@ -0,0 +1,29 @@
+/*
+ * 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 javax.security.enterprise.credential;
+
+public interface Credential {
+ default boolean isCleared() {
+ return false;
+ }
+
+ default void clear() {}
+
+ default boolean isValid() {
+ return true;
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/Password.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/Password.java
new file mode 100644
index 0000000..b52c429
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/Password.java
@@ -0,0 +1,56 @@
+/*
+ * 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 javax.security.enterprise.credential;
+
+import java.util.Arrays;
+
+import static java.util.Arrays.copyOf;
+import static java.util.Objects.requireNonNull;
+
+public class Password {
+ private static final char[] EMPTY_VALUE = new char[0];
+ private volatile char[] value;
+
+ public Password(char[] value) {
+ requireNonNull(value, "Password value may not be null");
+
+ this.value = copyOf(value, value.length);
+ }
+
+ public Password(String value) {
+ this(null == value ? null : value.toCharArray());
+ }
+
+ public char[] getValue() {
+ return value;
+ }
+
+ public void clear() {
+ if (EMPTY_VALUE == value) { return; }
+
+ char[] tempValue = value;
+ value = EMPTY_VALUE;
+
+ for (int i = 0; i < tempValue.length; i++) {
+ tempValue[i] = 0x00;
+ }
+ }
+
+ public boolean compareTo(String password) {
+ return password != null && Arrays.equals(password.toCharArray(), value);
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/RememberMeCredential.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/RememberMeCredential.java
new file mode 100644
index 0000000..91bdcb0
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/RememberMeCredential.java
@@ -0,0 +1,29 @@
+/*
+ * 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 javax.security.enterprise.credential;
+
+public class RememberMeCredential implements Credential {
+ private final String token;
+
+ public RememberMeCredential(String token) {
+ this.token = token;
+ }
+
+ public String getToken() {
+ return token;
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/UsernamePasswordCredential.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/UsernamePasswordCredential.java
new file mode 100644
index 0000000..6521397
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/credential/UsernamePasswordCredential.java
@@ -0,0 +1,54 @@
+/*
+ * 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 javax.security.enterprise.credential;
+
+public class UsernamePasswordCredential extends AbstractClearableCredential {
+
+ private final String caller;
+ private final Password password;
+
+ public UsernamePasswordCredential(String callerName, String password) {
+ this.caller = callerName;
+ this.password = new Password(password);
+ }
+
+ public UsernamePasswordCredential(String callerName, Password password) {
+ this.caller = callerName;
+ this.password = password;
+ }
+
+ public Password getPassword() {
+ return password;
+ }
+
+ public String getPasswordAsString() {
+ return String.valueOf(getPassword().getValue());
+ }
+
+ @Override
+ public void clearCredential() {
+ password.clear();
+ }
+
+ public String getCaller() {
+ return caller;
+ }
+
+ public boolean compareTo(String callerName, String password) {
+ return getCaller().equals(callerName) && getPassword().compareTo(password);
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/CredentialValidationResult.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/CredentialValidationResult.java
new file mode 100644
index 0000000..c24be15
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/CredentialValidationResult.java
@@ -0,0 +1,119 @@
+/*
+ * 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 javax.security.enterprise.identitystore;
+
+
+import javax.security.enterprise.CallerPrincipal;
+import java.util.HashSet;
+import java.util.Set;
+
+import static java.util.Collections.emptySet;
+import static java.util.Collections.unmodifiableSet;
+import static javax.security.enterprise.identitystore.CredentialValidationResult.Status.INVALID;
+import static javax.security.enterprise.identitystore.CredentialValidationResult.Status.NOT_VALIDATED;
+import static javax.security.enterprise.identitystore.CredentialValidationResult.Status.VALID;
+
+public class CredentialValidationResult {
+ public static final CredentialValidationResult INVALID_RESULT = new CredentialValidationResult(INVALID);
+ public static final CredentialValidationResult NOT_VALIDATED_RESULT = new CredentialValidationResult(NOT_VALIDATED);
+
+ private final Status status;
+ private final String storeId;
+ private final String callerDn;
+ private final String callerUniqueId;
+ private final CallerPrincipal callerPrincipal;
+ private final Set<String> groups;
+
+ public enum Status {
+ NOT_VALIDATED,
+ INVALID,
+ VALID
+ }
+
+ private CredentialValidationResult(Status status) {
+ this(status, null, null, null, null, null);
+ }
+
+ public CredentialValidationResult(String callerName) {
+ this(new CallerPrincipal(callerName), null);
+ }
+
+ public CredentialValidationResult(CallerPrincipal callerPrincipal) {
+ this(callerPrincipal, null);
+ }
+
+ public CredentialValidationResult(String callerName, Set<String> groups) {
+ this(new CallerPrincipal(callerName), groups);
+ }
+
+ public CredentialValidationResult(CallerPrincipal callerPrincipal, Set<String> groups) {
+ this(null, callerPrincipal, null, null, groups);
+ }
+
+ public CredentialValidationResult(String storeId, String callerName, String callerDn, String callerUniqueId,
+ Set<String> groups) {
+ this(storeId, new CallerPrincipal(callerName), callerDn, callerUniqueId, groups);
+ }
+
+ public CredentialValidationResult(String storeId, CallerPrincipal callerPrincipal, String callerDn,
+ String callerUniqueId, Set<String> groups) {
+ this(VALID, storeId, callerPrincipal, callerDn, callerUniqueId, groups);
+ }
+
+ private CredentialValidationResult(Status status, String storeId, CallerPrincipal callerPrincipal, String callerDn,
+ String callerUniqueId, Set<String> groups) {
+
+ if (status != VALID && (storeId != null || callerPrincipal != null ||
+ callerDn != null || callerUniqueId != null || groups != null)) {
+ throw new IllegalArgumentException("Bad status");
+ }
+ if (status == VALID && (callerPrincipal == null || callerPrincipal.getName().trim().isEmpty())) {
+ throw new IllegalArgumentException("Null or empty CallerPrincipal");
+ }
+
+ this.status = status;
+ this.storeId = storeId;
+ this.callerPrincipal = callerPrincipal;
+ this.callerDn = callerDn;
+ this.callerUniqueId = callerUniqueId;
+ this.groups = groups != null ? unmodifiableSet(new HashSet<>(groups)) : emptySet();
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public String getIdentityStoreId() {
+ return storeId;
+ }
+
+ public CallerPrincipal getCallerPrincipal() {
+ return callerPrincipal;
+ }
+
+ public String getCallerUniqueId() {
+ return callerUniqueId;
+ }
+
+ public String getCallerDn() {
+ return callerDn;
+ }
+
+ public Set<String> getCallerGroups() {
+ return groups;
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/DatabaseIdentityStoreDefinition.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/DatabaseIdentityStoreDefinition.java
new file mode 100644
index 0000000..2f3faa6
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/DatabaseIdentityStoreDefinition.java
@@ -0,0 +1,51 @@
+/*
+ * 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 javax.security.enterprise.identitystore;
+
+import javax.security.enterprise.identitystore.IdentityStore.ValidationType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static javax.security.enterprise.identitystore.IdentityStore.ValidationType.PROVIDE_GROUPS;
+import static javax.security.enterprise.identitystore.IdentityStore.ValidationType.VALIDATE;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface DatabaseIdentityStoreDefinition {
+ String dataSourceLookup() default "java:comp/DefaultDataSource";
+
+ String callerQuery() default "";
+
+ String groupsQuery() default "";
+
+ Class<? extends PasswordHash> hashAlgorithm() default Pbkdf2PasswordHash.class;
+
+ String[] hashAlgorithmParameters() default {};
+
+ int priority() default 70;
+
+ String priorityExpression() default "";
+
+ ValidationType[] useFor() default {
+ VALIDATE,
+ PROVIDE_GROUPS
+ };
+
+ String useForExpression() default "";
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/IdentityStore.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/IdentityStore.java
new file mode 100644
index 0000000..36d2538
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/IdentityStore.java
@@ -0,0 +1,61 @@
+/*
+ * 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 javax.security.enterprise.identitystore;
+
+import javax.security.enterprise.credential.Credential;
+import java.lang.invoke.MethodHandles;
+import java.util.EnumSet;
+import java.util.Set;
+
+import static java.lang.invoke.MethodType.methodType;
+import static java.util.Collections.emptySet;
+import static javax.security.enterprise.identitystore.CredentialValidationResult.NOT_VALIDATED_RESULT;
+import static javax.security.enterprise.identitystore.IdentityStore.ValidationType.PROVIDE_GROUPS;
+import static javax.security.enterprise.identitystore.IdentityStore.ValidationType.VALIDATE;
+
+public interface IdentityStore {
+ Set<ValidationType> DEFAULT_VALIDATION_TYPES = EnumSet.of(VALIDATE, PROVIDE_GROUPS);
+
+ default CredentialValidationResult validate(Credential credential) {
+ try {
+ return CredentialValidationResult.class.cast(
+ MethodHandles.lookup()
+ .bind(this, "validate", methodType(CredentialValidationResult.class, credential.getClass()))
+ .invoke(credential));
+ } catch (NoSuchMethodException e) {
+ return NOT_VALIDATED_RESULT;
+ } catch (Throwable e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ default Set<String> getCallerGroups(CredentialValidationResult validationResult) {
+ return emptySet();
+ }
+
+ default int priority() {
+ return 100;
+ }
+
+ default Set<ValidationType> validationTypes() {
+ return DEFAULT_VALIDATION_TYPES;
+ }
+
+ enum ValidationType {
+ VALIDATE, PROVIDE_GROUPS
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/IdentityStoreHandler.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/IdentityStoreHandler.java
new file mode 100644
index 0000000..4ce3049
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/IdentityStoreHandler.java
@@ -0,0 +1,23 @@
+/*
+ * 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 javax.security.enterprise.identitystore;
+
+import javax.security.enterprise.credential.Credential;
+
+public interface IdentityStoreHandler {
+ CredentialValidationResult validate(Credential credential);
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/IdentityStorePermission.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/IdentityStorePermission.java
new file mode 100644
index 0000000..a44fe50
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/IdentityStorePermission.java
@@ -0,0 +1,31 @@
+/*
+ * 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 javax.security.enterprise.identitystore;
+
+import java.security.BasicPermission;
+
+public class IdentityStorePermission extends BasicPermission {
+ private static final long serialVersionUID = 1254057022829640365L;
+
+ public IdentityStorePermission(String name) {
+ super(name);
+ }
+
+ public IdentityStorePermission(String name, String action) {
+ super(name, action);
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/IdentityStoreWrapper.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/IdentityStoreWrapper.java
new file mode 100644
index 0000000..113909a
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/IdentityStoreWrapper.java
@@ -0,0 +1,52 @@
+/*
+ * 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 javax.security.enterprise.identitystore;
+
+import javax.security.enterprise.credential.Credential;
+import java.util.Set;
+
+public class IdentityStoreWrapper implements IdentityStore {
+ private final IdentityStore identityStore;
+
+ public IdentityStoreWrapper(IdentityStore identityStore) {
+ this.identityStore = identityStore;
+ }
+
+ public IdentityStore getWrapped() {
+ return identityStore;
+ }
+
+ @Override
+ public CredentialValidationResult validate(Credential credential) {
+ return getWrapped().validate(credential);
+ }
+
+ @Override
+ public Set<String> getCallerGroups(CredentialValidationResult validationResult) {
+ return getWrapped().getCallerGroups(validationResult);
+ }
+
+ @Override
+ public int priority() {
+ return getWrapped().priority();
+ }
+
+ @Override
+ public Set<ValidationType> validationTypes() {
+ return getWrapped().validationTypes();
+ }
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/LdapIdentityStoreDefinition.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/LdapIdentityStoreDefinition.java
new file mode 100644
index 0000000..2a71657
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/LdapIdentityStoreDefinition.java
@@ -0,0 +1,85 @@
+/*
+ * 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 javax.security.enterprise.identitystore;
+
+import javax.security.enterprise.identitystore.IdentityStore.ValidationType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static javax.security.enterprise.identitystore.IdentityStore.ValidationType.PROVIDE_GROUPS;
+import static javax.security.enterprise.identitystore.IdentityStore.ValidationType.VALIDATE;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface LdapIdentityStoreDefinition {
+ enum LdapSearchScope {
+ ONE_LEVEL, SUBTREE
+ }
+
+ String url() default "";
+
+ String bindDn() default "";
+
+ String bindDnPassword() default "";
+
+ String callerBaseDn() default "";
+
+ String callerNameAttribute() default "uid";
+
+ String callerSearchBase() default "";
+
+ String callerSearchFilter() default "";
+
+ LdapSearchScope callerSearchScope() default LdapSearchScope.SUBTREE;
+
+ String callerSearchScopeExpression() default "";
+
+ String groupSearchBase() default "";
+
+ String groupSearchFilter() default "";
+
+ LdapSearchScope groupSearchScope() default LdapSearchScope.SUBTREE;
+
+ String groupSearchScopeExpression() default "";
+
+ String groupNameAttribute() default "cn";
+
+ String groupMemberAttribute() default "member";
+
+ String groupMemberOfAttribute() default "memberOf";
+
+ int readTimeout() default 0;
+
+ String readTimeoutExpression() default "";
+
+ int maxResults() default 1000;
+
+ String maxResultsExpression() default "";
+
+ int priority() default 80;
+
+ String priorityExpression() default "";
+
+ ValidationType[] useFor() default {
+ VALIDATE,
+ PROVIDE_GROUPS
+ };
+
+ String useForExpression() default "";
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/PasswordHash.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/PasswordHash.java
new file mode 100644
index 0000000..8bd5bdf
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/PasswordHash.java
@@ -0,0 +1,27 @@
+/*
+ * 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 javax.security.enterprise.identitystore;
+
+import java.util.Map;
+
+public interface PasswordHash {
+ default void initialize(Map<String, String> parameters) {}
+
+ String generate(char[] password);
+
+ boolean verify(char[] password, String hashedPassword);
+}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/Pbkdf2PasswordHash.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/Pbkdf2PasswordHash.java
new file mode 100644
index 0000000..9ed286f
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/Pbkdf2PasswordHash.java
@@ -0,0 +1,19 @@
+/*
+ * 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 javax.security.enterprise.identitystore;
+
+public interface Pbkdf2PasswordHash extends PasswordHash {}
diff --git a/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/RememberMeIdentityStore.java b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/RememberMeIdentityStore.java
new file mode 100644
index 0000000..257ebe7
--- /dev/null
+++ b/geronimo-security_1.0_spec/src/main/java/javax/security/enterprise/identitystore/RememberMeIdentityStore.java
@@ -0,0 +1,29 @@
+/*
+ * 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 javax.security.enterprise.identitystore;
+
+import javax.security.enterprise.CallerPrincipal;
+import javax.security.enterprise.credential.RememberMeCredential;
+import java.util.Set;
+
+public interface RememberMeIdentityStore {
+ CredentialValidationResult validate(RememberMeCredential credential);
+
+ String generateLoginToken(CallerPrincipal callerPrincipal, Set<String> groups);
+
+ void removeLoginToken(String token);
+}
diff --git a/pom.xml b/pom.xml
index f0ce31d..260fc55 100644
--- a/pom.xml
+++ b/pom.xml
@@ -172,7 +172,7 @@
<!-- Deployment 1.2 NONE -->
<!-- JACC 1.5 NONE -->
<!-- JASPIC 1.1 NONE -->
- <!-- Java EE Security API 1.0 NONE -->
+ <module>geronimo-security_1.0_spec</module>
<!-- DEBUG 1.0 NONE -->
<!-- JSTL 1.2 NONE -->
<!-- WS Metadata 2.1 NONE -->