You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by me...@apache.org on 2009/04/26 15:18:07 UTC
svn commit: r768701 - in /incubator/click/trunk/click: ./ examples/
examples/src/ examples/src/org/apache/click/examples/acegi/
examples/src/org/apache/click/examples/domain/
examples/src/org/apache/click/examples/page/
examples/src/org/apache/click/ex...
Author: medgar
Date: Sun Apr 26 13:18:06 2009
New Revision: 768701
URL: http://svn.apache.org/viewvc?rev=768701&view=rev
Log:
CLK-534 - added ACEGI security example
Added:
incubator/click/trunk/click/examples/src/org/apache/click/examples/acegi/
incubator/click/trunk/click/examples/src/org/apache/click/examples/acegi/UserDetailsAdaptor.java
incubator/click/trunk/click/examples/src/org/apache/click/examples/acegi/UserDetailsService.java
incubator/click/trunk/click/examples/src/org/apache/click/examples/acegi/package.html
incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/
incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/CreateAccountPage.java
incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/LoginPage.java
incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/LogoutPage.java
incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/NotAuthorizedPage.java
incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/secure/
incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/secure/SecurePage.java
incubator/click/trunk/click/examples/webapp/acegi/
incubator/click/trunk/click/examples/webapp/acegi/create-account.htm
incubator/click/trunk/click/examples/webapp/acegi/login.htm
incubator/click/trunk/click/examples/webapp/acegi/logout.htm
incubator/click/trunk/click/examples/webapp/acegi/not-authorized.htm
incubator/click/trunk/click/examples/webapp/acegi/secure/
incubator/click/trunk/click/examples/webapp/acegi/secure/secure.htm
Modified:
incubator/click/trunk/click/.classpath
incubator/click/trunk/click/examples/build.xml
incubator/click/trunk/click/examples/src/click-page.properties
incubator/click/trunk/click/examples/src/org/apache/click/examples/domain/PostCode.java
incubator/click/trunk/click/examples/src/org/apache/click/examples/page/SourceViewer.java
incubator/click/trunk/click/examples/src/org/apache/click/examples/service/UserService.java
incubator/click/trunk/click/examples/webapp/WEB-INF/lib/ (props changed)
incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml
incubator/click/trunk/click/examples/webapp/WEB-INF/spring-beans.xml
incubator/click/trunk/click/examples/webapp/WEB-INF/web.xml
incubator/click/trunk/click/examples/webapp/assets/css/style.css
Modified: incubator/click/trunk/click/.classpath
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/.classpath?rev=768701&r1=768700&r2=768701&view=diff
==============================================================================
--- incubator/click/trunk/click/.classpath (original)
+++ incubator/click/trunk/click/.classpath Sun Apr 26 13:18:06 2009
@@ -30,5 +30,6 @@
<classpathentry kind="lib" path="lib/spring-2.5.6.jar"/>
<classpathentry kind="lib" path="lib/velocity-1.6.2.jar"/>
<classpathentry kind="lib" path="examples/webapp/WEB-INF/lib/geronimo-annotation_1.0_spec-1.1.1.jar"/>
+ <classpathentry kind="lib" path="examples/webapp/WEB-INF/lib/acegi-security-1.0.7.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: incubator/click/trunk/click/examples/build.xml
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/build.xml?rev=768701&r1=768700&r2=768701&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/build.xml (original)
+++ incubator/click/trunk/click/examples/build.xml Sun Apr 26 13:18:06 2009
@@ -26,6 +26,7 @@
<property file="../build/build.properties"/>
<property name="name" value="click-examples"/>
+ <property name="jar.acegi" value="acegi-security-1.0.7.jar"/>
<property name="jar.annotation" value="geronimo-annotation_1.0_spec-1.1.1.jar"/>
<property name="jar.ashwood" value="ashwood-1.1.jar"/>
<property name="jar.cayenne" value="cayenne-nodeps-2.0.4.jar"/>
@@ -162,6 +163,10 @@
dest="${dir.weblib}/${jar.cayenne}"
verbose="true"
usetimestamp="true"/>
+ <get src="http://mirrors.ibiblio.org/pub/mirrors/maven2/org/acegisecurity/acegi-security/1.0.7/${jar.acegi}"
+ dest="${dir.weblib}/${jar.acegi}"
+ verbose="true"
+ usetimestamp="true"/>
<get src="http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/geronimo/specs/geronimo-annotation_1.0_spec/1.1.1/${jar.annotation}"
dest="${dir.weblib}/${jar.annotation}"
verbose="true"
Modified: incubator/click/trunk/click/examples/src/click-page.properties
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/click-page.properties?rev=768701&r1=768700&r2=768701&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/src/click-page.properties (original)
+++ incubator/click/trunk/click/examples/src/click-page.properties Sun Apr 26 13:18:06 2009
@@ -17,4 +17,6 @@
version=2.1.0
-invalid.form.submit=You have made an invalid form submission.
\ No newline at end of file
+invalid.form.submit=You have made an invalid form submission.
+
+usernameExistsError=Username already exists, please select another account username
\ No newline at end of file
Added: incubator/click/trunk/click/examples/src/org/apache/click/examples/acegi/UserDetailsAdaptor.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/acegi/UserDetailsAdaptor.java?rev=768701&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/acegi/UserDetailsAdaptor.java (added)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/acegi/UserDetailsAdaptor.java Sun Apr 26 13:18:06 2009
@@ -0,0 +1,62 @@
+/*
+ * 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.click.examples.acegi;
+
+import org.acegisecurity.GrantedAuthority;
+import org.acegisecurity.userdetails.UserDetails;
+import org.apache.click.examples.domain.User;
+
+public class UserDetailsAdaptor implements UserDetails {
+
+ private static final long serialVersionUID = 1L;
+
+ private final User user;
+
+ public UserDetailsAdaptor(User user) {
+ this.user = user;
+ }
+
+ public GrantedAuthority[] getAuthorities() {
+ return new GrantedAuthority[0];
+ }
+
+ public String getPassword() {
+ return user.getPassword();
+ }
+
+ public String getUsername() {
+ return user.getUsername();
+ }
+ public boolean isAccountNonExpired() {
+ return true;
+ }
+
+ public boolean isAccountNonLocked() {
+ return true;
+ }
+
+ public boolean isCredentialsNonExpired() {
+ return true;
+ }
+
+ public boolean isEnabled() {
+ return true;
+ }
+
+}
Added: incubator/click/trunk/click/examples/src/org/apache/click/examples/acegi/UserDetailsService.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/acegi/UserDetailsService.java?rev=768701&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/acegi/UserDetailsService.java (added)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/acegi/UserDetailsService.java Sun Apr 26 13:18:06 2009
@@ -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 org.apache.click.examples.acegi;
+
+import javax.annotation.Resource;
+
+import org.acegisecurity.userdetails.UserDetails;
+import org.acegisecurity.userdetails.UsernameNotFoundException;
+import org.apache.click.examples.domain.User;
+import org.apache.click.examples.service.UserService;
+import org.springframework.dao.DataAccessException;
+import org.springframework.stereotype.Component;
+
+@Component
+public class UserDetailsService implements org.acegisecurity.userdetails.UserDetailsService {
+
+ @Resource(name="userService")
+ private UserService userService;
+
+ /**
+ * @see org.acegisecurity.userdetails.UserDetailsService#loadUserByUsername(String)
+ */
+ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
+
+ User user = userService.getUser(username);
+
+ if (user != null) {
+ return new UserDetailsAdaptor(user);
+
+ } else {
+ throw new UsernameNotFoundException("UserDetailsService.loadUserByUsername()");
+ }
+ }
+
+}
Added: incubator/click/trunk/click/examples/src/org/apache/click/examples/acegi/package.html
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/acegi/package.html?rev=768701&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/acegi/package.html (added)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/acegi/package.html Sun Apr 26 13:18:06 2009
@@ -0,0 +1,22 @@
+<!--
+ 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.
+-->
+
+<body>
+Provides the Spring ACEGI Security example.
+</body>
\ No newline at end of file
Modified: incubator/click/trunk/click/examples/src/org/apache/click/examples/domain/PostCode.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/domain/PostCode.java?rev=768701&r1=768700&r2=768701&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/domain/PostCode.java (original)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/domain/PostCode.java Sun Apr 26 13:18:06 2009
@@ -22,4 +22,6 @@
public class PostCode extends _PostCode {
+ private static final long serialVersionUID = 1L;
+
}
Modified: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/SourceViewer.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/SourceViewer.java?rev=768701&r1=768700&r2=768701&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/SourceViewer.java (original)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/SourceViewer.java Sun Apr 26 13:18:06 2009
@@ -76,8 +76,9 @@
"login-config", "auth-method", "realm-name", "security-role",
"url-pattern", "welcome-file-list", "welcome-file", "Context",
"ResourceLink", "menu", "?xml", "controls", "control",
- "listener-class", "listener", "beans", "context-param",
- "context:component-scan" };
+ "listener-class", "listener", "beans", "bean", "context-param",
+ "context:component-scan", "property", "constructor-arg",
+ "list", "value", "ref" };
private static final String[] VELOCITY_KEYWORDS = { "#if", "#if(",
"#elseif", "#elseif(", "#else", "#else(", "#end", "#set", "#set(",
Added: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/CreateAccountPage.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/CreateAccountPage.java?rev=768701&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/CreateAccountPage.java (added)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/CreateAccountPage.java Sun Apr 26 13:18:06 2009
@@ -0,0 +1,136 @@
+/*
+ * 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.click.examples.page.acegi;
+
+import javax.annotation.Resource;
+
+import org.acegisecurity.Authentication;
+import org.acegisecurity.AuthenticationManager;
+import org.acegisecurity.context.SecurityContext;
+import org.acegisecurity.context.SecurityContextHolder;
+import org.acegisecurity.context.SecurityContextImpl;
+import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
+import org.apache.click.ActionListener;
+import org.apache.click.Control;
+import org.apache.click.control.Form;
+import org.apache.click.control.HiddenField;
+import org.apache.click.control.PasswordField;
+import org.apache.click.control.Submit;
+import org.apache.click.control.TextField;
+import org.apache.click.examples.domain.User;
+import org.apache.click.examples.page.BorderPage;
+import org.apache.click.examples.page.acegi.secure.SecurePage;
+import org.apache.click.examples.service.UserService;
+import org.apache.click.extras.control.EmailField;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CreateAccountPage extends BorderPage {
+
+ private Form form = new Form("form");
+ private TextField fullNameField = new TextField(User.FULLNAME_PROPERTY, "Full Name", true);
+ private EmailField emailField = new EmailField(User.EMAIL_PROPERTY);
+ private TextField userNameField = new TextField(User.USERNAME_PROPERTY, true);
+ private PasswordField passwordField = new PasswordField("password", true);
+ private PasswordField passwordAgainField = new PasswordField("passwordAgain", "Password again", true);
+ private HiddenField redirectField = new HiddenField("redirect", String.class);
+
+ @Resource(name="authenticationManager")
+ private AuthenticationManager authenticationManager;
+
+ @Resource(name="userService")
+ private UserService userService;
+
+ // Constructor ------------------------------------------------------------
+
+ public CreateAccountPage() {
+ addControl(form);
+
+ form.setDefaultFieldSize(30);
+
+ form.add(fullNameField);
+ form.add(emailField);
+ form.add(userNameField);
+ form.add(passwordField);
+ form.add(passwordAgainField);
+
+ Submit submit = new Submit("create");
+ submit.setActionListener(new ActionListener() {
+ public boolean onAction(Control source) {
+ return onCreate();
+ }
+ });
+ form.add(submit);
+
+ form.add(redirectField);
+ }
+
+ // Event Handlers ---------------------------------------------------------
+
+ @Override
+ public void onInit() {
+ super.onInit();
+
+ if (getContext().isGet()) {
+ redirectField.setValue(getContext().getRequestParameter("redirect"));
+ }
+ }
+
+ public boolean onCreate() {
+ if (form.isValid()) {
+
+ String fullName = fullNameField.getValue();
+ String email = emailField.getValue();
+ String username = userNameField.getValue();
+ String password1 = passwordField.getValue();
+ String password2 = passwordAgainField.getValue();
+
+ if (!password1.equals(password2)) {
+ passwordField.setError("Password and password again do not match");
+ return true;
+ }
+
+ User user = userService.getUser(username);
+
+ if (user != null) {
+ userNameField.setError(getMessage("usernameExistsError"));
+ return true;
+ }
+
+ user = userService.createUser(fullName, email, username, password1);
+
+ Authentication token = new UsernamePasswordAuthenticationToken(username, password1);
+ Authentication result = authenticationManager.authenticate(token);
+ SecurityContext securityContext = new SecurityContextImpl();
+ securityContext.setAuthentication(result);
+ SecurityContextHolder.setContext(securityContext);
+
+ String path = redirectField.getValue();
+ if (StringUtils.isNotBlank(path)) {
+ setRedirect(path);
+ } else {
+ setRedirect(SecurePage.class);
+ }
+ }
+
+ return true;
+ }
+
+}
Added: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/LoginPage.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/LoginPage.java?rev=768701&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/LoginPage.java (added)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/LoginPage.java Sun Apr 26 13:18:06 2009
@@ -0,0 +1,30 @@
+/*
+ * 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.click.examples.page.acegi;
+
+import org.apache.click.examples.page.BorderPage;
+
+/**
+ * Provides a ACEGI Security login page.
+ *
+ * @author Malcolm Edgar
+ */
+public class LoginPage extends BorderPage {
+
+}
Added: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/LogoutPage.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/LogoutPage.java?rev=768701&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/LogoutPage.java (added)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/LogoutPage.java Sun Apr 26 13:18:06 2009
@@ -0,0 +1,40 @@
+/*
+ * 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.click.examples.page.acegi;
+
+import org.apache.click.examples.page.BorderPage;
+import org.apache.click.examples.page.acegi.secure.SecurePage;
+
+/**
+ * Provides a ACEGI Security logout page.
+ *
+ * @author Malcolm Edgar
+ */
+public class LogoutPage extends BorderPage {
+
+ // Event Handlers ---------------------------------------------------------
+
+ @Override
+ public boolean onSecurityCheck() {
+ getContext().getSession().invalidate();
+ setRedirect(SecurePage.class);
+ return false;
+ }
+
+}
Added: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/NotAuthorizedPage.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/NotAuthorizedPage.java?rev=768701&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/NotAuthorizedPage.java (added)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/NotAuthorizedPage.java Sun Apr 26 13:18:06 2009
@@ -0,0 +1,30 @@
+/*
+ * 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.click.examples.page.acegi;
+
+import org.apache.click.examples.page.BorderPage;
+
+/**
+ * Provides a ACEGI Security logout page.
+ *
+ * @author Malcolm Edgar
+ */
+public class NotAuthorizedPage extends BorderPage {
+
+}
Added: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/secure/SecurePage.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/secure/SecurePage.java?rev=768701&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/secure/SecurePage.java (added)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/acegi/secure/SecurePage.java Sun Apr 26 13:18:06 2009
@@ -0,0 +1,7 @@
+package org.apache.click.examples.page.acegi.secure;
+
+import org.apache.click.examples.page.BorderPage;
+
+public class SecurePage extends BorderPage {
+
+}
Modified: incubator/click/trunk/click/examples/src/org/apache/click/examples/service/UserService.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/service/UserService.java?rev=768701&r1=768700&r2=768701&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/service/UserService.java (original)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/service/UserService.java Sun Apr 26 13:18:06 2009
@@ -45,4 +45,18 @@
public User getUser(String username) {
return (User) findObject(User.class, "username", username);
}
+
+ public User createUser(String fullName, String email, String username, String password) {
+ User user = new User();
+ getDataContext().registerNewObject(user);
+
+ user.setEmail(email);
+ user.setFullname(fullName);
+ user.setUsername(username);
+ user.setPassword(password);
+
+ commitChanges();
+
+ return user;
+ }
}
Propchange: incubator/click/trunk/click/examples/webapp/WEB-INF/lib/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sun Apr 26 13:18:06 2009
@@ -32,3 +32,4 @@
spring-core-2.5.4.jar
geronimo-annotation_1.0_spec-1.1.1.jar
spring-2.5.6.jar
+acegi-security-1.0.7.jar
Modified: incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml?rev=768701&r1=768700&r2=768701&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml (original)
+++ incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml Sun Apr 26 13:18:06 2009
@@ -43,7 +43,6 @@
<menu label="General" path="#" imageSrc="/assets/images/general.png">
<menu label="Direct Page" path="general/direct-page.htm"/>
- <menu label="Excel Export Page" path="general/excel-export.htm"/>
<menu label="Exception Demo" path="general/exception.htm"/>
<menu label="Flash Attribute" path="general/flash.htm"/>
<menu label="Page Imports" path="general/page-imports-example.htm"/>
@@ -135,9 +134,13 @@
<menu label="Reusable Panel" path="panel/reusable-panel-demo.htm"/>
</menu>
- <menu label=" Cayenne" path="#" imageSrc="/assets/images/cayenne.png">
- <menu label="CayenneForm" path="cayenne/cayenne-form-page.htm"/>
- <menu label="TabbedCayenneForm" path="cayenne/tabbed-cayenne-form-page.htm"/>
+ <menu label=" Integration" path="#" imageSrc="/assets/images/cayenne.png">
+ <menu label="ACEGI Security" path="acegi/secure/secure.htm"/>
+ <menu separator="true"/>
+ <menu label="Apache Cayenne Form" path="cayenne/cayenne-form-page.htm"/>
+ <menu label="Cayenne Tabbed Form" path="cayenne/tabbed-cayenne-form-page.htm"/>
+ <menu separator="true"/>
+ <menu label="Apache POI Excel Export" path="general/excel-export.htm"/>
</menu>
</menu>
Modified: incubator/click/trunk/click/examples/webapp/WEB-INF/spring-beans.xml
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/WEB-INF/spring-beans.xml?rev=768701&r1=768700&r2=768701&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/webapp/WEB-INF/spring-beans.xml (original)
+++ incubator/click/trunk/click/examples/webapp/WEB-INF/spring-beans.xml Sun Apr 26 13:18:06 2009
@@ -26,5 +26,91 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="org.apache.click.examples" scope-resolver="org.apache.click.extras.spring.PageScopeResolver"/>
+
+ <!-- ACEGI Security Beans -->
+
+ <bean id="filterChainProxy" class="org.acegisecurity.util.FilterChainProxy">
+ <property name="filterInvocationDefinitionSource">
+ <value><![CDATA[
+ CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
+ PATTERN_TYPE_APACHE_ANT
+ /**=httpSessionContextIntegrationFilter,logoutFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,exceptionTranslationFilter,filterInvocationInterceptor
+ ]]></value>
+ </property>
+ </bean>
+
+ <bean id="httpSessionContextIntegrationFilter" class="org.acegisecurity.context.HttpSessionContextIntegrationFilter" />
+
+ <bean id="logoutFilter" class="org.acegisecurity.ui.logout.LogoutFilter">
+ <constructor-arg value="/acegi/login.htm?logout=true" />
+ <constructor-arg>
+ <list>
+ <bean class="org.acegisecurity.ui.logout.SecurityContextLogoutHandler" />
+ </list>
+ </constructor-arg>
+ <property name="filterProcessesUrl" value="/j_acegi_logout" />
+ </bean>
+
+ <bean id="authenticationProcessingFilter" class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter">
+ <property name="authenticationManager" ref="authenticationManager" />
+ <property name="authenticationFailureUrl" value="/acegi/login.htm?auth-error=true" />
+ <property name="defaultTargetUrl" value="/" />
+ <property name="filterProcessesUrl" value="/j_acegi_security_check" />
+ </bean>
+
+ <bean id="securityContextHolderAwareRequestFilter" class="org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter" />
+
+ <bean id="exceptionTranslationFilter" class="org.acegisecurity.ui.ExceptionTranslationFilter">
+ <property name="authenticationEntryPoint">
+ <bean class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint">
+ <property name="loginFormUrl" value="/acegi/login.htm" />
+ <property name="forceHttps" value="false" />
+ </bean>
+ </property>
+ <property name="accessDeniedHandler">
+ <bean class="org.acegisecurity.ui.AccessDeniedHandlerImpl">
+ <property name="errorPage" value="/acegi/not-authorised.htm" />
+ </bean>
+ </property>
+ </bean>
+
+ <bean id="filterInvocationInterceptor" class="org.acegisecurity.intercept.web.FilterSecurityInterceptor">
+ <property name="authenticationManager" ref="authenticationManager" />
+ <property name="accessDecisionManager">
+ <bean class="org.acegisecurity.vote.AffirmativeBased">
+ <property name="allowIfAllAbstainDecisions" value="false" />
+ <property name="decisionVoters">
+ <list>
+ <bean class="org.acegisecurity.vote.RoleVoter" />
+ <bean class="org.acegisecurity.vote.AuthenticatedVoter" />
+ </list>
+ </property>
+ </bean>
+ </property>
+ <property name="objectDefinitionSource">
+ <value><![CDATA[
+ CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
+ PATTERN_TYPE_APACHE_ANT
+ /acegi/secure/**=IS_AUTHENTICATED_REMEMBERED
+ ]]></value>
+ </property>
+ </bean>
+
+ <bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager">
+ <property name="providers">
+ <list>
+ <ref local="daoAuthenticationProvider" />
+ </list>
+ </property>
+ </bean>
+
+ <bean id="userDetailsService" class="org.apache.click.examples.acegi.UserDetailsService"/>
+
+ <bean id="daoAuthenticationProvider" class="org.acegisecurity.providers.dao.DaoAuthenticationProvider">
+ <property name="userDetailsService" ref="userDetailsService" />
+ </bean>
+
+ <!-- This bean is optional; it isn't used by any other bean as it only listens and logs -->
+ <bean id="loggerListener" class="org.acegisecurity.event.authentication.LoggerListener" />
</beans>
\ No newline at end of file
Modified: incubator/click/trunk/click/examples/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/WEB-INF/web.xml?rev=768701&r1=768700&r2=768701&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/webapp/WEB-INF/web.xml (original)
+++ incubator/click/trunk/click/examples/webapp/WEB-INF/web.xml Sun Apr 26 13:18:06 2009
@@ -75,6 +75,23 @@
<param-value>*/excel-export.htm</param-value>
</init-param>
</filter>
+
+ <!--
+ Provides a ACEGI Security filter.
+ -->
+ <filter>
+ <filter-name>FilterToBeanProxy</filter-name>
+ <filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class>
+ <init-param>
+ <param-name>targetClass</param-name>
+ <param-value>org.acegisecurity.util.FilterChainProxy</param-value>
+ </init-param>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>FilterToBeanProxy</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
<filter-mapping>
<filter-name>DatabaseInitFilter</filter-name>
Added: incubator/click/trunk/click/examples/webapp/acegi/create-account.htm
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/acegi/create-account.htm?rev=768701&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/webapp/acegi/create-account.htm (added)
+++ incubator/click/trunk/click/examples/webapp/acegi/create-account.htm Sun Apr 26 13:18:06 2009
@@ -0,0 +1,30 @@
+<!--
+#* 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.*#
+-->
+
+<center>
+
+<div class="dialogForm" style="width:300px;">
+
+<div style="font-weight:bold;font-size:10pt;text-align:left;">Create Account</div>
+
+$form
+
+</div>
+
+</center>
Added: incubator/click/trunk/click/examples/webapp/acegi/login.htm
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/acegi/login.htm?rev=768701&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/webapp/acegi/login.htm (added)
+++ incubator/click/trunk/click/examples/webapp/acegi/login.htm Sun Apr 26 13:18:06 2009
@@ -0,0 +1,79 @@
+<!--
+#* 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.*#
+-->
+
+<center>
+
+<div class="dialogForm" style="width:305px;">
+
+<form method="post" action="$context/j_acegi_security_check" name="form">
+<table class="login" border="0" width="100%">
+ <tr>
+#if ($request.getParameter("auth-error"))
+ <td colspan="3" style="color:red">
+ Invalid Username or Password, please try again.<br/>Please ensure Caps Lock is off.
+ </td>
+#else
+ <td colspan="3" style="font-weight:bold;font-size:10pt;">Please login</td>
+#end
+ <td width="100%"> </td>
+ </tr>
+ <tr>
+ <td colspan="4"> </td>
+ </tr>
+ <tr>
+ <td><label>Username</label></td>
+ <td><input type="text" name="j_username" style="width:200px;"/></td>
+ <td> </td>
+ <td width="100%"> </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:middle;"><label>Password</label></td>
+ <td style="vertical-align:middle;"><input type="password" name="j_password" style="width:200px;"/></td>
+ <td style="vertical-align:middle;"><input type="image" src="$context/assets/images/intro.png" title="Click to Login"/></td>
+ <td width="100%"> </td>
+ </tr>
+</table>
+</form>
+
+<script type="text/javascript">
+ document.form.j_username.focus();
+</script>
+
+</div>
+
+
+<div class="dialogForm" style="width:305px;margin-top:40px;">
+
+<table class="login" border="0" width="100%">
+ <tr>
+ <td colspan="4" style="white-space:nowrap;color:#404040;">
+ New to Click Examples? It's free and easy.
+ </td>
+ </tr>
+ <tr>
+ <td colspan="4" style="padding-top:15px;">
+ <input type="button" style="font-weight:bold;" value="Create an account »" onclick="javascript:document.location.href='${context}/acegi/create-account.htm';"/>
+ </td>
+ </tr>
+</table>
+
+</div>
+
+
+</center>
Added: incubator/click/trunk/click/examples/webapp/acegi/logout.htm
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/acegi/logout.htm?rev=768701&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/webapp/acegi/logout.htm (added)
+++ incubator/click/trunk/click/examples/webapp/acegi/logout.htm Sun Apr 26 13:18:06 2009
@@ -0,0 +1,18 @@
+<!--
+#* 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.*#
+-->
\ No newline at end of file
Added: incubator/click/trunk/click/examples/webapp/acegi/not-authorized.htm
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/acegi/not-authorized.htm?rev=768701&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/webapp/acegi/not-authorized.htm (added)
+++ incubator/click/trunk/click/examples/webapp/acegi/not-authorized.htm Sun Apr 26 13:18:06 2009
@@ -0,0 +1,30 @@
+<!--
+#* 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.*#
+-->
+
+<center>
+
+<div class="dialogForm" style="width:300px;">
+
+<div style="font-weight:bold;font-size:10pt;text-align:left;color:red;">
+You are not authorized to access this page.
+</div>
+
+</div>
+
+</center>
Added: incubator/click/trunk/click/examples/webapp/acegi/secure/secure.htm
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/acegi/secure/secure.htm?rev=768701&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/webapp/acegi/secure/secure.htm (added)
+++ incubator/click/trunk/click/examples/webapp/acegi/secure/secure.htm Sun Apr 26 13:18:06 2009
@@ -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.*#
+-->
+
+<p>
+You are now logged into an <a class="external" target="_blank" href="http://www.acegisecurity.org/">ACEGI Security</a> protected page.
+To logout click <a href="$context/acegi/logout.htm">here</a>.
+</p>
+
+<p>
+ACEGI security is provided by a <tt>FilterToBeanProxy</tt> filter configured in
+<a target="_blank" href="$context/source-viewer.htm?filename=WEB-INF/web.xml">web.xml</a>,
+which is itself configured using Spring beans in the
+<a target="_blank" href="$context/source-viewer.htm?filename=WEB-INF/spring-beans.xml">spring-bean.xml</a>
+file.
+</p>
\ No newline at end of file
Modified: incubator/click/trunk/click/examples/webapp/assets/css/style.css
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/assets/css/style.css?rev=768701&r1=768700&r2=768701&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/webapp/assets/css/style.css (original)
+++ incubator/click/trunk/click/examples/webapp/assets/css/style.css Sun Apr 26 13:18:06 2009
@@ -236,3 +236,17 @@
.menustyle img.link {
margin-right: 2px;
}
+
+/*
+ * ACEGI example style.
+ */
+div.dialogForm {
+ background-color: #f0f0f0;
+ width: 305px;
+ margin-top: 100px;
+ padding: 20px 20px 20px 20px;
+ border-top: 1px solid #e0e0e0;
+ border-left: 1px solid #e0e0e0;
+ border-bottom: 1px solid #c0c0c0;
+ border-right: 1px solid #c0c0c0;
+}