[seam-commits] Seam SVN: r13074 - in modules/security/trunk: impl/src/main/java/org/jboss/seam/security/management and 1 other directory.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Jun 7 01:38:32 EDT 2010
Author: shane.bryzak at jboss.com
Date: 2010-06-07 01:38:30 -0400 (Mon, 07 Jun 2010)
New Revision: 13074
Modified:
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/IdentityProperty.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/PropertyType.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
Log:
allow credentials to be annotated multiple ways
Modified: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/IdentityProperty.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/IdentityProperty.java 2010-06-07 04:12:51 UTC (rev 13073)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/IdentityProperty.java 2010-06-07 05:38:30 UTC (rev 13074)
@@ -19,4 +19,5 @@
@Inherited
public @interface IdentityProperty {
PropertyType value();
+ String attributeName() default "";
}
Modified: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/PropertyType.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/PropertyType.java 2010-06-07 04:12:51 UTC (rev 13073)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/PropertyType.java 2010-06-07 05:38:30 UTC (rev 13074)
@@ -6,5 +6,5 @@
*/
public enum PropertyType {
NAME, TYPE, VALUE, RELATIONSHIP_FROM, RELATIONSHIP_TO, CREDENTIAL,
- CREDENTIAL_TYPE
+ CREDENTIAL_TYPE, ATTRIBUTE
}
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-06-07 04:12:51 UTC (rev 13073)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2010-06-07 05:38:30 UTC (rev 13074)
@@ -292,17 +292,51 @@
}
else
{
- Property<Object> p = findNamedProperty(credentialClass, "credentialValue",
- "password", "passwordHash", "credential", "value");
- if (p != null) modelProperties.put(PROPERTY_CREDENTIAL_VALUE, p);
+ // Try scanning for a credential property also
+ props = PropertyQueries.createQuery(credentialClass)
+ .addCriteria(new PropertyTypeCriteria(PropertyType.CREDENTIAL))
+ .getResultList();
+ if (props.size() == 1)
+ {
+ modelProperties.put(PROPERTY_CREDENTIAL_VALUE, props.get(0));
+ }
+ else if (props.size() > 1)
+ {
+ throw new IdentityManagementException(
+ "Ambiguous credential value property in credential class " +
+ credentialClass.getName());
+ }
+ else
+ {
+ Property<Object> p = findNamedProperty(credentialClass, "credentialValue",
+ "password", "passwordHash", "credential", "value");
+ if (p != null) modelProperties.put(PROPERTY_CREDENTIAL_VALUE, p);
+ }
}
}
else
{
- // The credentials may be stored in the identity class - let's search for it by name
- Property<Object> p = findNamedProperty(identityClass, "credentialValue",
- "password", "passwordHash", "credential", "value");
- if (p != null) modelProperties.put(PROPERTY_CREDENTIAL_VALUE, p);
+ // The credentials may be stored in the identity class
+ List<Property<Object>> props = PropertyQueries.createQuery(identityClass)
+ .addCriteria(new PropertyTypeCriteria(PropertyType.CREDENTIAL))
+ .getResultList();
+
+ if (props.size() == 1)
+ {
+ modelProperties.put(PROPERTY_CREDENTIAL_VALUE, props.get(0));
+ }
+ else if (props.size() > 1)
+ {
+ throw new IdentityManagementException(
+ "Ambiguous credential property in identity class " +
+ identityClass.getName());
+ }
+ else
+ {
+ Property<Object> p = findNamedProperty(identityClass, "credentialValue",
+ "password", "passwordHash", "credential", "value");
+ if (p != null) modelProperties.put(PROPERTY_CREDENTIAL_VALUE, p);
+ }
}
if (!modelProperties.containsKey(PROPERTY_CREDENTIAL_VALUE))
@@ -327,9 +361,26 @@
}
else
{
- Property<Object> p = findNamedProperty(credentialClass, "credentialType",
- "identityObjectCredentialType", "type");
- if (p != null) modelProperties.put(PROPERTY_CREDENTIAL_TYPE, p);
+ props = PropertyQueries.createQuery(credentialClass)
+ .addCriteria(new PropertyTypeCriteria(PropertyType.CREDENTIAL_TYPE))
+ .getResultList();
+
+ if (props.size() == 1)
+ {
+ modelProperties.put(PROPERTY_CREDENTIAL_TYPE, props.get(0));
+ }
+ else if (props.size() > 1)
+ {
+ throw new IdentityManagementException(
+ "Ambiguous credential type property in credential class " +
+ credentialClass.getName());
+ }
+ else
+ {
+ Property<Object> p = findNamedProperty(credentialClass, "credentialType",
+ "identityObjectCredentialType", "type");
+ if (p != null) modelProperties.put(PROPERTY_CREDENTIAL_TYPE, p);
+ }
}
Property<?> typeProp = modelProperties.get(PROPERTY_CREDENTIAL_TYPE);
@@ -565,6 +616,19 @@
protected void configureAttributes()
{
+ if (attributeClass != null)
+ {
+
+
+ }
+ else
+ {
+
+ }
+ }
+
+ protected void configureRoleTypeNames()
+ {
}
More information about the seam-commits
mailing list