SEC-51 and SEC-67 related changes. Tested all functions of "filters" version in web browser OK.
This commit is contained in:
parent
9be82a3d8f
commit
2d74db9a0c
|
@ -87,7 +87,7 @@ public class ContactManagerBackend extends ApplicationObjectSupport
|
||||||
|
|
||||||
@Secured ({"ROLE_USER","AFTER_ACL_READ"})
|
@Secured ({"ROLE_USER","AFTER_ACL_READ"})
|
||||||
@Transactional(readOnly=true)
|
@Transactional(readOnly=true)
|
||||||
public Contact getById(Integer id) {
|
public Contact getById(Long id) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Returning contact with id: " + id);
|
logger.debug("Returning contact with id: " + id);
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ public class ContactManagerBackend extends ApplicationObjectSupport
|
||||||
@Secured ({"ROLE_USER"})
|
@Secured ({"ROLE_USER"})
|
||||||
public void create(Contact contact) {
|
public void create(Contact contact) {
|
||||||
// Create the Contact itself
|
// Create the Contact itself
|
||||||
contact.setId(new Integer(counter++));
|
contact.setId(new Long(counter++));
|
||||||
contactDao.create(contact);
|
contactDao.create(contact);
|
||||||
|
|
||||||
// Grant the current principal access to the contact
|
// Grant the current principal access to the contact
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright 2004 Acegi Technology Pty Limited
|
/* Copyright 2004, 2005 Acegi Technology Pty Limited
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -21,13 +21,14 @@ import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
|
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import org.springframework.validation.BindException;
|
import org.springframework.validation.BindException;
|
||||||
|
|
||||||
import org.springframework.web.bind.RequestUtils;
|
import org.springframework.web.bind.RequestUtils;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||||
import org.springframework.web.servlet.view.RedirectView;
|
import org.springframework.web.servlet.view.RedirectView;
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -61,7 +62,8 @@ public class AddPermissionController extends SimpleFormController
|
||||||
}
|
}
|
||||||
|
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
Assert.notNull(contactManager, "A ContactManager implementation is required");
|
Assert.notNull(contactManager,
|
||||||
|
"A ContactManager implementation is required");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ModelAndView disallowDuplicateFormSubmission(
|
protected ModelAndView disallowDuplicateFormSubmission(
|
||||||
|
@ -80,7 +82,7 @@ public class AddPermissionController extends SimpleFormController
|
||||||
int contactId = RequestUtils.getRequiredIntParameter(request,
|
int contactId = RequestUtils.getRequiredIntParameter(request,
|
||||||
"contactId");
|
"contactId");
|
||||||
|
|
||||||
Contact contact = contactManager.getById(new Integer(contactId));
|
Contact contact = contactManager.getById(new Long(contactId));
|
||||||
|
|
||||||
AddPermission addPermission = new AddPermission();
|
AddPermission addPermission = new AddPermission();
|
||||||
addPermission.setContact(contact);
|
addPermission.setContact(contact);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright 2004 Acegi Technology Pty Limited
|
/* Copyright 2004, 2005 Acegi Technology Pty Limited
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,10 +20,11 @@ import net.sf.acegisecurity.acl.AclManager;
|
||||||
|
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import org.springframework.web.bind.RequestUtils;
|
import org.springframework.web.bind.RequestUtils;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import org.springframework.web.servlet.mvc.Controller;
|
import org.springframework.web.servlet.mvc.Controller;
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -66,7 +67,8 @@ public class AdminPermissionController implements Controller, InitializingBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
Assert.notNull(contactManager, "A ContactManager implementation is required");
|
Assert.notNull(contactManager,
|
||||||
|
"A ContactManager implementation is required");
|
||||||
Assert.notNull(aclManager, "An aclManager implementation is required");
|
Assert.notNull(aclManager, "An aclManager implementation is required");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +76,7 @@ public class AdminPermissionController implements Controller, InitializingBean {
|
||||||
HttpServletResponse response) throws ServletException, IOException {
|
HttpServletResponse response) throws ServletException, IOException {
|
||||||
int id = RequestUtils.getRequiredIntParameter(request, "contactId");
|
int id = RequestUtils.getRequiredIntParameter(request, "contactId");
|
||||||
|
|
||||||
Contact contact = contactManager.getById(new Integer(id));
|
Contact contact = contactManager.getById(new Long(id));
|
||||||
AclEntry[] acls = aclManager.getAcls(contact);
|
AclEntry[] acls = aclManager.getAcls(contact);
|
||||||
|
|
||||||
Map model = new HashMap();
|
Map model = new HashMap();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright 2004 Acegi Technology Pty Limited
|
/* Copyright 2004, 2005 Acegi Technology Pty Limited
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -27,7 +27,7 @@ import java.io.Serializable;
|
||||||
public class Contact implements Serializable {
|
public class Contact implements Serializable {
|
||||||
//~ Instance fields ========================================================
|
//~ Instance fields ========================================================
|
||||||
|
|
||||||
private Integer id;
|
private Long id;
|
||||||
private String email;
|
private String email;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public class Contact implements Serializable {
|
||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Integer id) {
|
public void setId(Long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public class Contact implements Serializable {
|
||||||
*
|
*
|
||||||
* @return Returns the id.
|
* @return Returns the id.
|
||||||
*/
|
*/
|
||||||
public Integer getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright 2004 Acegi Technology Pty Limited
|
/* Copyright 2004, 2005 Acegi Technology Pty Limited
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -27,11 +27,11 @@ import java.util.List;
|
||||||
public interface ContactDao {
|
public interface ContactDao {
|
||||||
//~ Methods ================================================================
|
//~ Methods ================================================================
|
||||||
|
|
||||||
public Contact getById(Integer id);
|
public Contact getById(Long id);
|
||||||
|
|
||||||
public void create(Contact contact);
|
public void create(Contact contact);
|
||||||
|
|
||||||
public void delete(Integer contactId);
|
public void delete(Long contactId);
|
||||||
|
|
||||||
public List findAll();
|
public List findAll();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright 2004 Acegi Technology Pty Limited
|
/* Copyright 2004, 2005 Acegi Technology Pty Limited
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -48,8 +48,8 @@ public class ContactDaoSpring extends JdbcDaoSupport implements ContactDao {
|
||||||
|
|
||||||
//~ Methods ================================================================
|
//~ Methods ================================================================
|
||||||
|
|
||||||
public Contact getById(Integer id) {
|
public Contact getById(Long id) {
|
||||||
List list = contactsByIdQuery.execute(id.intValue());
|
List list = contactsByIdQuery.execute(id.longValue());
|
||||||
|
|
||||||
if (list.size() == 0) {
|
if (list.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -59,10 +59,12 @@ public class ContactDaoSpring extends JdbcDaoSupport implements ContactDao {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void create(Contact contact) {
|
public void create(Contact contact) {
|
||||||
|
System.out.println("creating contact w/ id " + contact.getId() + " "
|
||||||
|
+ contact.getEmail());
|
||||||
contactInsert.insert(contact);
|
contactInsert.insert(contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(Integer contactId) {
|
public void delete(Long contactId) {
|
||||||
contactDelete.delete(contactId);
|
contactDelete.delete(contactId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,14 +111,14 @@ public class ContactDaoSpring extends JdbcDaoSupport implements ContactDao {
|
||||||
|
|
||||||
protected Object mapRow(ResultSet rs, int rownum)
|
protected Object mapRow(ResultSet rs, int rownum)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
return new Integer(rs.getInt("id"));
|
return new Long(rs.getLong("id"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class AclObjectIdentityInsert extends SqlUpdate {
|
protected class AclObjectIdentityInsert extends SqlUpdate {
|
||||||
protected AclObjectIdentityInsert(DataSource ds) {
|
protected AclObjectIdentityInsert(DataSource ds) {
|
||||||
super(ds, "INSERT INTO acl_object_identity VALUES (?, ?, ?, ?)");
|
super(ds, "INSERT INTO acl_object_identity VALUES (?, ?, ?, ?)");
|
||||||
declareParameter(new SqlParameter(Types.INTEGER));
|
declareParameter(new SqlParameter(Types.BIGINT));
|
||||||
declareParameter(new SqlParameter(Types.VARCHAR));
|
declareParameter(new SqlParameter(Types.VARCHAR));
|
||||||
declareParameter(new SqlParameter(Types.INTEGER));
|
declareParameter(new SqlParameter(Types.INTEGER));
|
||||||
declareParameter(new SqlParameter(Types.VARCHAR));
|
declareParameter(new SqlParameter(Types.VARCHAR));
|
||||||
|
@ -124,7 +126,7 @@ public class ContactDaoSpring extends JdbcDaoSupport implements ContactDao {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int insert(String objectIdentity,
|
protected int insert(String objectIdentity,
|
||||||
Integer parentAclObjectIdentity, String aclClass) {
|
Long parentAclObjectIdentity, String aclClass) {
|
||||||
Object[] objs = new Object[] {null, objectIdentity, parentAclObjectIdentity, aclClass};
|
Object[] objs = new Object[] {null, objectIdentity, parentAclObjectIdentity, aclClass};
|
||||||
super.update(objs);
|
super.update(objs);
|
||||||
|
|
||||||
|
@ -135,19 +137,19 @@ public class ContactDaoSpring extends JdbcDaoSupport implements ContactDao {
|
||||||
protected class ContactDelete extends SqlUpdate {
|
protected class ContactDelete extends SqlUpdate {
|
||||||
protected ContactDelete(DataSource ds) {
|
protected ContactDelete(DataSource ds) {
|
||||||
super(ds, "DELETE FROM contacts WHERE id = ?");
|
super(ds, "DELETE FROM contacts WHERE id = ?");
|
||||||
declareParameter(new SqlParameter(Types.INTEGER));
|
declareParameter(new SqlParameter(Types.BIGINT));
|
||||||
compile();
|
compile();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void delete(Integer contactId) {
|
protected void delete(Long contactId) {
|
||||||
super.update(contactId.intValue());
|
super.update(contactId.longValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class ContactInsert extends SqlUpdate {
|
protected class ContactInsert extends SqlUpdate {
|
||||||
protected ContactInsert(DataSource ds) {
|
protected ContactInsert(DataSource ds) {
|
||||||
super(ds, "INSERT INTO contacts VALUES (?, ?, ?)");
|
super(ds, "INSERT INTO contacts VALUES (?, ?, ?)");
|
||||||
declareParameter(new SqlParameter(Types.INTEGER));
|
declareParameter(new SqlParameter(Types.BIGINT));
|
||||||
declareParameter(new SqlParameter(Types.VARCHAR));
|
declareParameter(new SqlParameter(Types.VARCHAR));
|
||||||
declareParameter(new SqlParameter(Types.VARCHAR));
|
declareParameter(new SqlParameter(Types.VARCHAR));
|
||||||
compile();
|
compile();
|
||||||
|
@ -166,7 +168,7 @@ public class ContactDaoSpring extends JdbcDaoSupport implements ContactDao {
|
||||||
"UPDATE contacts SET contact_name = ?, address = ? WHERE id = ?");
|
"UPDATE contacts SET contact_name = ?, address = ? WHERE id = ?");
|
||||||
declareParameter(new SqlParameter(Types.VARCHAR));
|
declareParameter(new SqlParameter(Types.VARCHAR));
|
||||||
declareParameter(new SqlParameter(Types.VARCHAR));
|
declareParameter(new SqlParameter(Types.VARCHAR));
|
||||||
declareParameter(new SqlParameter(Types.INTEGER));
|
declareParameter(new SqlParameter(Types.BIGINT));
|
||||||
compile();
|
compile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +188,7 @@ public class ContactDaoSpring extends JdbcDaoSupport implements ContactDao {
|
||||||
protected Object mapRow(ResultSet rs, int rownum)
|
protected Object mapRow(ResultSet rs, int rownum)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
Contact contact = new Contact();
|
Contact contact = new Contact();
|
||||||
contact.setId(new Integer(rs.getInt("id")));
|
contact.setId(new Long(rs.getLong("id")));
|
||||||
contact.setName(rs.getString("contact_name"));
|
contact.setName(rs.getString("contact_name"));
|
||||||
contact.setEmail(rs.getString("email"));
|
contact.setEmail(rs.getString("email"));
|
||||||
|
|
||||||
|
@ -198,14 +200,14 @@ public class ContactDaoSpring extends JdbcDaoSupport implements ContactDao {
|
||||||
protected ContactsByIdQuery(DataSource ds) {
|
protected ContactsByIdQuery(DataSource ds) {
|
||||||
super(ds,
|
super(ds,
|
||||||
"SELECT id, contact_name, email FROM contacts WHERE id = ? ORDER BY id");
|
"SELECT id, contact_name, email FROM contacts WHERE id = ? ORDER BY id");
|
||||||
declareParameter(new SqlParameter(Types.INTEGER));
|
declareParameter(new SqlParameter(Types.BIGINT));
|
||||||
compile();
|
compile();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object mapRow(ResultSet rs, int rownum)
|
protected Object mapRow(ResultSet rs, int rownum)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
Contact contact = new Contact();
|
Contact contact = new Contact();
|
||||||
contact.setId(new Integer(rs.getInt("id")));
|
contact.setId(new Long(rs.getLong("id")));
|
||||||
contact.setName(rs.getString("contact_name"));
|
contact.setName(rs.getString("contact_name"));
|
||||||
contact.setEmail(rs.getString("email"));
|
contact.setEmail(rs.getString("email"));
|
||||||
|
|
||||||
|
@ -217,12 +219,12 @@ public class ContactDaoSpring extends JdbcDaoSupport implements ContactDao {
|
||||||
protected PermissionDelete(DataSource ds) {
|
protected PermissionDelete(DataSource ds) {
|
||||||
super(ds,
|
super(ds,
|
||||||
"DELETE FROM acl_permission WHERE ACL_OBJECT_IDENTITY = ? AND RECIPIENT = ?");
|
"DELETE FROM acl_permission WHERE ACL_OBJECT_IDENTITY = ? AND RECIPIENT = ?");
|
||||||
declareParameter(new SqlParameter(Types.INTEGER));
|
declareParameter(new SqlParameter(Types.BIGINT));
|
||||||
declareParameter(new SqlParameter(Types.VARCHAR));
|
declareParameter(new SqlParameter(Types.VARCHAR));
|
||||||
compile();
|
compile();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void delete(Integer aclObjectIdentity, String recipient) {
|
protected void delete(Long aclObjectIdentity, String recipient) {
|
||||||
super.update(new Object[] {aclObjectIdentity, recipient});
|
super.update(new Object[] {aclObjectIdentity, recipient});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,14 +232,14 @@ public class ContactDaoSpring extends JdbcDaoSupport implements ContactDao {
|
||||||
protected class PermissionInsert extends SqlUpdate {
|
protected class PermissionInsert extends SqlUpdate {
|
||||||
protected PermissionInsert(DataSource ds) {
|
protected PermissionInsert(DataSource ds) {
|
||||||
super(ds, "INSERT INTO acl_permission VALUES (?, ?, ?, ?);");
|
super(ds, "INSERT INTO acl_permission VALUES (?, ?, ?, ?);");
|
||||||
declareParameter(new SqlParameter(Types.INTEGER));
|
declareParameter(new SqlParameter(Types.BIGINT));
|
||||||
declareParameter(new SqlParameter(Types.INTEGER));
|
declareParameter(new SqlParameter(Types.BIGINT));
|
||||||
declareParameter(new SqlParameter(Types.VARCHAR));
|
declareParameter(new SqlParameter(Types.VARCHAR));
|
||||||
declareParameter(new SqlParameter(Types.INTEGER));
|
declareParameter(new SqlParameter(Types.INTEGER));
|
||||||
compile();
|
compile();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int insert(Integer aclObjectIdentity, String recipient,
|
protected int insert(Long aclObjectIdentity, String recipient,
|
||||||
Integer mask) {
|
Integer mask) {
|
||||||
Object[] objs = new Object[] {null, aclObjectIdentity, recipient, mask};
|
Object[] objs = new Object[] {null, aclObjectIdentity, recipient, mask};
|
||||||
super.update(objs);
|
super.update(objs);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright 2004 Acegi Technology Pty Limited
|
/* Copyright 2004, 2005 Acegi Technology Pty Limited
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -31,7 +31,7 @@ public interface ContactManager {
|
||||||
|
|
||||||
public List getAllRecipients();
|
public List getAllRecipients();
|
||||||
|
|
||||||
public Contact getById(Integer id);
|
public Contact getById(Long id);
|
||||||
|
|
||||||
public Contact getRandomContact();
|
public Contact getRandomContact();
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class ContactManagerBackend extends ApplicationObjectSupport
|
||||||
|
|
||||||
private BasicAclExtendedDao basicAclExtendedDao;
|
private BasicAclExtendedDao basicAclExtendedDao;
|
||||||
private ContactDao contactDao;
|
private ContactDao contactDao;
|
||||||
private int counter = 100;
|
private int counter = 1000;
|
||||||
|
|
||||||
//~ Methods ================================================================
|
//~ Methods ================================================================
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ public class ContactManagerBackend extends ApplicationObjectSupport
|
||||||
return basicAclExtendedDao;
|
return basicAclExtendedDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Contact getById(Integer id) {
|
public Contact getById(Long id) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Returning contact with id: " + id);
|
logger.debug("Returning contact with id: " + id);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ public class ContactManagerBackend extends ApplicationObjectSupport
|
||||||
|
|
||||||
public void create(Contact contact) {
|
public void create(Contact contact) {
|
||||||
// Create the Contact itself
|
// Create the Contact itself
|
||||||
contact.setId(new Integer(counter++));
|
contact.setId(new Long(counter++));
|
||||||
contactDao.create(contact);
|
contactDao.create(contact);
|
||||||
|
|
||||||
// Grant the current principal access to the contact
|
// Grant the current principal access to the contact
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class DataSourcePopulator implements InitializingBean {
|
||||||
JdbcTemplate template = new JdbcTemplate(dataSource);
|
JdbcTemplate template = new JdbcTemplate(dataSource);
|
||||||
|
|
||||||
template.execute(
|
template.execute(
|
||||||
"CREATE TABLE CONTACTS(ID INTEGER NOT NULL PRIMARY KEY, CONTACT_NAME VARCHAR_IGNORECASE(50) NOT NULL, EMAIL VARCHAR_IGNORECASE(50) NOT NULL)");
|
"CREATE TABLE CONTACTS(ID BIGINT NOT NULL PRIMARY KEY, CONTACT_NAME VARCHAR_IGNORECASE(50) NOT NULL, EMAIL VARCHAR_IGNORECASE(50) NOT NULL)");
|
||||||
template.execute(
|
template.execute(
|
||||||
"INSERT INTO contacts VALUES (1, 'John Smith', 'john@somewhere.com');"); // marissa
|
"INSERT INTO contacts VALUES (1, 'John Smith', 'john@somewhere.com');"); // marissa
|
||||||
template.execute(
|
template.execute(
|
||||||
|
@ -93,7 +93,7 @@ public class DataSourcePopulator implements InitializingBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
template.execute(
|
template.execute(
|
||||||
"CREATE TABLE ACL_OBJECT_IDENTITY(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 100) NOT NULL PRIMARY KEY,OBJECT_IDENTITY VARCHAR_IGNORECASE(250) NOT NULL,PARENT_OBJECT INTEGER,ACL_CLASS VARCHAR_IGNORECASE(250) NOT NULL,CONSTRAINT UNIQUE_OBJECT_IDENTITY UNIQUE(OBJECT_IDENTITY),CONSTRAINT SYS_FK_3 FOREIGN KEY(PARENT_OBJECT) REFERENCES ACL_OBJECT_IDENTITY(ID))");
|
"CREATE TABLE ACL_OBJECT_IDENTITY(ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 100) NOT NULL PRIMARY KEY,OBJECT_IDENTITY VARCHAR_IGNORECASE(250) NOT NULL,PARENT_OBJECT BIGINT,ACL_CLASS VARCHAR_IGNORECASE(250) NOT NULL,CONSTRAINT UNIQUE_OBJECT_IDENTITY UNIQUE(OBJECT_IDENTITY),CONSTRAINT SYS_FK_3 FOREIGN KEY(PARENT_OBJECT) REFERENCES ACL_OBJECT_IDENTITY(ID))");
|
||||||
template.execute(
|
template.execute(
|
||||||
"INSERT INTO acl_object_identity VALUES (1, 'sample.contact.Contact:1', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
"INSERT INTO acl_object_identity VALUES (1, 'sample.contact.Contact:1', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
||||||
template.execute(
|
template.execute(
|
||||||
|
@ -120,7 +120,7 @@ public class DataSourcePopulator implements InitializingBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
template.execute(
|
template.execute(
|
||||||
"CREATE TABLE ACL_PERMISSION(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 100) NOT NULL PRIMARY KEY,ACL_OBJECT_IDENTITY INTEGER NOT NULL,RECIPIENT VARCHAR_IGNORECASE(100) NOT NULL,MASK INTEGER NOT NULL,CONSTRAINT UNIQUE_RECIPIENT UNIQUE(ACL_OBJECT_IDENTITY,RECIPIENT),CONSTRAINT SYS_FK_7 FOREIGN KEY(ACL_OBJECT_IDENTITY) REFERENCES ACL_OBJECT_IDENTITY(ID))");
|
"CREATE TABLE ACL_PERMISSION(ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 100) NOT NULL PRIMARY KEY,ACL_OBJECT_IDENTITY BIGINT NOT NULL,RECIPIENT VARCHAR_IGNORECASE(100) NOT NULL,MASK INTEGER NOT NULL,CONSTRAINT UNIQUE_RECIPIENT UNIQUE(ACL_OBJECT_IDENTITY,RECIPIENT),CONSTRAINT SYS_FK_7 FOREIGN KEY(ACL_OBJECT_IDENTITY) REFERENCES ACL_OBJECT_IDENTITY(ID))");
|
||||||
template.execute(
|
template.execute(
|
||||||
"INSERT INTO acl_permission VALUES (null, 1, 'marissa', 1);"); // administer
|
"INSERT INTO acl_permission VALUES (null, 1, 'marissa', 1);"); // administer
|
||||||
template.execute(
|
template.execute(
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright 2004 Acegi Technology Pty Limited
|
/* Copyright 2004, 2005 Acegi Technology Pty Limited
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -17,10 +17,11 @@ package sample.contact;
|
||||||
|
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import org.springframework.web.bind.RequestUtils;
|
import org.springframework.web.bind.RequestUtils;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import org.springframework.web.servlet.mvc.Controller;
|
import org.springframework.web.servlet.mvc.Controller;
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -51,13 +52,14 @@ public class DeleteController implements Controller, InitializingBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
Assert.notNull(contactManager, "A ContactManager implementation is required");
|
Assert.notNull(contactManager,
|
||||||
|
"A ContactManager implementation is required");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelAndView handleRequest(HttpServletRequest request,
|
public ModelAndView handleRequest(HttpServletRequest request,
|
||||||
HttpServletResponse response) throws ServletException, IOException {
|
HttpServletResponse response) throws ServletException, IOException {
|
||||||
int id = RequestUtils.getRequiredIntParameter(request, "contactId");
|
int id = RequestUtils.getRequiredIntParameter(request, "contactId");
|
||||||
Contact contact = contactManager.getById(new Integer(id));
|
Contact contact = contactManager.getById(new Long(id));
|
||||||
contactManager.delete(contact);
|
contactManager.delete(contact);
|
||||||
|
|
||||||
return new ModelAndView("deleted", "contact", contact);
|
return new ModelAndView("deleted", "contact", contact);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright 2004 Acegi Technology Pty Limited
|
/* Copyright 2004, 2005 Acegi Technology Pty Limited
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -19,10 +19,11 @@ import net.sf.acegisecurity.acl.AclManager;
|
||||||
|
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import org.springframework.web.bind.RequestUtils;
|
import org.springframework.web.bind.RequestUtils;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import org.springframework.web.servlet.mvc.Controller;
|
import org.springframework.web.servlet.mvc.Controller;
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -65,7 +66,8 @@ public class DeletePermissionController implements Controller, InitializingBean
|
||||||
}
|
}
|
||||||
|
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
Assert.notNull(contactManager, "A ContactManager implementation is required");
|
Assert.notNull(contactManager,
|
||||||
|
"A ContactManager implementation is required");
|
||||||
Assert.notNull(aclManager, "An aclManager implementation is required");
|
Assert.notNull(aclManager, "An aclManager implementation is required");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +78,7 @@ public class DeletePermissionController implements Controller, InitializingBean
|
||||||
String recipient = RequestUtils.getRequiredStringParameter(request,
|
String recipient = RequestUtils.getRequiredStringParameter(request,
|
||||||
"recipient");
|
"recipient");
|
||||||
|
|
||||||
Contact contact = contactManager.getById(new Integer(contactId));
|
Contact contact = contactManager.getById(new Long(contactId));
|
||||||
|
|
||||||
contactManager.deletePermission(contact, recipient);
|
contactManager.deletePermission(contact, recipient);
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<html>
|
<html>
|
||||||
<head><title>Your Contacts</title></head>
|
<head><title>Your Contacts</title></head>
|
||||||
<body>
|
<body>
|
||||||
<h1><authz:authentication operation="principal"/>'s Contacts</h1>
|
<h1><authz:authentication operation="username"/>'s Contacts</h1>
|
||||||
<P>
|
<P>
|
||||||
<table cellpadding=3 border=0>
|
<table cellpadding=3 border=0>
|
||||||
<tr><td><b>id</b></td><td><b>Name</b></td><td><b>Email</b></td></tr>
|
<tr><td><b>id</b></td><td><b>Name</b></td><td><b>Email</b></td></tr>
|
||||||
|
|
Loading…
Reference in New Issue