You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by rw...@apache.org on 2009/02/08 22:28:38 UTC
svn commit: r742172 [3/7] - in
/portals/jetspeed-2/portal/branches/JPA_BRANCH: ./
components/jetspeed-page-manager/
components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/
components/jetspeed-profiler/ components/jetspeed-profiler/...
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/PersistentJetspeedPrincipal.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/PersistentJetspeedPrincipal.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/PersistentJetspeedPrincipal.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/PersistentJetspeedPrincipal.java Sun Feb 8 21:28:35 2009
@@ -0,0 +1,311 @@
+/*
+ * 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.jetspeed.security.jpa;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.NamedQuery;
+import javax.persistence.NamedQueries;
+import javax.persistence.OneToMany;
+import javax.persistence.PostLoad;
+import javax.persistence.PrePersist;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.apache.jetspeed.security.SecurityAttributes;
+import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.impl.AbstractTransientJetspeedPrincipal;
+import org.apache.jetspeed.security.impl.SecurityAttributesImpl;
+import org.apache.jetspeed.security.impl.SecurityAttributeValue;
+import org.apache.jetspeed.security.spi.impl.SynchronizationStateAccess;
+
+/**
+ * @version $Id: PersistentJetspeedPrincipal.java 698049 2008-09-23 00:51:02Z ate $
+ *
+ */
+@Entity (name="Principal")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="SECURITY_PRINCIPAL")
+@DiscriminatorColumn (name="PRINCIPAL_TYPE")
+@NamedQueries ({@NamedQuery(name="PRINCIPAL", query="select p from Principal p where p.id = :id and p.type = :type and p.domainId = :domainId"),
+ @NamedQuery(name="PRINCIPAL_ID", query="select p from Principal p where p.id = :id"),
+ @NamedQuery(name="PRINCIPAL_NAME", query="select p from Principal p where p.name = :name and p.type = :type and p.domainId = :domainId"),
+ @NamedQuery(name="PRINCIPALS_LIKE_NAME", query="select p from Principal p where p.name like :nameFilter and p.type = :type and p.domainId = :domainId"),
+ @NamedQuery(name="PRINCIPAL_NAMES_LIKE_NAME", query="select p.name from Principal p where p.name like :nameFilter and p.type = :type and p.domainId = :domainId"),
+ @NamedQuery(name="PRINCIPALS_ATTRIBUTE", query="select p from Principal p, SecurityAttribute sa where p.type = :type and p.domainId = :domainId and sa member p.attributes and sa.name = :attributeName and sa.value = :attributeValue"),
+ @NamedQuery(name="PRINCIPALS_ASSOCIATED_FROM_NAME", query="select p from Principal p, PrincipalAssociation pa, Principal pf where p.type = :type and p.domainId = :toSecurityDomain and pa.toPrincipalId = p.id and pa.associationName = :associationName and pf.id = pa.fromPrincipalId and pf.name = :principalFromName and pf.domainId = :fromSecurityDomain"),
+ @NamedQuery(name="PRINCIPALS_ASSOCIATED_TO_NAME", query="select p from Principal p, PrincipalAssociation pa, Principal pt where p.type = :type and p.domainId = :fromSecurityDomain and pa.fromPrincipalId = p.id and pa.associationName = :associationName and pt.id = pa.toPrincipalId and pt.name = :principalToName and pt.domainId = :toSecurityDomain"),
+ @NamedQuery(name="PRINCIPALS_ASSOCIATED_FROM_ID", query="select p from Principal p, PrincipalAssociation pa, Principal pf where p.type = :type and p.domainId = :toSecurityDomain and pa.toPrincipalId = p.id and pa.associationName = :associationName and pf.id = pa.fromPrincipalId and pf.id = :principalFromId and pf.domainId = :fromSecurityDomain"),
+ @NamedQuery(name="PRINCIPALS_ASSOCIATED_TO_ID", query="select p from Principal p, PrincipalAssociation pa, Principal pt where p.type = :type and p.domainId = :fromSecurityDomain and pa.fromPrincipalId = p.id and pa.associationName = :associationName and pt.id = pa.toPrincipalId and pt.id = :principalToId and pt.domainId = :toSecurityDomain"),
+ @NamedQuery(name="PRINCIPAL_NAMES_ASSOCIATED_FROM_NAME", query="select p.name from Principal p, PrincipalAssociation pa, Principal pf where p.type = :type and p.domainId = :toSecurityDomain and pa.toPrincipalId = p.id and pa.associationName = :associationName and pf.id = pa.fromPrincipalId and pf.name = :principalFromName and pf.domainId = :fromSecurityDomain"),
+ @NamedQuery(name="PRINCIPAL_NAMES_ASSOCIATED_TO_NAME", query="select p.name from Principal p, PrincipalAssociation pa, Principal pt where p.type = :type and p.domainId = :fromSecurityDomain and pa.fromPrincipalId = p.id and pa.associationName = :associationName and pt.id = pa.toPrincipalId and pt.name = :principalToName and pt.domainId = :toSecurityDomain"),
+ @NamedQuery(name="PRINCIPAL_NAMES_ASSOCIATED_FROM_ID", query="select p.name from Principal p, PrincipalAssociation pa, Principal pf where p.type = :type and p.domainId = :toSecurityDomain and pa.toPrincipalId = p.id and pa.associationName = :associationName and pf.id = pa.fromPrincipalId and pf.id = :principalFromId and pf.domainId = :fromSecurityDomain"),
+ @NamedQuery(name="PRINCIPAL_NAMES_ASSOCIATED_TO_ID", query="select p.name from Principal p, PrincipalAssociation pa, Principal pt where p.type = :type and p.domainId = :fromSecurityDomain and pa.fromPrincipalId = p.id and pa.associationName = :associationName and pt.id = pa.toPrincipalId and pt.id = :principalToId and pt.domainId = :toSecurityDomain"),
+ @NamedQuery(name="PRINCIPALS_PERMISSION", query="select p from Principal p, PrincipalPermission pp where pp.principalId = p.id and pp.permissionId = :permissionId and p.domainId = :domainId order by p.type asc, p.name asc"),
+ @NamedQuery(name="PRINCIPALS_PERMISSION_TYPE_NAME", query="select p from Principal p, PrincipalPermission pp, Permission pm where pp.principalId = p.id and pp.permissionId = pm.id and pm.name = :name and pm.type = :type and p.domainId = :domainId order by p.type asc, p.name asc"),
+ @NamedQuery(name="PRINCIPALS_TYPE_PERMISSION", query="select p from Principal p, PrincipalPermission pp where pp.principalId = p.id and pp.permissionId = :permissionId and p.type = :principalType and p.domainId = :domainId order by p.type asc, p.name asc"),
+ @NamedQuery(name="PRINCIPALS_TYPE_PERMISSION_TYPE_NAME", query="select p from Principal p, PrincipalPermission pp, Permission pm where pp.principalId = p.id and pp.permissionId = pm.id and pm.name = :name and pm.type = :type and p.type = :principalType and p.domainId = :domainId order by p.type asc, p.name asc")})
+public abstract class PersistentJetspeedPrincipal extends AbstractTransientJetspeedPrincipal implements Serializable
+{
+ private static final long serialVersionUID = -2146050906453422632L;
+
+ // Members
+
+ @Id
+ @GeneratedValue (strategy=GenerationType.AUTO)
+ @Column (name="PRINCIPAL_ID")
+ private Long id;
+ @Version
+ @Column (name="JPA_VERSION")
+ @SuppressWarnings("unused")
+ private int jpaVersion;
+ @Basic
+ @Column (name="PRINCIPAL_TYPE")
+ private String type;
+ @Basic
+ @Column (name="PRINCIPAL_NAME")
+ private String name;
+ @Basic
+ @Column (name="IS_MAPPED")
+ private boolean mapped;
+ @Basic
+ @Column (name="IS_ENABLED")
+ private boolean enabled;
+ @Basic
+ @Column (name="IS_READONLY")
+ private boolean readOnly;
+ @Basic
+ @Column (name="IS_REMOVABLE")
+ private boolean removable;
+ @Temporal (value=TemporalType.TIMESTAMP)
+ @Column (name="CREATION_DATE")
+ private Timestamp creationDate;
+ @Temporal (value=TemporalType.TIMESTAMP)
+ @Column (name="MODIFIED_DATE")
+ private Timestamp modifiedDate;
+ @Basic
+ @Column (name="DOMAIN_ID")
+ private Long domainId;
+ @OneToMany (targetEntity=SecurityAttributeValueImpl.class, mappedBy="principal", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+ protected Collection<SecurityAttributeValue> attributes;
+
+ @PrePersist
+ @SuppressWarnings("unused")
+ private void prePersist()
+ {
+ if (creationDate == null)
+ {
+ creationDate = new Timestamp(System.currentTimeMillis());
+ modifiedDate = creationDate;
+ sa = null;
+ }
+ else
+ {
+ modifiedDate = new Timestamp(System.currentTimeMillis());
+ }
+ }
+ @PostLoad
+ @SuppressWarnings("unused")
+ private void eagerFetchCollections()
+ {
+ if (attributes != null)
+ {
+ attributes.size();
+ }
+ }
+
+ @Transient
+ private SecurityAttributeValueCollection attributesCollection;
+ @Transient
+ private boolean extendable;
+
+ // Implementation
+
+ public PersistentJetspeedPrincipal()
+ {
+ super();
+ this.enabled = true;
+ this.removable = true;
+ this.extendable = true;
+ }
+
+ public PersistentJetspeedPrincipal(String name)
+ {
+ this();
+ this.name = name;
+ }
+
+ public Long getId()
+ {
+ return id;
+ }
+
+ public String getTypeName()
+ {
+ return type;
+ }
+
+ public void setTypeName(String type)
+ {
+ this.type = type;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public Timestamp getCreationDate()
+ {
+ return creationDate;
+ }
+
+ public Timestamp getModifiedDate()
+ {
+ return modifiedDate;
+ }
+
+ public boolean isEnabled()
+ {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) throws SecurityException
+ {
+ if (isReadOnly() && !isSynchronizing())
+ {
+ throw new SecurityException(SecurityException.PRINCIPAL_IS_READ_ONLY.createScoped(getType().getName(), getName()));
+ }
+ this.enabled = enabled;
+ }
+
+ public boolean isTransient()
+ {
+ return false;
+ }
+
+ public boolean isMapped()
+ {
+ return mapped;
+ }
+
+ public void setMapped(boolean mapped)
+ {
+ this.mapped = mapped;
+ }
+
+ public boolean isReadOnly()
+ {
+ return readOnly;
+ }
+
+ public void setReadOnly(boolean readOnly)
+ {
+ this.readOnly = readOnly;
+ }
+
+ public boolean isRemovable()
+ {
+ return removable;
+ }
+
+ public void setRemovable(boolean removable)
+ {
+ this.removable = removable;
+ }
+
+ public boolean isExtendable()
+ {
+ return extendable;
+ }
+
+ public void setExtendable(boolean extendable)
+ {
+ this.extendable = extendable;
+ }
+
+ public synchronized SecurityAttributes getSecurityAttributes()
+ {
+ if (sa == null)
+ {
+ if (attributes == null)
+ {
+ attributes = new ArrayList<SecurityAttributeValue>();
+ }
+ if (attributesCollection == null)
+ {
+ attributesCollection = new SecurityAttributeValueCollection(this, attributes);
+ }
+ sa = new SecurityAttributesImpl(this, attributesCollection, SecurityAttributeValueImpl.class, isReadOnly(), isExtendable());
+ }
+ return sa;
+ }
+
+ public Map<String, String> getInfoMap()
+ {
+ return getSecurityAttributes().getInfoMap();
+ }
+
+ protected boolean isSynchronizing()
+ {
+ return SynchronizationStateAccess.isSynchronizing();
+ }
+
+ public Long getDomainId()
+ {
+ return domainId;
+ }
+
+ public void setDomainId(Long domainId)
+ {
+ this.domainId = domainId;
+ }
+
+ /**
+ * Test whether element is newly created.
+ *
+ * @return new status of element.
+ */
+ public boolean isNew()
+ {
+ return (id == null);
+ }
+}
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/RoleImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/RoleImpl.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/RoleImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/RoleImpl.java Sun Feb 8 21:28:35 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.jetspeed.security.jpa;
+
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import org.apache.jetspeed.security.Role;
+import org.apache.jetspeed.security.JetspeedPrincipalType;
+
+/**
+ * <p>Represents a security 'role' extending BaseJetspeedPrincipal.</p>
+ * @version $Id: RoleImpl.java 695798 2008-09-16 09:48:31Z ate $
+ */
+@Entity (name="Group")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="SECURITY_PRINCIPAL")
+@DiscriminatorColumn (name="PRINCIPAL_TYPE")
+@DiscriminatorValue (value=JetspeedPrincipalType.ROLE)
+public class RoleImpl extends PersistentJetspeedPrincipal implements Role
+{
+ private static final long serialVersionUID = 5484179899807809619L;
+
+ public RoleImpl()
+ {
+ super();
+ }
+
+ public RoleImpl(String name)
+ {
+ super(name);
+ }
+}
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/RoleManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/RoleManagerImpl.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/RoleManagerImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/RoleManagerImpl.java Sun Feb 8 21:28:35 2009
@@ -0,0 +1,238 @@
+/*
+ * 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.jetspeed.security.jpa;
+
+import java.util.List;
+
+import org.apache.jetspeed.security.JetspeedPrincipalType;
+import org.apache.jetspeed.security.Role;
+import org.apache.jetspeed.security.RoleManager;
+import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.impl.AbstractRoleManagerImpl;
+import org.apache.jetspeed.security.spi.JetspeedPrincipalAccessManager;
+import org.apache.jetspeed.security.spi.JetspeedPrincipalStorageManager;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Implementation for managing roles.
+ *
+ * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @version $Id: RoleManagerImpl.java 702099 2008-10-06 11:13:38Z ate $
+ */
+@Repository
+public class RoleManagerImpl extends AbstractRoleManagerImpl implements RoleManager
+{
+ private static final long serialVersionUID = 6267652995099120178L;
+
+ public RoleManagerImpl(JetspeedPrincipalType principalType, JetspeedPrincipalType userType, JetspeedPrincipalType groupType,
+ JetspeedPrincipalAccessManager jpam, JetspeedPrincipalStorageManager jpsm)
+ {
+ super(principalType, userType, groupType, jpam, jpsm);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.RoleManager#newRole(java.lang.String, boolean)
+ */
+ public Role newRole(String name, boolean mapped)
+ {
+ RoleImpl role = new RoleImpl(name);
+ role.setMapped(mapped);
+ return role;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#addRole(java.lang.String)
+ */
+ @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+ public Role addRole(String roleName) throws SecurityException
+ {
+ return super.addRole(roleName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#addRole(java.lang.String, boolean)
+ */
+ @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+ public Role addRole(String roleName, boolean mapped) throws SecurityException
+ {
+ return super.addRole(roleName, mapped);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#removeRole(java.lang.String)
+ */
+ @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+ public void removeRole(String roleName) throws SecurityException
+ {
+ super.removeRole(roleName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#roleExists(java.lang.String)
+ */
+ @Transactional (readOnly=true)
+ public boolean roleExists(String roleName)
+ {
+ return super.roleExists(roleName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#getRole(java.lang.String)
+ */
+ @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+ public Role getRole(String roleName) throws SecurityException
+ {
+ return super.getRole(roleName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#getRolesForUser(java.lang.String)
+ */
+ @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+ public List<Role> getRolesForUser(String username) throws SecurityException
+ {
+ return super.getRolesForUser(username);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#getRolesInGroup(java.lang.String)
+ */
+ @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+ public List<Role> getRolesInGroup(String groupName) throws SecurityException
+ {
+ return super.getRolesInGroup(groupName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#addRoleToUser(java.lang.String, java.lang.String)
+ */
+ @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+ public void addRoleToUser(String username, String roleName) throws SecurityException
+ {
+ super.addRoleToUser(username, roleName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#removeRoleFromUser(java.lang.String, java.lang.String)
+ */
+ @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+ public void removeRoleFromUser(String username, String roleName) throws SecurityException
+ {
+ super.removeRoleFromUser(username, roleName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#isUserInRole(java.lang.String, java.lang.String)
+ */
+ @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+ public boolean isUserInRole(String username, String roleName) throws SecurityException
+ {
+ return super.isUserInRole(username, roleName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#addRoleToGroup(java.lang.String, java.lang.String)
+ */
+ @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+ public void addRoleToGroup(String roleName, String groupName) throws SecurityException
+ {
+ super.addRoleToGroup(roleName, groupName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#removeRoleFromGroup(java.lang.String, java.lang.String)
+ */
+ @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+ public void removeRoleFromGroup(String roleName, String groupName) throws SecurityException
+ {
+ super.removeRoleFromGroup(roleName, groupName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#isGroupInRole(java.lang.String, java.lang.String)
+ */
+ @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+ public boolean isGroupInRole(String groupName, String roleName) throws SecurityException
+ {
+ return super.isGroupInRole(groupName, roleName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#getRoles(java.lang.String)
+ */
+ @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+ public List<Role> getRoles(String nameFilter) throws SecurityException
+ {
+ return super.getRoles(nameFilter);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#getRoleNames(java.lang.String)
+ */
+ @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+ public List<String> getRoleNames(String nameFilter) throws SecurityException
+ {
+ return super.getRoleNames(nameFilter);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#updateRole(org.apache.jetspeed.security.Role)
+ */
+ @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+ public void updateRole(Role role) throws SecurityException
+ {
+ super.updateRole(role);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#addRoleToRole(org.apache.jetspeed.security.Role, org.apache.jetspeed.security.Role, java.lang.String)
+ */
+ @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+ public void addRoleToRole(Role from, Role to, String associationName) throws SecurityException
+ {
+ super.addRoleToRole(from, to, associationName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#removeRoleFromRole(org.apache.jetspeed.security.Role, org.apache.jetspeed.security.Role, java.lang.String)
+ */
+ @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+ public void removeRoleFromRole(Role from, Role to, String associationName) throws SecurityException
+ {
+ super.removeRoleFromRole(from, to, associationName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#getRolesAssociatedTo(org.apache.jetspeed.security.Role, java.lang.String)
+ */
+ @Transactional (readOnly=true)
+ public List<Role> getRolesAssociatedTo(Role to, String associationName)
+ {
+ return super.getRolesAssociatedTo(to, associationName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractRoleManagerImpl#getRolesAssociatedFrom(org.apache.jetspeed.security.Role, java.lang.String)
+ */
+ @Transactional (readOnly=true)
+ public List<Role> getRolesAssociatedFrom(Role from, String associationName)
+ {
+ return super.getRolesAssociatedFrom(from, associationName);
+ }
+}
\ No newline at end of file
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/SecurityAttributeValueCollection.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/SecurityAttributeValueCollection.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/SecurityAttributeValueCollection.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/SecurityAttributeValueCollection.java Sun Feb 8 21:28:35 2009
@@ -0,0 +1,115 @@
+/*
+ * 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.jetspeed.security.jpa;
+
+import java.util.AbstractCollection;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.jetspeed.security.impl.SecurityAttributeValue;
+
+/**
+ * SecurityAttributeValueCollection
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+class SecurityAttributeValueCollection extends AbstractCollection<SecurityAttributeValue>
+{
+ private PersistentJetspeedPrincipal principal;
+ private Collection<SecurityAttributeValue> attributesCollection;
+
+ /**
+ * Construct collection to maintain JPA inverse relationship.
+ *
+ * @param principal owning principal.
+ * @param attributesCollection managed attributes collection.
+ */
+ SecurityAttributeValueCollection(PersistentJetspeedPrincipal principal, Collection<SecurityAttributeValue> attributesCollection)
+ {
+ super();
+ this.principal = principal;
+ this.attributesCollection = attributesCollection;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.AbstractCollection#add(java.lang.Object)
+ */
+ public boolean add(SecurityAttributeValue element)
+ {
+ ((SecurityAttributeValueImpl)element).setInverseRelationship(principal);
+ return attributesCollection.add(element);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.AbstractCollection#iterator()
+ */
+ public Iterator<SecurityAttributeValue> iterator()
+ {
+ return new Iterator<SecurityAttributeValue>()
+ {
+ private Iterator<SecurityAttributeValue> iter = attributesCollection.iterator();
+ private SecurityAttributeValue lastNext = null;
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#hasNext()
+ */
+ public boolean hasNext()
+ {
+ return iter.hasNext();
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#next()
+ */
+ public SecurityAttributeValue next()
+ {
+ return lastNext = iter.next();
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#remove()
+ */
+ public void remove()
+ {
+ iter.remove();
+ ((SecurityAttributeValueImpl)lastNext).setInverseRelationship(null);
+ }
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.AbstractCollection#remove(java.lang.Object)
+ */
+ public boolean remove(Object element)
+ {
+ if (attributesCollection.remove(element))
+ {
+ ((SecurityAttributeValueImpl)element).setInverseRelationship(null);
+ return true;
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.AbstractCollection#size()
+ */
+ public int size()
+ {
+ return attributesCollection.size();
+ }
+}
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/SecurityAttributeValueImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/SecurityAttributeValueImpl.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/SecurityAttributeValueImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/SecurityAttributeValueImpl.java Sun Feb 8 21:28:35 2009
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jetspeed.security.jpa;
+
+import java.io.Serializable;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Version;
+
+import org.apache.jetspeed.security.impl.SecurityAttributeValue;
+
+/**
+ * @version $Id: SecurityAttributeValue.java 695798 2008-09-16 09:48:31Z ate $
+ *
+ */
+@Entity (name="SecurityAttribute")
+@Table (name="SECURITY_ATTRIBUTE")
+public class SecurityAttributeValueImpl implements SecurityAttributeValue, Serializable
+{
+ private static final long serialVersionUID = -5305625934872996140L;
+
+ // Members
+
+ @Id
+ @GeneratedValue (strategy=GenerationType.AUTO)
+ @Column (name="PRINCIPAL_ID")
+ @SuppressWarnings("unused")
+ private Long id;
+ @Version
+ @Column (name="JPA_VERSION")
+ @SuppressWarnings("unused")
+ private int jpaVersion;
+ @ManyToOne (targetEntity=PersistentJetspeedPrincipal.class, fetch=FetchType.LAZY, optional=false)
+ @JoinColumn (name="PRINCIPAL_ID", referencedColumnName="PRINCIPAL_ID")
+ @SuppressWarnings("unused")
+ private PersistentJetspeedPrincipal principal;
+ @Basic
+ @Column (name="ATTR_NAME")
+ private String name;
+ @Basic
+ @Column (name="ATTR_VALUE")
+ private String value;
+
+ /**
+ * Accessor used to maintain JPA bidirectional relationships.
+ *
+ * @param inverse bidirectional relationship inverse.
+ */
+ public void setInverseRelationship(Object inverse)
+ {
+ principal = (PersistentJetspeedPrincipal)inverse;
+ }
+
+ // Implementation
+
+ public SecurityAttributeValueImpl()
+ {
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getStringValue()
+ {
+ return value;
+ }
+
+ public void setStringValue(String stringValue)
+ {
+ this.value = stringValue;
+ }
+}
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/SecurityDomainImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/SecurityDomainImpl.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/SecurityDomainImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/SecurityDomainImpl.java Sun Feb 8 21:28:35 2009
@@ -0,0 +1,145 @@
+/*
+ * 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.jetspeed.security.jpa;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQuery;
+import javax.persistence.NamedQueries;
+import javax.persistence.Table;
+import javax.persistence.Version;
+
+import org.apache.jetspeed.security.SecurityDomain;
+
+/**
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ * @version $Id: SecurityDomainImpl.java 736069 2009-01-20 19:10:43Z rwatler $
+ */
+@Entity (name="SecurityDomain")
+@Table (name="SECURITY_DOMAIN")
+@NamedQueries ({@NamedQuery(name="SECURITY_DOMAIN", query="select sd from SecurityDomain sd where sd.domainId = :domainId"),
+ @NamedQuery(name="SECURITY_DOMAIN_NAME", query="select sd from SecurityDomain sd where sd.name = :name"),
+ @NamedQuery(name="SECURITY_DOMAINS_OWNER", query="select sd from SecurityDomain sd where sd.ownerDomainId = :ownerDomainId order by sd.name asc"),
+ @NamedQuery(name="SECURITY_DOMAINS", query="select sd from SecurityDomain order by sd.name asc")})
+public class SecurityDomainImpl implements SecurityDomain
+{
+ // Members
+
+ @Id
+ @GeneratedValue (strategy=GenerationType.AUTO)
+ @Column (name="DOMAIN_ID")
+ private Long domainId;
+ @Version
+ @Column (name="JPA_VERSION")
+ @SuppressWarnings("unused")
+ private int jpaVersion;
+ @Basic
+ @Column (name="DOMAIN_NAME")
+ private String name;
+ @Basic
+ @Column (name="OWNER_DOMAIN_ID")
+ private Long ownerDomainId;
+ @Basic
+ @Column (name="REMOTE")
+ private boolean remote;
+ @Basic
+ @Column (name="ENABLED")
+ private boolean enabled;
+
+ // Implementation
+
+ public SecurityDomainImpl()
+ {
+ this.enabled = true;
+ }
+
+ public SecurityDomainImpl(SecurityDomain anotherDomain)
+ {
+ this.domainId=anotherDomain.getDomainId();
+ this.name=anotherDomain.getName();
+ this.ownerDomainId=anotherDomain.getOwnerDomainId();
+ this.remote=anotherDomain.isRemote();
+ this.enabled=anotherDomain.isEnabled();
+ }
+
+ public Long getDomainId()
+ {
+ return domainId;
+ }
+
+ public void setDomainId(Long domainId)
+ {
+ this.domainId = domainId;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public Long getOwnerDomainId()
+ {
+ return ownerDomainId;
+ }
+
+ public void setOwnerDomainId(Long ownerDomainId)
+ {
+ this.ownerDomainId = ownerDomainId;
+ }
+
+ public boolean isRemote()
+ {
+ return remote;
+ }
+
+ public void setRemote(boolean remote)
+ {
+ this.remote = remote;
+ }
+
+
+ public boolean isEnabled()
+ {
+ return enabled;
+ }
+
+
+ public void setEnabled(boolean enabled)
+ {
+ this.enabled = enabled;
+ }
+
+
+ /**
+ * Test whether element is newly created.
+ *
+ * @return new status of element.
+ */
+ public boolean isNew()
+ {
+ return (domainId == null);
+ }
+}
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/UserImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/UserImpl.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/UserImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/UserImpl.java Sun Feb 8 21:28:35 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.jetspeed.security.jpa;
+
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import org.apache.jetspeed.security.User;
+import org.apache.jetspeed.security.JetspeedPrincipalType;
+
+/**
+ * <p>Represents a security 'user' extending BaseJetspeedPrincipal.</p>
+ * @version $Id: UserImpl.java 695798 2008-09-16 09:48:31Z ate $
+ */
+@Entity (name="Group")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="SECURITY_PRINCIPAL")
+@DiscriminatorColumn (name="PRINCIPAL_TYPE")
+@DiscriminatorValue (value=JetspeedPrincipalType.USER)
+public class UserImpl extends PersistentJetspeedPrincipal implements User
+{
+ private static final long serialVersionUID = 5484179899807809619L;
+
+ public UserImpl()
+ {
+ super();
+ }
+
+ public UserImpl(String name)
+ {
+ super(name);
+ }
+}
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/UserManagerImpl.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/UserManagerImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/UserManagerImpl.java Sun Feb 8 21:28:35 2009
@@ -0,0 +1,198 @@
+/*
+ * 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.jetspeed.security.jpa;
+
+import java.util.List;
+
+import javax.security.auth.Subject;
+
+import org.apache.jetspeed.security.JetspeedPrincipalType;
+import org.apache.jetspeed.security.PasswordCredential;
+import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.User;
+import org.apache.jetspeed.security.UserManager;
+import org.apache.jetspeed.security.impl.AbstractUserManagerImpl;
+import org.apache.jetspeed.security.spi.JetspeedPrincipalAccessManager;
+import org.apache.jetspeed.security.spi.JetspeedPrincipalStorageManager;
+import org.apache.jetspeed.security.spi.UserPasswordCredentialManager;
+import org.apache.jetspeed.security.spi.UserSubjectPrincipalsProvider;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Implementation for managing users and provides access to the {@link User}.
+ *
+ * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
+ * @author <a href="mailto:vkumar@apache.org">Vivek Kumar </a>
+ * @version $Id: UserManagerImpl.java 721251 2008-11-27 17:55:08Z woonsan $
+ */
+@Repository
+public class UserManagerImpl extends AbstractUserManagerImpl implements UserManager, UserSubjectPrincipalsProvider
+{
+ private static final long serialVersionUID = 3373105117294097895L;
+
+ public UserManagerImpl(JetspeedPrincipalType principalType, JetspeedPrincipalType roleType, JetspeedPrincipalType groupType,
+ JetspeedPrincipalAccessManager jpam, JetspeedPrincipalStorageManager jpsm, UserPasswordCredentialManager credentialManager)
+ {
+ super(principalType, roleType, groupType, jpam, jpsm, credentialManager);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.UserManager#newUser(java.lang.String)
+ */
+ public User newUser(String name)
+ {
+ UserImpl user = new UserImpl(name);
+ return user;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.UserManager#newUser(java.lang.String, boolean)
+ */
+ public User newUser(String name, boolean mapped)
+ {
+ UserImpl user = new UserImpl(name);
+ user.setMapped(mapped);
+ return user;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractUserManagerImpl#addUser(java.lang.String)
+ */
+ @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+ public User addUser(String userName) throws SecurityException
+ {
+ return super.addUser(userName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractUserManagerImpl#addUser(java.lang.String, boolean)
+ */
+ @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+ public User addUser(String userName, boolean mapped) throws SecurityException
+ {
+ return super.addUser(userName, mapped);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractUserManagerImpl#removeUser(java.lang.String)
+ */
+ @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+ public void removeUser(String userName) throws SecurityException
+ {
+ super.removeUser(userName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractUserManagerImpl#userExists(java.lang.String)
+ */
+ @Transactional (readOnly=true)
+ public boolean userExists(String userName)
+ {
+ return super.userExists(userName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractUserManagerImpl#getUser(java.lang.String)
+ */
+ @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+ public User getUser(String userName) throws SecurityException
+ {
+ return super.getUser(userName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractUserManagerImpl#getSubject(org.apache.jetspeed.security.User)
+ */
+ @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+ public Subject getSubject(User user) throws SecurityException
+ {
+ return super.getSubject(user);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractUserManagerImpl#getUsers(java.lang.String)
+ */
+ @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+ public List<User> getUsers(String nameFilter) throws SecurityException
+ {
+ return super.getUsers(nameFilter);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractUserManagerImpl#getUserNames(java.lang.String)
+ */
+ @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+ public List<String> getUserNames(String nameFilter) throws SecurityException
+ {
+ return super.getUserNames(nameFilter);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractUserManagerImpl#getUsersInRole(java.lang.String)
+ */
+ @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+ public List<User> getUsersInRole(String roleName) throws SecurityException
+ {
+ return super.getUsersInRole(roleName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractUserManagerImpl#getUsersInGroup(java.lang.String)
+ */
+ @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+ public List<User> getUsersInGroup(String groupName) throws SecurityException
+ {
+ return super.getUsersInGroup(groupName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractUserManagerImpl#updateUser(org.apache.jetspeed.security.User)
+ */
+ @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+ public void updateUser(User user) throws SecurityException
+ {
+ super.updateUser(user);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractUserManagerImpl#lookupUsers(java.lang.String, java.lang.String)
+ */
+ @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+ public List<User> lookupUsers(String attributeName, String attributeValue) throws SecurityException
+ {
+ return super.lookupUsers(attributeName, attributeValue);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractUserManagerImpl#getPasswordCredential(org.apache.jetspeed.security.User)
+ */
+ @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+ public PasswordCredential getPasswordCredential(User user) throws SecurityException
+ {
+ return super.getPasswordCredential(user);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.security.impl.AbstractUserManagerImpl#storePasswordCredential(org.apache.jetspeed.security.PasswordCredential)
+ */
+ @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+ public void storePasswordCredential(PasswordCredential credential) throws SecurityException
+ {
+ super.storePasswordCredential(credential);
+ }
+}
\ No newline at end of file
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPermissionAccessManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPermissionAccessManager.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPermissionAccessManager.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPermissionAccessManager.java Sun Feb 8 21:28:35 2009
@@ -21,7 +21,6 @@
import org.apache.jetspeed.security.JetspeedPermission;
import org.apache.jetspeed.security.JetspeedPrincipal;
-import org.apache.jetspeed.security.impl.PersistentJetspeedPrincipal;
/**
* @version $Id$
@@ -30,7 +29,7 @@
public interface JetspeedPermissionAccessManager
{
boolean permissionExists(JetspeedPermission permission);
- List<? extends JetspeedPermission> getPermissions(PersistentJetspeedPrincipal principal);
+ List<? extends JetspeedPermission> getPermissions(JetspeedPrincipal principal);
List<? extends JetspeedPermission> getPermissions();
List<? extends JetspeedPermission> getPermissions(String type);
List<? extends JetspeedPermission> getPermissions(String type, String nameFilter);
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/AbstractUserPasswordCredentialManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/AbstractUserPasswordCredentialManagerImpl.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/AbstractUserPasswordCredentialManagerImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/AbstractUserPasswordCredentialManagerImpl.java Sun Feb 8 21:28:35 2009
@@ -0,0 +1,131 @@
+/*
+ * 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.jetspeed.security.spi.impl;
+
+import org.apache.jetspeed.security.JetspeedPrincipalType;
+import org.apache.jetspeed.security.PasswordCredential;
+import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.User;
+import org.apache.jetspeed.security.spi.UserPasswordCredentialAccessManager;
+import org.apache.jetspeed.security.spi.UserPasswordCredentialManager;
+import org.apache.jetspeed.security.spi.UserPasswordCredentialPolicyManager;
+import org.apache.jetspeed.security.spi.UserPasswordCredentialStorageManager;
+
+/**
+ * @version $Id: AbstractUserPasswordCredentialManagerImpl.java 698208 2008-09-23 15:57:18Z ate $
+ */
+public abstract class AbstractUserPasswordCredentialManagerImpl implements UserPasswordCredentialManager
+{
+ private static final long serialVersionUID = 6203626413396285704L;
+
+ private UserPasswordCredentialStorageManager upcsm;
+ private UserPasswordCredentialAccessManager upcam;
+ private UserPasswordCredentialPolicyManager upcpm;
+
+ protected AbstractUserPasswordCredentialManagerImpl(UserPasswordCredentialStorageManager upcsm, UserPasswordCredentialAccessManager upcam)
+ {
+ this.upcsm = upcsm;
+ this.upcam = upcam;
+ }
+
+ protected AbstractUserPasswordCredentialManagerImpl(UserPasswordCredentialStorageManager upcsm, UserPasswordCredentialAccessManager upcam, UserPasswordCredentialPolicyManager upcpm)
+ {
+ this(upcsm, upcam);
+ this.upcpm = upcpm;
+ }
+
+ public PasswordCredential getPasswordCredential(User user) throws SecurityException
+ {
+ PasswordCredential credential = upcsm.getPasswordCredential(user);
+ if (!credential.isNew() && upcpm != null)
+ {
+ upcpm.onLoad(credential, user.getName());
+ }
+ return credential;
+ }
+
+ public void storePasswordCredential(PasswordCredential credential) throws SecurityException
+ {
+ if (upcpm != null)
+ {
+ upcpm.onStore(credential);
+ }
+ upcsm.storePasswordCredential(credential);
+ }
+
+ public PasswordCredential getAuthenticatedPasswordCredential(String userName, String password) throws SecurityException
+ {
+ PasswordCredential credential = upcam.getPasswordCredential(userName);
+ if (credential == null)
+ {
+ throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, userName));
+ }
+
+ if (upcpm != null)
+ {
+ if (upcpm.onLoad(credential, userName))
+ {
+ upcsm.storePasswordCredential(credential);
+ }
+ if (credential.isEnabled() && !credential.isExpired())
+ {
+ if (upcpm.authenticate(credential, userName, password))
+ {
+ upcsm.storePasswordCredential(credential);
+ }
+ if (!credential.isEnabled() || credential.isExpired())
+ {
+ throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, userName));
+ }
+ else if (credential.getAuthenticationFailures() != 0)
+ {
+ throw new SecurityException(SecurityException.INVALID_PASSWORD);
+ }
+ }
+ }
+ else
+ {
+ if (password == null)
+ {
+ throw new SecurityException(SecurityException.PASSWORD_REQUIRED);
+ }
+ else if (credential.getPassword() == null || !password.equals(new String(credential.getPassword())))
+ {
+ throw new SecurityException(SecurityException.INVALID_PASSWORD);
+ }
+ if (!credential.isEnabled() || credential.isExpired())
+ {
+ throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, userName));
+ }
+ }
+
+ try
+ {
+ upcam.loadPasswordCredentialUser(credential);
+ }
+ catch (Exception e)
+ {
+ throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, userName), e);
+ }
+
+ if (credential.getUser() == null || !credential.getUser().isEnabled())
+ {
+ throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, userName));
+ }
+ return credential;
+ }
+}
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/AbstractUserPasswordCredentialPolicyManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/AbstractUserPasswordCredentialPolicyManagerImpl.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/AbstractUserPasswordCredentialPolicyManagerImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/AbstractUserPasswordCredentialPolicyManagerImpl.java Sun Feb 8 21:28:35 2009
@@ -0,0 +1,219 @@
+/*
+ * 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.jetspeed.security.spi.impl;
+
+import java.sql.Timestamp;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.jetspeed.security.CredentialPasswordEncoder;
+import org.apache.jetspeed.security.CredentialPasswordValidator;
+import org.apache.jetspeed.security.InvalidPasswordException;
+import org.apache.jetspeed.security.PasswordCredential;
+import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.spi.AlgorithmUpgradeCredentialPasswordEncoder;
+import org.apache.jetspeed.security.spi.PasswordCredentialInterceptor;
+import org.apache.jetspeed.security.spi.UserPasswordCredentialPolicyManager;
+
+/**
+ * @version $Id: AbstractUserPasswordCredentialPolicyManagerImpl.java 707423 2008-10-23 17:38:23Z vkumar $
+ */
+public abstract class AbstractUserPasswordCredentialPolicyManagerImpl implements UserPasswordCredentialPolicyManager
+{
+ private static final long serialVersionUID = 4552270806045085693L;
+
+ private CredentialPasswordEncoder encoder;
+ private CredentialPasswordValidator validator;
+ private PasswordCredentialInterceptor[] interceptors;
+
+ protected AbstractUserPasswordCredentialPolicyManagerImpl()
+ {
+ this.interceptors = new PasswordCredentialInterceptor[0];
+ }
+
+ protected AbstractUserPasswordCredentialPolicyManagerImpl(CredentialPasswordEncoder encoder, CredentialPasswordValidator validator, List<?> interceptors)
+ {
+ this.encoder = encoder;
+ this.validator = validator;
+ if(interceptors !=null)
+ {
+ this.interceptors = (PasswordCredentialInterceptor[]) interceptors.toArray(new PasswordCredentialInterceptor[interceptors.size()]);
+ }
+ else
+ {
+ this.interceptors = new PasswordCredentialInterceptor[0];
+ }
+ }
+
+ public CredentialPasswordEncoder getCredentialPasswordEncoder()
+ {
+ return encoder;
+ }
+
+ public CredentialPasswordValidator getCredentialPasswordValidator()
+ {
+ return validator;
+ }
+
+ public boolean onLoad(PasswordCredential credential, String userName) throws SecurityException
+ {
+ boolean update = false;
+ for (PasswordCredentialInterceptor pci : interceptors)
+ {
+ if (pci.afterLoad(userName, credential, encoder, validator))
+ {
+ update = true;
+ }
+ }
+ return update;
+ }
+
+ public boolean authenticate(PasswordCredential credential, String userName, String password) throws SecurityException
+ {
+ String encodedPassword = password;
+ boolean authenticated = false;
+ if (encoder != null && credential.isEncoded())
+ {
+ if (encoder instanceof AlgorithmUpgradeCredentialPasswordEncoder)
+ {
+ encodedPassword = ((AlgorithmUpgradeCredentialPasswordEncoder)encoder).encode(credential, password);
+ }
+ else
+ {
+ encodedPassword = encoder.encode(userName, password);
+ }
+ authenticated = credential.getPassword().equals(encodedPassword);
+ }
+ boolean update = false;
+
+ for (PasswordCredentialInterceptor pci : interceptors)
+ {
+ if (pci.afterAuthenticated(credential, authenticated))
+ {
+ update = true;
+ }
+ }
+ if (update && (!credential.isEnabled() || credential.isExpired()))
+ {
+ authenticated = false;
+ }
+
+ if (authenticated)
+ {
+ credential.setAuthenticationFailures(0);
+ if (encoder != null && encoder instanceof AlgorithmUpgradeCredentialPasswordEncoder)
+ {
+ ((AlgorithmUpgradeCredentialPasswordEncoder)encoder).recodeIfNeeded(credential, password);
+ credential.clearNewPasswordSet();
+ }
+ credential.setPreviousAuthenticationDate(credential.getLastAuthenticationDate());
+ credential.setLastAuthenticationDate(new Timestamp(new Date().getTime()));
+ update = true;
+ }else{
+ credential.setAuthenticationFailures(credential.getAuthenticationFailures()+1);
+ }
+
+ return update;
+ }
+
+ public void onStore(PasswordCredential credential) throws SecurityException
+ {
+ if (credential.isNewPasswordSet())
+ {
+ String newPassword = null;
+ boolean authenticated = false;
+ if (credential.getNewPassword() != null)
+ {
+ if (credential.getOldPassword() != null)
+ {
+ authenticated = true;
+ String validatingOldPassword = credential.getOldPassword();
+ if (credential.isEncoded() && encoder != null)
+ {
+ if (encoder instanceof AlgorithmUpgradeCredentialPasswordEncoder)
+ {
+ validatingOldPassword = ((AlgorithmUpgradeCredentialPasswordEncoder)encoder).encode(credential, validatingOldPassword);
+ }
+ else
+ {
+ validatingOldPassword = encoder.encode(credential.getUserName(), validatingOldPassword);
+ }
+ }
+ if (credential.getPassword() == null || !credential.getPassword().equals(validatingOldPassword))
+ {
+ throw new InvalidPasswordException();
+ }
+ }
+ if (validator != null)
+ {
+ validator.validate(credential.getNewPassword());
+ }
+ newPassword = credential.getNewPassword();
+ if (encoder != null)
+ {
+ newPassword = encoder.encode(credential.getUserName(), newPassword);
+ }
+
+ }
+ else
+ {
+ newPassword = credential.getPassword();
+ if (encoder != null && !credential.isEncoded())
+ {
+ newPassword = encoder.encode(credential.getUserName(), newPassword);
+ }
+ }
+
+ if (!credential.isNew())
+ {
+ credential.revertNewPasswordSet();
+ for (PasswordCredentialInterceptor pci : interceptors)
+ {
+ pci.beforeSetPassword(credential, newPassword, authenticated);
+ }
+ credential.setUpdateRequired(false);
+ }
+ credential.setPassword(newPassword, encoder != null);
+ credential.clearNewPasswordSet();
+ if (!authenticated)
+ {
+ if (encoder != null && encoder instanceof AlgorithmUpgradeCredentialPasswordEncoder)
+ {
+ // set current time in previous auth date, and clear last authentication date
+ // !!! While this might be a bit strange logic, it is *required* for the AlgorithmUpgradePBEPasswordEncodingService
+ // to be able to distinguish password changes from other changes
+ credential.setPreviousAuthenticationDate(new Timestamp(new Date().getTime()));
+ credential.setLastAuthenticationDate(null);
+ }
+ }
+ else
+ {
+ // authenticated password change (by user itself)
+ credential.setPreviousAuthenticationDate(credential.getLastAuthenticationDate());
+ credential.setLastAuthenticationDate(new Timestamp(new Date().getTime()));
+ }
+ }
+ if (credential.isNew())
+ {
+ for (PasswordCredentialInterceptor pci : interceptors)
+ {
+ pci.beforeCreate(credential);
+ }
+ }
+ }
+}
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/BaseJetspeedPermission.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/BaseJetspeedPermission.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/BaseJetspeedPermission.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/BaseJetspeedPermission.java Sun Feb 8 21:28:35 2009
@@ -39,6 +39,8 @@
*/
public abstract class BaseJetspeedPermission extends Permission implements JetspeedPermission
{
+ private static final long serialVersionUID = 5277704825880577140L;
+
private static class JetspeedPermissionCollection extends PermissionCollection
{
private static final long serialVersionUID = -3852518088847803886L;
@@ -79,17 +81,17 @@
private final PersistentJetspeedPermission permission;
- public BaseJetspeedPermission(String type, String name, int mask)
+ public BaseJetspeedPermission(PersistentJetspeedPermission permission, int mask)
{
- super(name);
- this.permission = new PersistentJetspeedPermissionImpl(type, name);
+ super(permission.getName());
+ this.permission = permission;
this.mask = mask;
}
- public BaseJetspeedPermission(String type, String name, String actions)
+ public BaseJetspeedPermission(PersistentJetspeedPermission permission, String actions)
{
- super(name);
- this.permission = new PersistentJetspeedPermissionImpl(type, name);
+ super(permission.getName());
+ this.permission = permission;
this.mask = JetspeedActions.getContainerActionsMask(actions);
}
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FolderPermission.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FolderPermission.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FolderPermission.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FolderPermission.java Sun Feb 8 21:28:35 2009
@@ -61,14 +61,22 @@
super(PermissionFactory.FOLDER_PERMISSION);
}
- public FolderPermission newPermission(String name, String actions)
+ public FolderPermission newPermission(PersistentJetspeedPermission permission, String actions)
{
- return new FolderPermission(getType(), name, actions);
+ if (permission.getType().equals(getType()))
+ {
+ return new FolderPermission(permission, actions);
+ }
+ throw new IllegalArgumentException("Permission is not of type "+getType());
}
- public FolderPermission newPermission(String name, int mask)
+ public FolderPermission newPermission(PersistentJetspeedPermission permission, int mask)
{
- return new FolderPermission(getType(), name, mask);
+ if (permission.getType().equals(getType()))
+ {
+ return new FolderPermission(permission, mask);
+ }
+ throw new IllegalArgumentException("Permission is not of type "+getType());
}
public FolderPermission newPermission(PersistentJetspeedPermission permission)
@@ -95,15 +103,15 @@
parsePath();
}
- protected FolderPermission(String type, String name, int mask)
+ protected FolderPermission(PersistentJetspeedPermission permission, int mask)
{
- super(type, name, mask);
+ super(permission, mask);
parsePath();
}
- protected FolderPermission(String type, String name, String actions)
+ protected FolderPermission(PersistentJetspeedPermission permission, String actions)
{
- super(type, name, actions);
+ super(permission, actions);
parsePath();
}
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FragmentPermission.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FragmentPermission.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FragmentPermission.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FragmentPermission.java Sun Feb 8 21:28:35 2009
@@ -55,14 +55,22 @@
super(PermissionFactory.FRAGMENT_PERMISSION);
}
- public FragmentPermission newPermission(String name, String actions)
+ public FragmentPermission newPermission(PersistentJetspeedPermission permission, String actions)
{
- return new FragmentPermission(getType(), name, actions);
+ if (permission.getType().equals(getType()))
+ {
+ return new FragmentPermission(permission, actions);
+ }
+ throw new IllegalArgumentException("Permission is not of type "+getType());
}
- public FragmentPermission newPermission(String name, int mask)
+ public FragmentPermission newPermission(PersistentJetspeedPermission permission, int mask)
{
- return new FragmentPermission(getType(), name, mask);
+ if (permission.getType().equals(getType()))
+ {
+ return new FragmentPermission(permission, mask);
+ }
+ throw new IllegalArgumentException("Permission is not of type "+getType());
}
public FragmentPermission newPermission(PersistentJetspeedPermission permission)
@@ -80,14 +88,14 @@
super(permission);
}
- protected FragmentPermission(String type, String name, int mask)
+ protected FragmentPermission(PersistentJetspeedPermission permission, int mask)
{
- super(type, name, mask);
+ super(permission, mask);
}
- protected FragmentPermission(String type, String name, String actions)
+ protected FragmentPermission(PersistentJetspeedPermission permission, String actions)
{
- super(type, name, actions);
+ super(permission, actions);
}
public boolean implies(Permission permission)
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPermissionFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPermissionFactory.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPermissionFactory.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPermissionFactory.java Sun Feb 8 21:28:35 2009
@@ -37,9 +37,9 @@
return type;
}
- public abstract BaseJetspeedPermission newPermission(String name, String actions);
+ public abstract BaseJetspeedPermission newPermission(PersistentJetspeedPermission permission, String actions);
- public abstract BaseJetspeedPermission newPermission(String name, int mask);
+ public abstract BaseJetspeedPermission newPermission(PersistentJetspeedPermission permission, int mask);
public abstract BaseJetspeedPermission newPermission(PersistentJetspeedPermission permission);
}
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedSecurityPersistenceManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedSecurityPersistenceManager.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedSecurityPersistenceManager.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedSecurityPersistenceManager.java Sun Feb 8 21:28:35 2009
@@ -34,9 +34,9 @@
import org.apache.jetspeed.security.SecurityDomain;
import org.apache.jetspeed.security.SecurityException;
import org.apache.jetspeed.security.User;
+import org.apache.jetspeed.security.impl.AbstractTransientJetspeedPrincipal;
import org.apache.jetspeed.security.impl.PersistentJetspeedPrincipal;
import org.apache.jetspeed.security.impl.SecurityDomainImpl;
-import org.apache.jetspeed.security.impl.TransientJetspeedPrincipal;
import org.apache.jetspeed.security.spi.JetspeedDomainPrincipalAccessManager;
import org.apache.jetspeed.security.spi.JetspeedPermissionAccessManager;
import org.apache.jetspeed.security.spi.JetspeedPermissionStorageManager;
@@ -386,8 +386,8 @@
public void addPrincipal(JetspeedPrincipal principal, Set<JetspeedPrincipalAssociationReference> associations)
throws SecurityException
{
- if (principal.getDomainId() == null && principal instanceof TransientJetspeedPrincipal){
- ((TransientJetspeedPrincipal)principal).setDomainId(getDefaultSecurityDomainId());
+ if (principal.getDomainId() == null && principal instanceof AbstractTransientJetspeedPrincipal){
+ ((AbstractTransientJetspeedPrincipal)principal).setDomainId(getDefaultSecurityDomainId());
}
if (principalExists(principal))
{
@@ -668,7 +668,7 @@
}
@SuppressWarnings("unchecked")
- public List<PersistentJetspeedPermission> getPermissions(PersistentJetspeedPrincipal principal)
+ public List<PersistentJetspeedPermission> getPermissions(JetspeedPrincipal principal)
{
Criteria criteria = new Criteria();
criteria.addEqualTo("principals.principalId", principal.getId());
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PagePermission.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PagePermission.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PagePermission.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PagePermission.java Sun Feb 8 21:28:35 2009
@@ -42,14 +42,22 @@
super(PermissionFactory.PAGE_PERMISSION);
}
- public PagePermission newPermission(String name, String actions)
+ public PagePermission newPermission(PersistentJetspeedPermission permission, String actions)
{
- return new PagePermission(getType(), name, actions);
+ if (permission.getType().equals(getType()))
+ {
+ return new PagePermission(permission, actions);
+ }
+ throw new IllegalArgumentException("Permission is not of type "+getType());
}
- public PagePermission newPermission(String name, int mask)
+ public PagePermission newPermission(PersistentJetspeedPermission permission, int mask)
{
- return new PagePermission(getType(), name, mask);
+ if (permission.getType().equals(getType()))
+ {
+ return new PagePermission(permission, mask);
+ }
+ throw new IllegalArgumentException("Permission is not of type "+getType());
}
public PagePermission newPermission(PersistentJetspeedPermission permission)
@@ -67,14 +75,14 @@
super(permission);
}
- protected PagePermission(String type, String name, int mask)
+ protected PagePermission(PersistentJetspeedPermission permission, int mask)
{
- super(type, name, mask);
+ super(permission, mask);
}
- protected PagePermission(String type, String name, String actions)
+ protected PagePermission(PersistentJetspeedPermission permission, String actions)
{
- super(type, name, actions);
+ super(permission, actions);
}
public boolean implies(Permission permission)
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PortletPermission.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PortletPermission.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PortletPermission.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PortletPermission.java Sun Feb 8 21:28:35 2009
@@ -42,14 +42,22 @@
super(PermissionFactory.PORTLET_PERMISSION);
}
- public PortletPermission newPermission(String name, String actions)
+ public PortletPermission newPermission(PersistentJetspeedPermission permission, String actions)
{
- return new PortletPermission(getType(), name, actions);
+ if (permission.getType().equals(getType()))
+ {
+ return new PortletPermission(permission, actions);
+ }
+ throw new IllegalArgumentException("Permission is not of type "+getType());
}
- public PortletPermission newPermission(String name, int mask)
+ public PortletPermission newPermission(PersistentJetspeedPermission permission, int mask)
{
- return new PortletPermission(getType(), name, mask);
+ if (permission.getType().equals(getType()))
+ {
+ return new PortletPermission(permission, mask);
+ }
+ throw new IllegalArgumentException("Permission is not of type "+getType());
}
public PortletPermission newPermission(PersistentJetspeedPermission permission)
@@ -67,14 +75,14 @@
super(permission);
}
- protected PortletPermission(String type, String name, int mask)
+ protected PortletPermission(PersistentJetspeedPermission permission, int mask)
{
- super(type, name, mask);
+ super(permission, mask);
}
- protected PortletPermission(String type, String name, String actions)
+ protected PortletPermission(PersistentJetspeedPermission permission, String actions)
{
- super(type, name, actions);
+ super(permission, actions);
}
public boolean implies(Permission permission)
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org