Seam SVN: r13397 - modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-14 21:31:24 -0400 (Wed, 14 Jul 2010)
New Revision: 13397
Added:
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityObjectRelationshipTypeImpl.java
Modified:
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityObjectImpl.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityObjectRelationshipImpl.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityObjectTypeImpl.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
Log:
implement resolveRelationships
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityObjectImpl.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityObjectImpl.java 2010-07-15 01:30:40 UTC (rev 13396)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityObjectImpl.java 2010-07-15 01:31:24 UTC (rev 13397)
@@ -21,6 +21,9 @@
public IdentityObjectImpl(String id, String name, IdentityObjectType type)
{
+ if (name == null) throw new IllegalArgumentException("IdentityObject.name cannot be null");
+ if (type == null) throw new IllegalArgumentException("IdentityObject.identityType cannot be null");
+
this.id = id;
this.name = name;
this.type = type;
@@ -45,4 +48,24 @@
{
}
+
+ @Override
+ public boolean equals(Object value)
+ {
+ if (!(value instanceof IdentityObject)) return false;
+ IdentityObject other = (IdentityObject) value;
+
+ return (id != null ? id.equals(other.getId()) : other.getId() == null) &&
+ name.equals(other.getName()) &&
+ type.equals(other.getIdentityType());
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int hash = 0;
+ if (id != null) hash ^= (id.hashCode() * 17);
+ hash ^= (name.hashCode() * 29) ^ (type.hashCode() * 37);
+ return hash;
+ }
}
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityObjectRelationshipImpl.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityObjectRelationshipImpl.java 2010-07-15 01:30:40 UTC (rev 13396)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityObjectRelationshipImpl.java 2010-07-15 01:31:24 UTC (rev 13397)
@@ -23,6 +23,10 @@
IdentityObject toIdentityObject, String name,
IdentityObjectRelationshipType type)
{
+ if (fromIdentityObject == null) throw new IllegalArgumentException("IdentityObjectRelationship.fromIdentityObject cannot be null.");
+ if (toIdentityObject == null) throw new IllegalArgumentException("IdentityObjectRelationship.toIdentityObject cannot be null.");
+ if (type == null) throw new IllegalArgumentException("IdentityObjectRelationship.type cannot be null.");
+
this.fromIdentityObject = fromIdentityObject;
this.toIdentityObject = toIdentityObject;
this.name = name;
@@ -48,4 +52,37 @@
{
return type;
}
+
+ @Override
+ public boolean equals(Object value)
+ {
+ if (!(value instanceof IdentityObjectRelationship)) return false;
+ IdentityObjectRelationship other = (IdentityObjectRelationship) value;
+
+ if (!fromIdentityObject.equals(other.getFromIdentityObject())) return false;
+ if (!toIdentityObject.equals(other.getToIdentityObject())) return false;
+ if (!type.equals(other.getType())) return false;
+ if (name == null)
+ {
+ if (other.getName() != null) return false;
+ }
+ else
+ {
+ if (!name.equals(other.getName())) return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int hash = (fromIdentityObject.hashCode() * 11) ^
+ (toIdentityObject.hashCode() * 17) ^
+ (type.hashCode() * 23);
+
+ if (name != null) hash ^= (name.hashCode() * 29);
+
+ return hash;
+ }
}
Added: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityObjectRelationshipTypeImpl.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityObjectRelationshipTypeImpl.java (rev 0)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityObjectRelationshipTypeImpl.java 2010-07-15 01:31:24 UTC (rev 13397)
@@ -0,0 +1,45 @@
+package org.jboss.seam.security.management;
+
+import java.io.Serializable;
+
+import org.picketlink.idm.spi.model.IdentityObjectRelationshipType;
+
+/**
+ * Simple implementation of IdentityObjectRelationshipType
+ *
+ * @author Shane Bryzak
+ */
+public class IdentityObjectRelationshipTypeImpl implements IdentityObjectRelationshipType, Serializable
+{
+ private static final long serialVersionUID = 6389479876202629001L;
+
+ private String name;
+
+ public IdentityObjectRelationshipTypeImpl(String name)
+ {
+ if (name == null) throw new IllegalArgumentException("IdentityObjectRelationshipType.name cannot be null.");
+
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ @Override
+ public boolean equals(Object value)
+ {
+ if (!(value instanceof IdentityObjectRelationshipType)) return false;
+ IdentityObjectRelationshipType other = (IdentityObjectRelationshipType) value;
+
+ return name.equals(other.getName());
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return name.hashCode();
+ }
+
+}
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityObjectTypeImpl.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityObjectTypeImpl.java 2010-07-15 01:30:40 UTC (rev 13396)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityObjectTypeImpl.java 2010-07-15 01:31:24 UTC (rev 13397)
@@ -17,6 +17,7 @@
public IdentityObjectTypeImpl(String name)
{
+ if (name == null) throw new IllegalArgumentException("IdentityObjectType name cannot be null");
this.name = name;
}
@@ -24,4 +25,18 @@
{
return name;
}
+
+ @Override
+ public boolean equals(Object value)
+ {
+ if (!(value instanceof IdentityObjectType)) return false;
+ IdentityObjectType other = (IdentityObjectType) value;
+ return name.equals(other.getName());
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return name.hashCode();
+ }
}
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2010-07-15 01:30:40 UTC (rev 13396)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2010-07-15 01:31:24 UTC (rev 13397)
@@ -6,6 +6,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -86,6 +87,87 @@
private static final String PROPERTY_ATTRIBUTE_VALUE = "ATTRIBUTE_VALUE";
private static final String PROPERTY_ROLE_TYPE_NAME = "ROLE_TYPE_NAME";
+
+ private class EntityToSpiConverter
+ {
+ private static final String IDENTITY_TYPE_CACHE_PREFIX = "identity_type:";
+ private static final String RELATIONSHIP_TYPE_CACHE_PREFIX = "relationship_type:";
+
+ private Map<Object,Object> cache = new HashMap<Object,Object>();
+
+ private Property<?> identityIdProperty = modelProperties.get(PROPERTY_IDENTITY_ID);
+ private Property<?> identityNameProperty = modelProperties.get(PROPERTY_IDENTITY_NAME);
+ private Property<?> identityTypeProperty = modelProperties.get(PROPERTY_IDENTITY_TYPE);
+ private Property<?> identityTypeNameProperty = modelProperties.get(PROPERTY_IDENTITY_TYPE_NAME);
+ private Property<?> relationshipTypeNameProperty = modelProperties.get(PROPERTY_RELATIONSHIP_TYPE_NAME);
+
+ public IdentityObject convertToIdentityObject(Object entity)
+ {
+ if (!identityClass.isAssignableFrom(entity.getClass()))
+ {
+ throw new IllegalArgumentException("Invalid identity entity");
+ }
+
+ if (cache.containsKey(entity))
+ {
+ return (IdentityObject) cache.get(entity);
+ }
+ else
+ {
+ IdentityObject obj = new IdentityObjectImpl(
+ (String) identityIdProperty.getValue(entity),
+ (String) identityNameProperty.getValue(entity),
+ convertToIdentityObjectType(identityTypeProperty.getValue(entity)));
+ cache.put(entity, obj);
+
+ return obj;
+ }
+ }
+
+ public IdentityObjectType convertToIdentityObjectType(Object value)
+ {
+ if (value instanceof String)
+ {
+ String key = IDENTITY_TYPE_CACHE_PREFIX + (String) value;
+ if (cache.containsKey(key)) return (IdentityObjectType) cache.get(key);
+
+ IdentityObjectType type = new IdentityObjectTypeImpl((String) value);
+ cache.put(key, type);
+ return type;
+ }
+ else
+ {
+ if (cache.containsKey(value)) return (IdentityObjectType) cache.get(value);
+ IdentityObjectType type = new IdentityObjectTypeImpl(
+ (String) identityTypeNameProperty.getValue(value));
+ cache.put(value, type);
+ return type;
+ }
+ }
+
+ public IdentityObjectRelationshipType convertToRelationshipType(Object value)
+ {
+ if (value instanceof String)
+ {
+ String key = RELATIONSHIP_TYPE_CACHE_PREFIX + (String) value;
+ if (cache.containsKey(key)) return (IdentityObjectRelationshipType) cache.get(key);
+
+ IdentityObjectRelationshipType type = new IdentityObjectRelationshipTypeImpl((String) value);
+ cache.put(key, type);
+ return type;
+ }
+ else
+ {
+ if (cache.containsKey(value)) return (IdentityObjectRelationshipType) cache.get(value);
+ IdentityObjectRelationshipType type = new IdentityObjectRelationshipTypeImpl(
+ (String) relationshipTypeNameProperty.getValue(value));
+ cache.put(value, type);
+ return type;
+ }
+ }
+ }
+
+
private String id;
// Entity classes
@@ -1083,12 +1165,6 @@
return null;
}
}
-
- protected IdentityObjectType convertType(Object obj)
- {
- // TODO implement
- return null;
- }
public IdentityObject findIdentityObject(
IdentityStoreInvocationContext invocationContext, String name,
@@ -1317,13 +1393,63 @@
}
public Set<IdentityObjectRelationship> resolveRelationships(
- IdentityStoreInvocationContext invocationCxt,
+ IdentityStoreInvocationContext ctx,
IdentityObject fromIdentity, IdentityObject toIdentity,
IdentityObjectRelationshipType relationshipType)
throws IdentityException
{
- // TODO Auto-generated method stub
- return null;
+ Set<IdentityObjectRelationship> relationships = new HashSet<IdentityObjectRelationship>();
+
+ EntityManager em = getEntityManager(ctx);
+
+ CriteriaBuilder builder = em.getCriteriaBuilder();
+ CriteriaQuery<?> criteria = builder.createQuery(relationshipClass);
+ Root<?> root = criteria.from(relationshipClass);
+
+ Property<?> relationshipFromProp = modelProperties.get(PROPERTY_RELATIONSHIP_FROM);
+ Property<?> relationshipToProp = modelProperties.get(PROPERTY_RELATIONSHIP_TO);
+ Property<?> relationshipTypeProp = modelProperties.get(PROPERTY_RELATIONSHIP_TYPE);
+ Property<?> relationshipNameProp = modelProperties.get(PROPERTY_RELATIONSHIP_NAME);
+
+ List<Predicate> predicates = new ArrayList<Predicate>();
+
+ if (fromIdentity != null)
+ {
+ predicates.add(builder.equal(root.get(relationshipFromProp.getName()),
+ lookupIdentity(fromIdentity, em)));
+ }
+
+ if (toIdentity != null)
+ {
+ predicates.add(builder.equal(root.get(relationshipToProp.getName()),
+ lookupIdentity(toIdentity, em)));
+ }
+
+ if (relationshipType != null)
+ {
+ predicates.add(builder.equal(root.get(relationshipTypeProp.getName()),
+ lookupRelationshipType(relationshipType, em)));
+ }
+
+ criteria.where(predicates.toArray(new Predicate[0]));
+
+ List<?> results = em.createQuery(criteria).getResultList();
+
+ EntityToSpiConverter converter = new EntityToSpiConverter();
+
+ for (Object result : results)
+ {
+ IdentityObjectRelationship relationship = new IdentityObjectRelationshipImpl(
+ converter.convertToIdentityObject(relationshipFromProp.getValue(result)),
+ converter.convertToIdentityObject(relationshipToProp.getValue(result)),
+ (String) relationshipNameProp.getValue(result),
+ converter.convertToRelationshipType(relationshipTypeProp.getValue(result))
+ );
+
+ relationships.add(relationship);
+ }
+
+ return relationships;
}
public Set<IdentityObjectRelationship> resolveRelationships(
13 years, 11 months
Seam SVN: r13396 - in modules/security/trunk/examples/idmconsole/src/main: resources and 2 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-14 21:30:40 -0400 (Wed, 14 Jul 2010)
New Revision: 13396
Modified:
modules/security/trunk/examples/idmconsole/src/main/java/org/jboss/seam/security/examples/idmconsole/model/IdentityObjectRelationship.java
modules/security/trunk/examples/idmconsole/src/main/resources/import.sql
modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/classes/seam-beans.xml
modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/security-rules.drl
Log:
add some relationships
Modified: modules/security/trunk/examples/idmconsole/src/main/java/org/jboss/seam/security/examples/idmconsole/model/IdentityObjectRelationship.java
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/java/org/jboss/seam/security/examples/idmconsole/model/IdentityObjectRelationship.java 2010-07-14 22:39:48 UTC (rev 13395)
+++ modules/security/trunk/examples/idmconsole/src/main/java/org/jboss/seam/security/examples/idmconsole/model/IdentityObjectRelationship.java 2010-07-15 01:30:40 UTC (rev 13396)
@@ -5,6 +5,7 @@
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.jboss.seam.security.annotations.management.IdentityProperty;
@@ -22,7 +23,7 @@
private Long id;
private String name;
- private IdentityObjectRelationshipType type;
+ private IdentityObjectRelationshipType relationshipType;
private IdentityObject from;
private IdentityObject to;
@@ -47,18 +48,18 @@
this.name = name;
}
- @ManyToOne @IdentityProperty(PropertyType.TYPE)
- public IdentityObjectRelationshipType getType()
+ @ManyToOne @IdentityProperty(PropertyType.TYPE) @JoinColumn(name = "RELATIONSHIP_TYPE_ID")
+ public IdentityObjectRelationshipType getRelationshipType()
{
- return type;
+ return relationshipType;
}
- public void setType(IdentityObjectRelationshipType type)
+ public void setRelationshipType(IdentityObjectRelationshipType relationshipType)
{
- this.type = type;
+ this.relationshipType = relationshipType;
}
- @ManyToOne @IdentityProperty(PropertyType.RELATIONSHIP_FROM)
+ @ManyToOne @IdentityProperty(PropertyType.RELATIONSHIP_FROM) @JoinColumn(name = "FROM_IDENTITY_ID")
public IdentityObject getFrom()
{
return from;
@@ -69,7 +70,7 @@
this.from = from;
}
- @ManyToOne @IdentityProperty(PropertyType.RELATIONSHIP_TO)
+ @ManyToOne @IdentityProperty(PropertyType.RELATIONSHIP_TO) @JoinColumn(name = "TO_IDENTITY_ID")
public IdentityObject getTo()
{
return to;
Modified: modules/security/trunk/examples/idmconsole/src/main/resources/import.sql
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/resources/import.sql 2010-07-14 22:39:48 UTC (rev 13395)
+++ modules/security/trunk/examples/idmconsole/src/main/resources/import.sql 2010-07-15 01:30:40 UTC (rev 13396)
@@ -3,9 +3,14 @@
insert into IdentityObject (id, name, identity_object_type_id) values (1, 'shane', 1);
insert into IdentityObject (id, name, identity_object_type_id) values (2, 'demo', 1);
+insert into IdentityObject (id, name, identity_object_type_id) values (3, 'Head Office', 2);
insert into IdentityObjectCredentialType (id, name) values (1, 'PASSWORD');
insert into IdentityObjectCredential (id, identity_object_id, credential_type_id, value) values (1, 1, 1, 'password');
insert into IdentityObjectCredential (id, identity_object_id, credential_type_id, value) values (2, 2, 1, 'demo');
+insert into IdentityObjectRelationshipType (id, name) values (1, 'MEMBER_OF');
+insert into IdentityObjectRelationshipType (id, name) values (2, 'ROLE');
+
+insert into IdentityObjectRelationship (id, name, relationship_type_id, identity_from_id, identity_to_id) values (1, 'admin', 2, 1, 3);
Modified: modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/classes/seam-beans.xml
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/classes/seam-beans.xml 2010-07-14 22:39:48 UTC (rev 13395)
+++ modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/classes/seam-beans.xml 2010-07-15 01:30:40 UTC (rev 13396)
@@ -14,7 +14,7 @@
</security:JpaPermissionStore>
<drools:RuleResources>
- <s:modifies/>
+ <s:overrides/>
<security:SecurityRulesConfig/>
<drools:resources>
<s:value>classpath;security-rules.drl;DRL</s:value>
@@ -31,20 +31,7 @@
</drools:DroolsConfig>
<security:RuleBasedPermissionResolver>
- <s:overrides/>
-
- <security:manager>
- <s:Inject/>
- </security:manager>
-
- <security:identity>
- <s:Inject/>
- </security:identity>
-
- <security:init>
- <s:Inject/>
- </security:init>
-
+ <s:modifies/>
<security:securityRules>
<security:SecurityRulesConfig/>
<s:Inject/>
Modified: modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/security-rules.drl
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/security-rules.drl 2010-07-14 22:39:48 UTC (rev 13395)
+++ modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/security-rules.drl 2010-07-15 01:30:40 UTC (rev 13396)
@@ -34,7 +34,7 @@
******************************************************************************************/
-rule ManageUsers
+rule ManageIdentities
no-loop
activation-group "permissions"
when
@@ -43,12 +43,3 @@
check.grant();
end
-rule ManageRoles
- no-loop
- activation-group "permissions"
-when
- check: PermissionCheck(resource == "seam.role", granted == false)
-// Role(name == "admin")
-then
- check.grant();
-end
13 years, 11 months
Seam SVN: r13395 - in sandbox/encore: shell/src/main/java/org/jboss/encore/shell/cli/builtin and 1 other directories.
by seam-commits@lists.jboss.org
Author: lincolnthree
Date: 2010-07-14 18:39:48 -0400 (Wed, 14 Jul 2010)
New Revision: 13395
Added:
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/ClearPlugin.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/PwdPlugin.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Help.java
Modified:
sandbox/encore/model/
Log:
* A few more plugins
* SVN ignores
Property changes on: sandbox/encore/model
___________________________________________________________________
Name: svn:ignore
- target
+ target
.settings
.classpath
.project
Added: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/ClearPlugin.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/ClearPlugin.java (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/ClearPlugin.java 2010-07-14 22:39:48 UTC (rev 13395)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.shell.cli.builtin;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jboss.encore.shell.Shell;
+import org.jboss.encore.shell.plugins.Command;
+import org.jboss.encore.shell.plugins.Default;
+import org.jboss.encore.shell.plugins.Help;
+import org.jboss.encore.shell.plugins.Plugin;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ */
+@Named("clear")
+@Help("Clears the console output.")
+public class ClearPlugin implements Plugin
+{
+ @Inject
+ Shell shell;
+
+ @Default
+ @Command
+ public void run()
+ {
+ shell.clear();
+ }
+}
Added: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/PwdPlugin.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/PwdPlugin.java (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/PwdPlugin.java 2010-07-14 22:39:48 UTC (rev 13395)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.shell.cli.builtin;
+
+import java.io.File;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jboss.encore.shell.Shell;
+import org.jboss.encore.shell.plugins.Command;
+import org.jboss.encore.shell.plugins.Default;
+import org.jboss.encore.shell.plugins.Help;
+import org.jboss.encore.shell.plugins.Plugin;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ */
+@Named("pwd")
+@Help("Prints the current directory.")
+public class PwdPlugin implements Plugin
+{
+ @Inject
+ Shell shell;
+
+ @Default
+ @Command
+ public void run()
+ {
+ String currentDir = new File(".").getAbsolutePath();
+ shell.write(currentDir);
+ }
+}
Added: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Help.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Help.java (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Help.java 2010-07-14 22:39:48 UTC (rev 13395)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.shell.plugins;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Describes help text for a plug-in.
+ *
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+@Target({ TYPE })
+@Retention(RUNTIME)
+@Documented
+public @interface Help
+{
+ /**
+ * The help text.
+ */
+ String value();
+}
13 years, 11 months
Seam SVN: r13394 - sandbox/encore/model.
by seam-commits@lists.jboss.org
Author: lincolnthree
Date: 2010-07-14 18:38:19 -0400 (Wed, 14 Jul 2010)
New Revision: 13394
Removed:
sandbox/encore/model/.classpath
sandbox/encore/model/.project
sandbox/encore/model/.settings/
Modified:
sandbox/encore/model/
Log:
preparing for ignores
Property changes on: sandbox/encore/model
___________________________________________________________________
Name: svn:ignore
+ target
Deleted: sandbox/encore/model/.classpath
===================================================================
--- sandbox/encore/model/.classpath 2010-07-14 22:36:54 UTC (rev 13393)
+++ sandbox/encore/model/.classpath 2010-07-14 22:38:19 UTC (rev 13394)
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" output="target/classes" path="src/main/java"/>
- <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
- <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
- <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
Deleted: sandbox/encore/model/.project
===================================================================
--- sandbox/encore/model/.project 2010-07-14 22:36:54 UTC (rev 13393)
+++ sandbox/encore/model/.project 2010-07-14 22:38:19 UTC (rev 13394)
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>model</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.wst.common.project.facet.core.builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.maven.ide.eclipse.maven2Builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.maven.ide.eclipse.maven2Nature</nature>
- <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
- </natures>
-</projectDescription>
13 years, 11 months
Seam SVN: r13393 - in sandbox/encore: model and 16 other directories.
by seam-commits@lists.jboss.org
Author: lincolnthree
Date: 2010-07-14 18:36:54 -0400 (Wed, 14 Jul 2010)
New Revision: 13393
Added:
sandbox/encore/model/
sandbox/encore/model/.classpath
sandbox/encore/model/.project
sandbox/encore/model/.settings/
sandbox/encore/model/.settings/org.eclipse.jdt.core.prefs
sandbox/encore/model/.settings/org.maven.ide.eclipse.prefs
sandbox/encore/model/pom.xml
sandbox/encore/model/src/
sandbox/encore/model/src/main/
sandbox/encore/model/src/main/java/
sandbox/encore/model/src/main/java/org/
sandbox/encore/model/src/main/java/org/jboss/
sandbox/encore/model/src/main/java/org/jboss/encore/
sandbox/encore/model/src/main/java/org/jboss/encore/model/
sandbox/encore/model/src/main/java/org/jboss/encore/model/AbstractProject.java
sandbox/encore/model/src/main/java/org/jboss/encore/model/MavenJavaProject.java
sandbox/encore/model/src/main/java/org/jboss/encore/model/Project.java
sandbox/encore/model/src/main/java/org/jboss/encore/model/events/
sandbox/encore/model/src/main/java/org/jboss/encore/model/events/FileCreated.java
sandbox/encore/model/src/main/java/org/jboss/encore/model/events/FileEvent.java
sandbox/encore/model/src/main/java/org/jboss/encore/model/events/JavaFileCreated.java
sandbox/encore/model/src/main/resources/
sandbox/encore/model/src/main/resources/META-INF/
sandbox/encore/model/src/main/resources/META-INF/beans.xml
sandbox/encore/model/src/test/
sandbox/encore/model/src/test/java/
sandbox/encore/model/src/test/resources/
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/HelpPlugin.java
Removed:
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Help.java
Modified:
sandbox/encore/pom.xml
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginCommandCompletionHandler.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginMetadata.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/ExitShell.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Option.java
Log:
Began project meta-model API, can remove methods from java files
Added: sandbox/encore/model/.classpath
===================================================================
--- sandbox/encore/model/.classpath (rev 0)
+++ sandbox/encore/model/.classpath 2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: sandbox/encore/model/.project
===================================================================
--- sandbox/encore/model/.project (rev 0)
+++ sandbox/encore/model/.project 2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>model</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ </natures>
+</projectDescription>
Added: sandbox/encore/model/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- sandbox/encore/model/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ sandbox/encore/model/.settings/org.eclipse.jdt.core.prefs 2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,6 @@
+#Wed Jul 14 14:23:58 EDT 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
Added: sandbox/encore/model/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- sandbox/encore/model/.settings/org.maven.ide.eclipse.prefs (rev 0)
+++ sandbox/encore/model/.settings/org.maven.ide.eclipse.prefs 2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,9 @@
+#Wed Jul 14 14:23:58 EDT 2010
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1
Added: sandbox/encore/model/pom.xml
===================================================================
--- sandbox/encore/model/pom.xml (rev 0)
+++ sandbox/encore/model/pom.xml 2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,33 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>encore</artifactId>
+ <groupId>org.jboss.encore</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>model</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <packaging>jar</packaging>
+ <name>Encore Project Model APIs</name>
+ <description>Simplified project bootstrapping and incremental enhancement framework</description>
+
+ <dependencies>
+ <!-- Resource manipulation dependencies -->
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-api</artifactId>
+ <version>1.0.0-alpha-9</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+
+</project>
Added: sandbox/encore/model/src/main/java/org/jboss/encore/model/AbstractProject.java
===================================================================
--- sandbox/encore/model/src/main/java/org/jboss/encore/model/AbstractProject.java (rev 0)
+++ sandbox/encore/model/src/main/java/org/jboss/encore/model/AbstractProject.java 2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.model;
+
+import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.enterprise.event.Event;
+import javax.inject.Inject;
+
+import org.jboss.encore.model.events.JavaFileCreated;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public abstract class AbstractProject implements Project
+{
+ @Inject
+ Event<JavaFileCreated> event;
+
+ public boolean createJavaFile(final String path, final byte[] data)
+ {
+ return createJavaFile(path, new ByteArrayInputStream(data));
+ }
+
+ public boolean createJavaFile(final String path, final InputStream data)
+ {
+ BufferedWriter writer = null;
+ try
+ {
+ File file = new File(path);
+ writer = new BufferedWriter(new FileWriter(file));
+ event.fire(new JavaFileCreated(file));
+ writer.close();
+ return true;
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Added: sandbox/encore/model/src/main/java/org/jboss/encore/model/MavenJavaProject.java
===================================================================
--- sandbox/encore/model/src/main/java/org/jboss/encore/model/MavenJavaProject.java (rev 0)
+++ sandbox/encore/model/src/main/java/org/jboss/encore/model/MavenJavaProject.java 2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.model;
+
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public class MavenJavaProject extends AbstractProject
+{
+
+}
Added: sandbox/encore/model/src/main/java/org/jboss/encore/model/Project.java
===================================================================
--- sandbox/encore/model/src/main/java/org/jboss/encore/model/Project.java (rev 0)
+++ sandbox/encore/model/src/main/java/org/jboss/encore/model/Project.java 2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.model;
+
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public interface Project
+{
+}
Added: sandbox/encore/model/src/main/java/org/jboss/encore/model/events/FileCreated.java
===================================================================
--- sandbox/encore/model/src/main/java/org/jboss/encore/model/events/FileCreated.java (rev 0)
+++ sandbox/encore/model/src/main/java/org/jboss/encore/model/events/FileCreated.java 2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.model.events;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public class FileCreated extends FileEvent
+{
+ public FileCreated(final File file)
+ {
+ super(file);
+ }
+
+}
Added: sandbox/encore/model/src/main/java/org/jboss/encore/model/events/FileEvent.java
===================================================================
--- sandbox/encore/model/src/main/java/org/jboss/encore/model/events/FileEvent.java (rev 0)
+++ sandbox/encore/model/src/main/java/org/jboss/encore/model/events/FileEvent.java 2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.model.events;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public class FileEvent
+{
+ private final File file;
+
+ public FileEvent(final File file)
+ {
+ this.file = file;
+ }
+
+ public File getFile()
+ {
+ return file;
+ }
+}
Added: sandbox/encore/model/src/main/java/org/jboss/encore/model/events/JavaFileCreated.java
===================================================================
--- sandbox/encore/model/src/main/java/org/jboss/encore/model/events/JavaFileCreated.java (rev 0)
+++ sandbox/encore/model/src/main/java/org/jboss/encore/model/events/JavaFileCreated.java 2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.model.events;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public class JavaFileCreated extends FileCreated
+{
+ public JavaFileCreated(final File file)
+ {
+ super(file);
+ }
+}
Added: sandbox/encore/model/src/main/resources/META-INF/beans.xml
===================================================================
--- sandbox/encore/model/src/main/resources/META-INF/beans.xml (rev 0)
+++ sandbox/encore/model/src/main/resources/META-INF/beans.xml 2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans>
+</beans>
Modified: sandbox/encore/pom.xml
===================================================================
--- sandbox/encore/pom.xml 2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/pom.xml 2010-07-14 22:36:54 UTC (rev 13393)
@@ -13,6 +13,7 @@
<modules>
<module>core</module>
+ <module>model</module>
<module>shell</module>
</modules>
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java 2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java 2010-07-14 22:36:54 UTC (rev 13393)
@@ -160,4 +160,19 @@
{
return prompt("");
}
+
+ public void clear()
+ {
+ try
+ {
+ String currentPrompt = reader.getPrompt();
+ reader.setPrompt("");
+ reader.clearScreen();
+ reader.setPrompt(currentPrompt);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
}
\ No newline at end of file
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java 2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java 2010-07-14 22:36:54 UTC (rev 13393)
@@ -36,6 +36,7 @@
import org.jboss.encore.shell.plugins.Command;
import org.jboss.encore.shell.plugins.Default;
+import org.jboss.encore.shell.plugins.Help;
import org.jboss.encore.shell.plugins.Option;
import org.jboss.encore.shell.plugins.Plugin;
import org.jboss.encore.shell.util.Annotations;
@@ -69,6 +70,11 @@
pluginMeta.setName(name);
pluginMeta.setType(plugin);
+ if (Annotations.isAnnotationPresent(plugin, Help.class))
+ {
+ pluginMeta.setHelp(Annotations.getAnnotation(plugin, Help.class).value());
+ }
+
List<CommandMetadata> commands = getPluginCommands(pluginMeta, plugin);
pluginMeta.setCommands(commands);
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginCommandCompletionHandler.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginCommandCompletionHandler.java 2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginCommandCompletionHandler.java 2010-07-14 22:36:54 UTC (rev 13393)
@@ -52,7 +52,7 @@
String pluginName = p.getValue().getName();
if (isPotentialMatch(pluginName, token))
{
- candidates.add(pluginName + " ");
+ candidates.add(pluginName);
}
}
}
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginMetadata.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginMetadata.java 2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginMetadata.java 2010-07-14 22:36:54 UTC (rev 13393)
@@ -32,6 +32,7 @@
*/
public class PluginMetadata
{
+ private String help;
private String name;
private Class<? extends Plugin> type;
private List<CommandMetadata> commands = new ArrayList<CommandMetadata>();
@@ -109,4 +110,14 @@
{
return "PluginMetadata [name=" + name + ", type=" + type + ", commands=" + commands + "]";
}
+
+ public String getHelp()
+ {
+ return help;
+ }
+
+ public void setHelp(final String help)
+ {
+ this.help = help;
+ }
}
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java 2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java 2010-07-14 22:36:54 UTC (rev 13393)
@@ -26,15 +26,14 @@
import org.jboss.encore.shell.Shell;
import org.jboss.encore.shell.plugins.Command;
import org.jboss.encore.shell.plugins.Default;
+import org.jboss.encore.shell.plugins.Help;
import org.jboss.encore.shell.plugins.Option;
import org.jboss.encore.shell.plugins.Plugin;
/**
- * Implements a demonstration {@link Plugin}
- *
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
- *
*/
+@Help("Writes input to output.")
public class Echo implements Plugin
{
@Inject
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/ExitShell.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/ExitShell.java 2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/ExitShell.java 2010-07-14 22:36:54 UTC (rev 13393)
@@ -28,23 +28,24 @@
import org.jboss.encore.shell.events.Shutdown;
import org.jboss.encore.shell.plugins.Command;
import org.jboss.encore.shell.plugins.Default;
+import org.jboss.encore.shell.plugins.Help;
import org.jboss.encore.shell.plugins.Plugin;
/**
- * Implements a {@link Plugin} that fires the shell {@link Shutdown#NORMAL}
- * event.
+ * Implements a {@link Plugin} that fires the shell {@link Shutdown#NORMAL} event.
*
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*
*/
@Named("exit")
+@Help("Exits the shell.")
public class ExitShell implements Plugin
{
@Inject
private Event<Shutdown> shutdown;
@Default
- @Command(help = "Exit the shell")
+ @Command
public void exit()
{
shutdown.fire(Shutdown.NORMAL);
Deleted: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Help.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Help.java 2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Help.java 2010-07-14 22:36:54 UTC (rev 13393)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.encore.shell.cli.builtin;
-
-import java.util.Arrays;
-
-import org.jboss.encore.shell.events.Shutdown;
-import org.jboss.encore.shell.plugins.Command;
-import org.jboss.encore.shell.plugins.Default;
-import org.jboss.encore.shell.plugins.Option;
-import org.jboss.encore.shell.plugins.Plugin;
-
-/**
- * Implements a {@link Plugin} that fires the shell {@link Shutdown#NORMAL}
- * event.
- *
- * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
- *
- */
-public class Help implements Plugin
-{
- @Default
- @Command(help = "Get help about specific commands")
- public void help(@Option("test") final String test, @Option final String... commands)
- {
- if (commands == null)
- {
- System.out.println("Welcome to Encore!");
- }
- else
- {
- System.out.println("You requested help for: " + Arrays.deepToString(commands));
- }
- }
-}
Copied: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/HelpPlugin.java (from rev 13389, sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Help.java)
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/HelpPlugin.java (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/HelpPlugin.java 2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.shell.cli.builtin;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jboss.encore.shell.Shell;
+import org.jboss.encore.shell.cli.PluginRegistry;
+import org.jboss.encore.shell.plugins.Command;
+import org.jboss.encore.shell.plugins.Default;
+import org.jboss.encore.shell.plugins.Help;
+import org.jboss.encore.shell.plugins.Option;
+import org.jboss.encore.shell.plugins.Plugin;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ */
+@Named("help")
+@Help("Displays help text for specified plugins & commands.")
+public class HelpPlugin implements Plugin
+{
+ @Inject
+ PluginRegistry registry;
+
+ @Inject
+ Shell shell;
+
+ @Default
+ @Command(help = "Get help about specific commands")
+ public void help(@Option("test") final String test, @Option final String... commands)
+ {
+ if (commands == null)
+ {
+ shell.write("Welcome to Encore!");
+ }
+ else
+ {
+ shell.write("[" + commands[0] + "] " + registry.getPlugins().get(commands[0]).getHelp());
+ }
+ }
+}
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Option.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Option.java 2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Option.java 2010-07-14 22:36:54 UTC (rev 13393)
@@ -44,7 +44,7 @@
public @interface Option
{
/**
- * The name of this option;
+ * The name of this option.
*/
String value() default "";
13 years, 11 months
Seam SVN: r13392 - in branches/enterprise/JBPAPP_5_0: seam-gen and 1 other directory.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-14 17:11:09 -0400 (Wed, 14 Jul 2010)
New Revision: 13392
Modified:
branches/enterprise/JBPAPP_5_0/build/gen.pom.xml
branches/enterprise/JBPAPP_5_0/seam-gen/build.xml
Log:
JBPAPP-4570 eliminated duplicated slf4j-* jars in lib/gen
Modified: branches/enterprise/JBPAPP_5_0/build/gen.pom.xml
===================================================================
--- branches/enterprise/JBPAPP_5_0/build/gen.pom.xml 2010-07-14 16:27:07 UTC (rev 13391)
+++ branches/enterprise/JBPAPP_5_0/build/gen.pom.xml 2010-07-14 21:11:09 UTC (rev 13392)
@@ -150,17 +150,17 @@
</exclusions>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <optional>true</optional>
- <exclusions>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+<!-- <dependency>-->
+<!-- <groupId>org.slf4j</groupId>-->
+<!-- <artifactId>slf4j-log4j12</artifactId>-->
+<!-- <optional>true</optional>-->
+<!-- <exclusions>-->
+<!-- <exclusion>-->
+<!-- <groupId>log4j</groupId>-->
+<!-- <artifactId>log4j</artifactId>-->
+<!-- </exclusion>-->
+<!-- </exclusions>-->
+<!-- </dependency>-->
</dependencies>
Modified: branches/enterprise/JBPAPP_5_0/seam-gen/build.xml
===================================================================
--- branches/enterprise/JBPAPP_5_0/seam-gen/build.xml 2010-07-14 16:27:07 UTC (rev 13391)
+++ branches/enterprise/JBPAPP_5_0/seam-gen/build.xml 2010-07-14 21:11:09 UTC (rev 13392)
@@ -1351,7 +1351,7 @@
<pathelement path="${seam.dir}/lib/hibernate-entitymanager.jar"/>
<pathelement path="${seam.dir}/lib/hibernate-validator.jar"/>
<pathelement path="${seam.dir}/lib/slf4j-api.jar"/>
- <pathelement path="${seam.dir}/lib/gen/slf4j-log4j12.jar"/>
+ <pathelement path="${seam.dir}/lib/slf4j-log4j12.jar"/>
<pathelement path="${seam.dir}/lib/log4j.jar"/>
<pathelement path="${seam.dir}/lib/commons-collections.jar"/>
<pathelement path="${seam.dir}/lib/commons-logging.jar"/>
13 years, 11 months
Seam SVN: r13391 - in sandbox/encore: core/src/test/java/org/jboss/encore/grammar/java and 3 other directories.
by seam-commits@lists.jboss.org
Author: lincolnthree
Date: 2010-07-14 12:27:07 -0400 (Wed, 14 Jul 2010)
New Revision: 13391
Modified:
sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/JavaClass.java
sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java
Log:
Default commands may no longer be executed by plug-in-name + command-name, only by plugin-name (arguments matching the command method name are now treated as regular parameters to the default command.)
Parser can now remove java methods.
Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/JavaClass.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/JavaClass.java 2010-07-14 16:03:24 UTC (rev 13390)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/JavaClass.java 2010-07-14 16:27:07 UTC (rev 13391)
@@ -176,7 +176,7 @@
{
if (getMethods().contains(method))
{
- getTypeDeclaration().bodyDeclarations().remove(method);
+ getTypeDeclaration().bodyDeclarations().remove(method.getInternal());
}
return this;
}
Modified: sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java 2010-07-14 16:03:24 UTC (rev 13390)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java 2010-07-14 16:27:07 UTC (rev 13391)
@@ -107,10 +107,10 @@
public void testRemoveMethod() throws Exception
{
// TODO Removing methods needs to work
- // List<Method> methods = javaClass.getMethods();
- // javaClass.removeMethod(methods.get(0)).applyChanges();
- // methods = javaClass.getMethods();
- // assertEquals(1, methods.size());
+ List<Method> methods = javaClass.getMethods();
+ javaClass.removeMethod(methods.get(0)).applyChanges();
+ methods = javaClass.getMethods();
+ assertEquals(1, methods.size());
}
@Test
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java 2010-07-14 16:03:24 UTC (rev 13390)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java 2010-07-14 16:27:07 UTC (rev 13391)
@@ -136,8 +136,10 @@
{
String currentPrompt = reader.getPrompt();
reader.setPrompt(" ");
+ reader.removeCompleter(completer);
String line = reader.readLine();
reader.setPrompt(currentPrompt);
+ reader.addCompleter(completer);
return line;
}
catch (IOException e)
@@ -153,4 +155,9 @@
{
System.out.println(line);
}
+
+ public String prompt()
+ {
+ return prompt("");
+ }
}
\ No newline at end of file
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java 2010-07-14 16:03:24 UTC (rev 13390)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java 2010-07-14 16:27:07 UTC (rev 13391)
@@ -95,14 +95,18 @@
commandMeta.setDefault(true);
}
- if (command.value().length == 0)
+ // Default commands are invoked via the name of the plug-in, not by plug-in + command
+ if (!commandMeta.isDefault())
{
- commandMeta.setNames(m.getName().toLowerCase());
+ if (command.value().length == 0)
+ {
+ commandMeta.setNames(m.getName().toLowerCase());
+ }
+ else
+ {
+ commandMeta.setNames(command.value());
+ }
}
- else
- {
- commandMeta.setNames(command.value());
- }
Class<?>[] parameterTypes = m.getParameterTypes();
Annotation[][] parameterAnnotations = m.getParameterAnnotations();
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java 2010-07-14 16:03:24 UTC (rev 13390)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java 2010-07-14 16:27:07 UTC (rev 13391)
@@ -44,6 +44,11 @@
@Command(help = "This is a demo command")
public void run(@Option(help = "The text to be echoed") final String text)
{
- shell.write("Echo plugin says: \"" + text + "\"");
+ String input = text;
+ if (input == null)
+ {
+ input = shell.prompt();
+ }
+ shell.write("Echo plugin says: \"" + input + "\"");
}
}
13 years, 11 months
Seam SVN: r13390 - sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli.
by seam-commits@lists.jboss.org
Author: lincolnthree
Date: 2010-07-14 12:03:24 -0400 (Wed, 14 Jul 2010)
New Revision: 13390
Modified:
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/ExecutionParser.java
Log:
Quoted strings now respected on command line
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/ExecutionParser.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/ExecutionParser.java 2010-07-14 10:47:59 UTC (rev 13389)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/ExecutionParser.java 2010-07-14 16:03:24 UTC (rev 13390)
@@ -25,6 +25,8 @@
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
@@ -107,10 +109,20 @@
{
Queue<String> tokens = new LinkedList<String>();
- for (String token : line.split("\\s+"))
+ // -------------------------------(0-(1------)---(2---))----------
+ Matcher matcher = Pattern.compile("\"([^\"]*?)\"|(\\S+)").matcher(line);
+ while (matcher.find())
{
- tokens.add(token);
+ if (matcher.group(1) != null)
+ {
+ tokens.add(matcher.group(1));
+ }
+ else
+ {
+ tokens.add(matcher.group());
+ }
}
+
return tokens;
}
@@ -118,7 +130,9 @@
{
Map<OptionMetadata, Object> valueMap = new HashMap<OptionMetadata, Object>();
- CommandParser commandParser = new CompositeCommandParser(new NamedBooleanOptionParser(), new NamedValueOptionParser(), new NamedValueVarargsOptionParser(), new OrderedValueOptionParser(), new OrderedValueVarargsOptionParser(), new ParseErrorParser());
+ CommandParser commandParser = new CompositeCommandParser(new NamedBooleanOptionParser(),
+ new NamedValueOptionParser(), new NamedValueVarargsOptionParser(), new OrderedValueOptionParser(),
+ new OrderedValueVarargsOptionParser(), new ParseErrorParser());
commandParser.parse(command, valueMap, tokens);
13 years, 11 months
Seam SVN: r13389 - in modules/security/trunk: api/src/main/java/org/jboss/seam/security/management and 3 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-14 06:47:59 -0400 (Wed, 14 Jul 2010)
New Revision: 13389
Modified:
modules/security/trunk/api/src/main/java/org/jboss/seam/security/Identity.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/IdentityManager.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/permission/PermissionStore.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PermissionCheck.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PermissionMapper.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PersistentPermissionResolver.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
Log:
got rule-based permissions resolving
Modified: modules/security/trunk/api/src/main/java/org/jboss/seam/security/Identity.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/Identity.java 2010-07-14 10:46:56 UTC (rev 13388)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/Identity.java 2010-07-14 10:47:59 UTC (rev 13389)
@@ -141,16 +141,16 @@
void checkRole(String role, String group, String groupType);
/**
- * Checks if the currently authenticated user can perform the specified action
- * on the specified target object.
+ * Checks if the currently authenticated user has the specified permission
+ * for the specified resource.
*
- * @param target The target object for which the user wishes to perform a restricted action
- * @param action The action that the user wishes to perform
+ * @param resource The resource for which the user wishes to perform a restricted action
+ * @param permission The name of the permission that the user requires to invoke the operation
* @throws NotLoggedInException if the current user is not authenticated
* @throws AuthorizationException if the current user does not have the necessary
- * privileges to perform the specified action on the specified target object.
+ * permission for the specified resource object.
*/
- void checkPermission(Object target, String action);
+ void checkPermission(Object resource, String permission);
/**
* Filters a collection of objects by a specified action, by removing the
@@ -160,15 +160,13 @@
* @param collection The Collection to filter
* @param action The name of the action to filter by
*/
- void filterByPermission(Collection<?> collection, String action);
+ void filterByPermission(Collection<?> collection, String permission);
/**
- * Checks if the currently authenticated user has the necessary privileges to perform the
- * specified action on the specified target object.
+ * Checks if the currently authenticated user has the necessary permission for
+ * a specific resource.
*
- * @param target
- * @param action
- * @return true if the user has the required privileges, otherwise false
+ * @return true if the user has the required permission, otherwise false
*/
- boolean hasPermission(Object target, String action);
+ boolean hasPermission(Object resource, String permission);
}
Modified: modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/IdentityManager.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/IdentityManager.java 2010-07-14 10:46:56 UTC (rev 13388)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/IdentityManager.java 2010-07-14 10:47:59 UTC (rev 13389)
@@ -80,7 +80,7 @@
* @param value The value of the attribute
* @return true if the attribute was successfully set
*/
- boolean setUserAttribute(String username, String attribute, Object value);
+ void setUserAttribute(String username, String attribute, Object value);
/**
* Deletes the specified attribute value from the specified user
@@ -89,7 +89,7 @@
* @param attribute The name of the attribute to delete
* @return true if the attribute was successfully deleted
*/
- boolean deleteUserAttribute(String username, String attribute);
+ void deleteUserAttribute(String username, String attribute);
/**
* Creates a new role type
Modified: modules/security/trunk/api/src/main/java/org/jboss/seam/security/permission/PermissionStore.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/permission/PermissionStore.java 2010-07-14 10:46:56 UTC (rev 13388)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/permission/PermissionStore.java 2010-07-14 10:47:59 UTC (rev 13389)
@@ -19,4 +19,5 @@
boolean revokePermissions(List<Permission> permissions);
List<String> listAvailableActions(Object target);
void clearPermissions(Object target);
+ boolean isEnabled();
}
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java 2010-07-14 10:46:56 UTC (rev 13388)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java 2010-07-14 10:47:59 UTC (rev 13389)
@@ -26,7 +26,7 @@
import org.slf4j.LoggerFactory;
/**
- * Default IdentityManager implementation
+ * Default IdentityManager implementation, backed by PicketLink IDM
*
* @author Shane Bryzak
*/
@@ -35,9 +35,7 @@
{
private static final long serialVersionUID = 6864253169970552893L;
- public static final String USER_PERMISSION_NAME = "seam.user";
- public static final String ROLE_PERMISSION_NAME = "seam.role";
- public static final String GROUP_PERMISSION_NAME = "seam.group";
+ public static final String RESOURCE_IDENTITY = "seam.identity";
public static final String PERMISSION_CREATE = "create";
public static final String PERMISSION_READ = "read";
@@ -53,7 +51,7 @@
public boolean createUser(String name, Credential credential)
{
- identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_CREATE);
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_CREATE);
try
{
User user = identitySession.getPersistenceManager().createUser(name);
@@ -68,7 +66,7 @@
public boolean deleteUser(String name)
{
- identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_DELETE);
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_DELETE);
try
{
@@ -83,21 +81,21 @@
public boolean enableUser(String name)
{
- identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_UPDATE);
//return identityStore.enableUser(name);
return false;
}
public boolean disableUser(String name)
{
- identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_UPDATE);
//return identityStore.disableUser(name);
return false;
}
public boolean updateCredential(String name, Credential credential)
{
- identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_UPDATE);
try
{
@@ -112,49 +110,63 @@
public boolean isUserEnabled(String name)
{
- identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_READ);
//return identityStore.isUserEnabled(name);
return false;
}
- public boolean setUserAttribute(String username, String attribute, Object value)
+ public void setUserAttribute(String username, String attribute, Object value)
{
- identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
- //return identityStore.setUserAttribute(username, attribute, value);
- return false;
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_UPDATE);
+ try
+ {
+ identitySession.getAttributesManager().addAttribute(username, attribute, value);
+ }
+ catch (IdentityException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
- public boolean deleteUserAttribute(String username, String attribute)
+ public void deleteUserAttribute(String username, String attribute)
{
- identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
- //return identityStore.deleteUserAttribute(username, attribute);
- return false;
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_UPDATE);
+ try
+ {
+ identitySession.getAttributesManager().removeAttributes(username, new String[] {attribute});
+ }
+ catch (IdentityException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
public boolean grantRole(String name, String role, String groupName, String groupType)
{
- identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_UPDATE);
//return roleIdentityStore.grantRole(name, role, groupName, groupType);
return false;
}
public boolean revokeRole(String name, String role, String groupName, String groupType)
{
- identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_UPDATE);
//return roleIdentityStore.revokeRole(name, role, groupName, groupType);
return false;
}
public boolean associateUser(String groupName, String groupType, String username)
{
- identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_UPDATE);
//return identityStore.associateUser(groupName, groupType, username);
return false;
}
public boolean disassociateUser(String groupName, String groupType, String username)
{
- identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_UPDATE);
//return identityStore.disassociateUser(groupName, groupType, username);
return false;
}
@@ -171,35 +183,35 @@
public boolean createRoleType(String roleType)
{
- identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_CREATE);
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_CREATE);
//return roleIdentityStore.createRoleType(roleType);
return false;
}
public boolean deleteRoleType(String roleType)
{
- identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_DELETE);
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_DELETE);
//return roleIdentityStore.deleteRoleType(roleType);
return false;
}
public boolean createGroup(String groupName, String groupType)
{
- identity.checkPermission(GROUP_PERMISSION_NAME, PERMISSION_CREATE);
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_CREATE);
//return groupIdentityStore.createGroup(groupName, groupType);
return false;
}
public boolean deleteGroup(String groupName, String groupType)
{
- identity.checkPermission(GROUP_PERMISSION_NAME, PERMISSION_DELETE);
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_DELETE);
//return groupIdentityStore.deleteGroup(groupName, groupType);
return false;
}
public boolean userExists(String name)
{
- identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_READ);
//return identityStore.userExists(name);
return false;
}
@@ -212,7 +224,7 @@
public List<String> findUsers(String filter)
{
- identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
+ identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_READ);
UserQueryBuilder builder = identitySession.createUserQueryBuilder();
UserQuery userQuery = builder.createQuery();
@@ -237,7 +249,7 @@
public List<String> listRoleTypes()
{
- identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_READ);
+ // identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_READ);
//List<String> roles = roleIdentityStore.listRoleTypes();
return null;
@@ -276,7 +288,7 @@
public List<IdentityType> listRoleMembers(String roleType, String groupName, String groupType)
{
- identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_READ);
+ //identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_READ);
//return roleIdentityStore.listRoleMembers(roleType, groupName, groupType);
return null;
}
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2010-07-14 10:46:56 UTC (rev 13388)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2010-07-14 10:47:59 UTC (rev 13389)
@@ -1132,7 +1132,7 @@
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<?> criteria = builder.createQuery(identityClass);
- //Root<?> root = criteria.from(identityClass);
+ Root<?> root = criteria.from(identityClass);
Property<?> identityNameProp = modelProperties.get(PROPERTY_IDENTITY_NAME);
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java 2010-07-14 10:46:56 UTC (rev 13388)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java 2010-07-14 10:47:59 UTC (rev 13389)
@@ -62,6 +62,7 @@
}
}
+ private boolean enabled;
private Class<?> identityPermissionClass;
@@ -90,6 +91,7 @@
if (identityPermissionClass == null)
{
log.debug("No identityPermissionClass set, JpaPermissionStore will be unavailable.");
+ enabled = false;
return;
}
@@ -152,6 +154,8 @@
identityPermissionClass.getName() +
" - required annotation @PermissionProperty(PERMISSION) not found on any field or method.");
}
+
+ enabled = true;
}
/**
@@ -540,4 +544,9 @@
.setParameter("resource", identifier)
.executeUpdate();
}
+
+ public boolean isEnabled()
+ {
+ return enabled;
+ }
}
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PermissionCheck.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PermissionCheck.java 2010-07-14 10:46:56 UTC (rev 13388)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PermissionCheck.java 2010-07-14 10:47:59 UTC (rev 13389)
@@ -4,7 +4,7 @@
import java.util.Set;
/**
- * Used to assert permission requirements into a WorkingMemory when evaluating
+ * Used to assert permission check requirements into a StatefulSession when evaluating
* a @Restrict expression. The consequence of the rule is responsible for
* granting the permission.
*
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PermissionMapper.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PermissionMapper.java 2010-07-14 10:46:56 UTC (rev 13388)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PermissionMapper.java 2010-07-14 10:47:59 UTC (rev 13389)
@@ -11,6 +11,7 @@
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.SessionScoped;
+import javax.enterprise.context.spi.CreationalContext;
import javax.inject.Inject;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.Bean;
@@ -37,11 +38,11 @@
{
defaultResolverChain = new ArrayList<PermissionResolver>();
- Set<Bean<?>> beans = manager.getBeans(PermissionResolver.class);
- for (Bean<?> resolverBean : beans)
- {
- defaultResolverChain.add((PermissionResolver) manager.getReference(
- resolverBean, PermissionResolver.class, manager.createCreationalContext(resolverBean)));
+ Set<Bean<?>> beans = (Set<Bean<?>>) manager.getBeans(PermissionResolver.class);
+ for (Bean<?> resolverBean : beans)
+ {
+ CreationalContext<PermissionResolver> ctx = manager.createCreationalContext((Bean<PermissionResolver>) resolverBean);
+ defaultResolverChain.add(((Bean<PermissionResolver>) resolverBean).create(ctx));
}
}
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PersistentPermissionResolver.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PersistentPermissionResolver.java 2010-07-14 10:46:56 UTC (rev 13388)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PersistentPermissionResolver.java 2010-07-14 10:47:59 UTC (rev 13389)
@@ -42,6 +42,8 @@
if (!identity.isLoggedIn()) return false;
+ if (!permissionStore.isEnabled()) return false;
+
List<Permission> permissions = permissionStore.listPermissions(target, action);
String username = identity.getPrincipal().getName();
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java 2010-07-14 10:46:56 UTC (rev 13388)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java 2010-07-14 10:47:59 UTC (rev 13389)
@@ -48,7 +48,7 @@
@Inject Identity identity;
@Inject
- protected void initSecurityContext()
+ public void init()
{
if (getSecurityRules() != null)
{
@@ -84,7 +84,7 @@
{
// TODO fix
String componentName = null; // manager. Seam.getComponentName((Class) target);
- resource = componentName != null ? componentName : ((Class) resource).getName();
+ resource = componentName != null ? componentName : ((Class<?>) resource).getName();
}
check = new PermissionCheck(resource, permission);
@@ -111,7 +111,7 @@
public void filterSetByAction(Set<Object> targets, String action)
{
- Iterator iter = targets.iterator();
+ Iterator<?> iter = targets.iterator();
while (iter.hasNext())
{
Object target = iter.next();
@@ -131,15 +131,15 @@
synchronized( securityContext )
{
- if (!(target instanceof String) && !(target instanceof Class))
+ if (!(target instanceof String) && !(target instanceof Class<?>))
{
handles.add( securityContext.insert(target) );
}
- else if (target instanceof Class)
+ else if (target instanceof Class<?>)
{
// TODO fix
String componentName = null; //Seam.getComponentName((Class) target);
- target = componentName != null ? componentName : ((Class) target).getName();
+ target = componentName != null ? componentName : ((Class<?>) target).getName();
}
try
@@ -180,7 +180,6 @@
return roleCheck.isGranted();
}
- @SuppressWarnings("unchecked")
public void unAuthenticate(@Observes PostLoggedOutEvent event)
{
if (getSecurityContext() != null)
@@ -188,7 +187,7 @@
getSecurityContext().dispose();
setSecurityContext(null);
}
- initSecurityContext();
+ init();
}
/**
@@ -204,7 +203,7 @@
{
if ( IdentityImpl.ROLES_GROUP.equals( sg.getName() ) )
{
- Enumeration e = sg.members();
+ Enumeration<?> e = sg.members();
while (e.hasMoreElements())
{
Principal role = (Principal) e.nextElement();
13 years, 11 months
Seam SVN: r13388 - in modules/security/trunk/examples/idmconsole/src/main: webapp/WEB-INF and 1 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-14 06:46:56 -0400 (Wed, 14 Jul 2010)
New Revision: 13388
Modified:
modules/security/trunk/examples/idmconsole/src/main/java/org/jboss/seam/security/examples/idmconsole/model/IdentityPermission.java
modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/classes/seam-beans.xml
modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/security-rules.drl
Log:
fix rule configuration
Modified: modules/security/trunk/examples/idmconsole/src/main/java/org/jboss/seam/security/examples/idmconsole/model/IdentityPermission.java
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/java/org/jboss/seam/security/examples/idmconsole/model/IdentityPermission.java 2010-07-13 19:04:08 UTC (rev 13387)
+++ modules/security/trunk/examples/idmconsole/src/main/java/org/jboss/seam/security/examples/idmconsole/model/IdentityPermission.java 2010-07-14 10:46:56 UTC (rev 13388)
@@ -30,7 +30,8 @@
private String permission;
/**
- * Surrogate primary key value of the permission.
+ * Surrogate primary key value for the permission.
+ *
* @return
*/
@Id @GeneratedValue
@@ -118,7 +119,7 @@
/**
* The permission(s) granted for the resource. May either be a comma-separated
- * list of permission names (such as create, delete, etc) or a bitmasked
+ * list of permission names (such as create, delete, etc) or a bit-masked
* integer value, in which each bit represents a different permission.
*
* @return
Modified: modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/classes/seam-beans.xml
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/classes/seam-beans.xml 2010-07-13 19:04:08 UTC (rev 13387)
+++ modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/classes/seam-beans.xml 2010-07-14 10:46:56 UTC (rev 13388)
@@ -17,7 +17,7 @@
<s:modifies/>
<security:SecurityRulesConfig/>
<drools:resources>
- <s:value>security-rules.drl</s:value>
+ <s:value>classpath;security-rules.drl;DRL</s:value>
</drools:resources>
</drools:RuleResources>
@@ -32,11 +32,24 @@
<security:RuleBasedPermissionResolver>
<s:overrides/>
+
+ <security:manager>
+ <s:Inject/>
+ </security:manager>
+
+ <security:identity>
+ <s:Inject/>
+ </security:identity>
+
+ <security:init>
+ <s:Inject/>
+ </security:init>
+
<security:securityRules>
<security:SecurityRulesConfig/>
<s:Inject/>
<s:Default/>
</security:securityRules>
- </security:RuleBasedPermissionResolver>
+ </security:RuleBasedPermissionResolver>
</beans>
Modified: modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/security-rules.drl
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/security-rules.drl 2010-07-13 19:04:08 UTC (rev 13387)
+++ modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/security-rules.drl 2010-07-14 10:46:56 UTC (rev 13388)
@@ -1,221 +1,29 @@
-package SeamSpacePermissions;
+package IDMConsolePermissions;
dialect 'mvel'
import java.security.Principal;
import org.jboss.seam.security.permission.PermissionCheck;
-import org.jboss.seam.security.permission.RoleCheck;
-import org.jboss.seam.security.Role;
-import org.jboss.seam.security.examples.seamspace.model.BlogComment;
-import org.jboss.seam.security.examples.seamspace.model.Member;
-import org.jboss.seam.security.examples.seamspace.model.MemberAccount;
-import org.jboss.seam.security.examples.seamspace.model.MemberBlog;
-import org.jboss.seam.security.examples.seamspace.model.MemberFriend;
-import org.jboss.seam.security.examples.seamspace.model.MemberImage;
-
-# These rules allow members to manage permissions on their own images
-
-rule ManageImagePermissions
- no-loop
- activation-group "permissions"
-when
- acct: MemberAccount()
- image: MemberImage(mbr : member -> (mbr.memberId.equals(acct.member.memberId)))
- check: PermissionCheck(target == image, action == "seam.read-permissions", granted == false)
-then
- check.grant();
-end
-
-rule GrantImagePermissions
- no-loop
- activation-group "permissions"
-when
- acct: MemberAccount()
- image: MemberImage(mbr : member -> (mbr.memberId.equals(acct.member.memberId)))
- check: PermissionCheck(target == image, action == "seam.grant-permission", granted == false)
-then
- check.grant();
-end
-
# Allow all users to read the available roles
rule ReadRoles
no-loop
activation-group "permissions"
when
- check: PermissionCheck(target == "seam.role", action == "read", granted == false)
- Role(name == "user")
+ check: PermissionCheck(resource == "seam.role", permission == "read", granted == false)
+// Role(name == "user")
then
check.grant();
end
-# This rule allows a member to delete their own images
-
-rule DeleteImage
- no-loop
- activation-group "permissions"
-when
- acct: MemberAccount()
- image: MemberImage(mbr : member -> (mbr.memberId.equals(acct.member.memberId)))
- check: PermissionCheck(target == image, action == "delete", granted == false)
-then
- check.grant();
-end
-
-# This rule allows members to revoke permissions on their images to other users/roles
-
-rule RevokeImagePermissions
- no-loop
- activation-group "permissions"
-when
- acct: MemberAccount()
- image: MemberImage(mbr : member -> (mbr.memberId.equals(acct.member.memberId)))
- check: PermissionCheck(target == image, action == "seam.revoke-permission", granted == false)
-then
- check.grant();
-end
-
-rule ViewProfileImage
- no-loop
- activation-group "permissions"
-when
- image: MemberImage()
- check: PermissionCheck(target == image, action == "view", granted == false)
- eval( image.getMember().getPicture() == image )
-then
- check.grant();
-end
-
-rule FriendViewImage
- no-loop
- activation-group "permissions"
-when
- acct: MemberAccount()
- image: MemberImage(mbr : member -> (mbr.isFriend(acct.member)))
- PermissionCheck(target == image, action == "view")
- role: RoleCheck(name == "friends")
-then
- role.grant();
-end
-
-rule GuestViewImage
- no-loop
- activation-group "permissions"
-when
- image: MemberImage()
- PermissionCheck(target == image, action == "view")
- role: RoleCheck(name == "guest")
-then
- role.grant();
-end
-
-rule ViewMyImages
- no-loop
- activation-group "permissions"
-when
- acct: MemberAccount()
- image: MemberImage(mbr : member -> (mbr.memberId.equals(acct.member.memberId)))
- check: PermissionCheck(target == image, action == "view")
-then
- check.grant();
-end
-
-rule RestrictCommentPage
- no-loop
- activation-group "permissions"
-when
- check: PermissionCheck(target == "/comment.xhtml", granted == false)
- Role(name == "user")
-then
- check.grant();
-end
-
-rule CanCreateBlogComment
- no-loop
- activation-group "permissions"
-when
- blog: MemberBlog()
- check: PermissionCheck(target == blog, action == "create", granted == false)
- Role(name == "user")
-then
- check.grant();
-end
-
-rule CreateBlogComment
- no-loop
- activation-group "permissions"
-when
- check: PermissionCheck(target == "blogComment", action == "insert", granted == false)
- Role(name == "user")
-then
- check.grant();
-end
-
-# This rule grants permission for users to create their own blog entries
-rule CreateBlog
- no-loop
- activation-group "permissions"
-when
- mbr: Member()
- acct: MemberAccount(member.memberId == mbr.memberId)
- check: PermissionCheck(target.memberId == mbr.memberId, action == "createBlog", granted == false)
-then
- check.grant();
-end
-
-# This rule grants permission for users to upload pictures to their profile
-rule UploadImage
- no-loop
- activation-group "permissions"
-when
- mbr: Member()
- acct: MemberAccount(member.memberId == mbr.memberId)
- check: PermissionCheck(target.memberId == mbr.memberId, action == "uploadImage", granted == false)
-then
- check.grant();
-end
-
-rule InsertMemberBlog
- no-loop
- activation-group "permissions"
-when
- acct: MemberAccount()
- blog: MemberBlog(member == acct.member)
- check: PermissionCheck(target == blog, action == "insert", granted == false)
-then
- check.grant();
-end
-
-rule CreateFriendComment
- no-loop
- activation-group "permissions"
-when
- acct: MemberAccount()
- member: Member() //friends contains acct.member)
- check: PermissionCheck(target == member, action == "createFriendComment", granted == false)
-then
- check.grant();
-end
-
-rule CreateFriendRequest
- no-loop
- activation-group "permissions"
-when
- acct: MemberAccount()
- member: Member() //friends not contains acct.member)
- check: PermissionCheck(target == member, action == "createFriendRequest", granted == false)
-then
- check.grant();
-end
-
rule CreateAccount
no-loop
activation-group "permissions"
when
- check: PermissionCheck(target == "seam.account", action == "create", granted == false)
- Role(name == "admin")
+ check: PermissionCheck(resource == "seam.account", permission == "create", granted == false)
+// Role(name == "admin")
then
check.grant();
end
@@ -230,8 +38,7 @@
no-loop
activation-group "permissions"
when
- check: PermissionCheck(target == "seam.user", granted == false)
- Role(name == "admin")
+ check: PermissionCheck(resource == "seam.identity", granted == false)
then
check.grant();
end
@@ -240,8 +47,8 @@
no-loop
activation-group "permissions"
when
- check: PermissionCheck(target == "seam.role", granted == false)
- Role(name == "admin")
+ check: PermissionCheck(resource == "seam.role", granted == false)
+// Role(name == "admin")
then
check.grant();
end
13 years, 11 months