Author: shane.bryzak(a)jboss.com
Date: 2010-06-15 10:19:38 -0400 (Tue, 15 Jun 2010)
New Revision: 13150
Modified:
modules/security/trunk/examples/idmconsole/src/main/webapp/home.xhtml
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/CredentialsImpl.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/IdentityImpl.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/management/picketlink/IdentityConfigurationMetaDataProducer.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/IdentitySessionProducer.java
modules/security/trunk/pom.xml
Log:
more picketlink configuration
Modified: modules/security/trunk/examples/idmconsole/src/main/webapp/home.xhtml
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/webapp/home.xhtml 2010-06-15
12:22:40 UTC (rev 13149)
+++ modules/security/trunk/examples/idmconsole/src/main/webapp/home.xhtml 2010-06-15
14:19:38 UTC (rev 13150)
@@ -10,7 +10,7 @@
<h:form id="loginForm" rendered="#{not
identity.loggedIn}">
<h:messages id="messages" globalOnly="true"/>
-
+
<div class="loginRow">
<h:outputLabel for="name" value="Username"
styleClass="loginLabel"/>
<h:inputText id="name"
value="#{credentials.username}"/>
Modified:
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/CredentialsImpl.java
===================================================================
---
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/CredentialsImpl.java 2010-06-15
12:22:40 UTC (rev 13149)
+++
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/CredentialsImpl.java 2010-06-15
14:19:38 UTC (rev 13150)
@@ -18,9 +18,7 @@
*
* @author Shane Bryzak
*/
-@Named
-@SessionScoped
-public class CredentialsImpl implements Credentials, Serializable
+public @Named("credentials") @SessionScoped class CredentialsImpl implements
Credentials, Serializable
{
private static final long serialVersionUID = -2271248957776488426L;
Modified:
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/IdentityImpl.java
===================================================================
---
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/IdentityImpl.java 2010-06-15
12:22:40 UTC (rev 13149)
+++
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/IdentityImpl.java 2010-06-15
14:19:38 UTC (rev 13150)
@@ -50,9 +50,7 @@
*
* @author Shane Bryzak
*/
-@Named
-@SessionScoped
-public class IdentityImpl implements Identity, Serializable
+public @Named("identity") @SessionScoped class IdentityImpl implements
Identity, Serializable
{
private static final long serialVersionUID = 3751659008033189259L;
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-06-15
12:22:40 UTC (rev 13149)
+++
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java 2010-06-15
14:19:38 UTC (rev 13150)
@@ -261,8 +261,16 @@
public boolean authenticate(String username, Credential credential)
{
if (Strings.isEmpty(username)) return false;
- //return identityStore.authenticate(username, credential);
- return false;
+
+ try
+ {
+ return identitySession.getAttributesManager().validateCredentials(
+ new UserImpl(username), new Credential[] {credential});
+ }
+ catch (IdentityException ex)
+ {
+ return false;
+ }
}
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-15
12:22:40 UTC (rev 13149)
+++
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2010-06-15
14:19:38 UTC (rev 13150)
@@ -51,7 +51,7 @@
*
* @author Shane Bryzak
*/
-public @ApplicationScoped class JpaIdentityStore implements
org.picketlink.idm.spi.store.IdentityStore, Serializable
+public class JpaIdentityStore implements org.picketlink.idm.spi.store.IdentityStore,
Serializable
{
private static final long serialVersionUID = 7729139146633529501L;
@@ -86,19 +86,16 @@
private static final String PROPERTY_ROLE_TYPE_NAME = "ROLE_TYPE_NAME";
/**
- * The bean manager
- */
- @Inject BeanManager beanManager;
-
- /**
*
*/
- @Inject Instance<EntityManager> entityManagerInstance;
+ //@Inject Instance<EntityManager> entityManagerInstance;
/**
*
*/
- //@Inject CredentialProcessor credentialEncoder;
+ //@Inject CredentialProcessor credentialEncoder;
+
+ private String id;
// Entity classes
@@ -147,6 +144,11 @@
}
}
+ public JpaIdentityStore(String id)
+ {
+ this.id = id;
+ }
+
public void bootstrap(IdentityStoreConfigurationContext configurationContext)
throws IdentityException
{
@@ -830,12 +832,12 @@
{
Property<Object> typeNameProp =
modelProperties.get(PROPERTY_IDENTITY_TYPE_NAME);
- Object val = entityManagerInstance.get().createQuery(
+ Object val = null; /*entityManagerInstance.get().createQuery(
"select t from " + typeNameProp.getDeclaringClass().getName() +
" t where t." + typeNameProp.getName() +
" = :identityType")
.setParameter("identityType", identityType)
- .getSingleResult();
+ .getSingleResult();*/
return val;
}
catch (NoResultException ex)
@@ -865,11 +867,11 @@
typeProp.setValue(identityInstance,
lookupIdentityType(identityObjectType.getName()));
}
- beanManager.fireEvent(new PrePersistUserEvent(identityInstance));
+ //beanManager.fireEvent(new PrePersistUserEvent(identityInstance));
- entityManagerInstance.get().persist(identityInstance);
+ //entityManagerInstance.get().persist(identityInstance);
- beanManager.fireEvent(new UserCreatedEvent(identityInstance));
+ //beanManager.fireEvent(new UserCreatedEvent(identityInstance));
// TODO persist attributes
@@ -913,7 +915,7 @@
modelProperties.get(PROPERTY_RELATIONSHIP_NAME).setValue(relationship,
relationshipName);
- entityManagerInstance.get().persist(relationship);
+ //entityManagerInstance.get().persist(relationship);
return new IdentityObjectRelationshipImpl(fromIdentity, toIdentity,
relationshipName, relationshipType);
@@ -950,12 +952,12 @@
{
try
{
- Object identity = entityManagerInstance.get().createQuery("select i from
" +
+ Object identity = null; /*entityManagerInstance.get().createQuery("select i
from " +
identityClass.getName() + " i where i." +
modelProperties.get(PROPERTY_IDENTITY_ID).getName() +
" = :id")
.setParameter("id", id)
- .getSingleResult();
+ .getSingleResult();*/
IdentityObjectType type =
modelProperties.containsKey(PROPERTY_IDENTITY_TYPE_NAME) ?
new IdentityObjectTypeImpl(
@@ -991,14 +993,14 @@
lookupIdentityType(identityObjectType.getName()) :
identityObjectType.getName();
- Object identity = entityManagerInstance.get().createQuery("select i from
" +
- identityClass.getName() + " i where i." +
+ Object identity = null; //entityManagerInstance.get().createQuery("select i
from " +
+ /*identityClass.getName() + " i where i." +
modelProperties.get(PROPERTY_IDENTITY_NAME).getName() +
" = :name and i." +
modelProperties.get(PROPERTY_IDENTITY_TYPE).getName() +
" = :type")
.setParameter("name", name)
.setParameter("type", identityType)
- .getSingleResult();
+ .getSingleResult();*/
return new IdentityObjectImpl(
modelProperties.get(PROPERTY_IDENTITY_ID).getValue(identity).toString(),
@@ -1032,8 +1034,7 @@
public String getId()
{
- // TODO Auto-generated method stub
- return null;
+ return id;
}
public int getIdentityObjectsCount(
Modified:
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/IdentityConfigurationMetaDataProducer.java
===================================================================
---
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/IdentityConfigurationMetaDataProducer.java 2010-06-15
12:22:40 UTC (rev 13149)
+++
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/IdentityConfigurationMetaDataProducer.java 2010-06-15
14:19:38 UTC (rev 13150)
@@ -16,7 +16,11 @@
{
@Produces @ApplicationScoped IdentityConfigurationMetaData createConfig()
{
+ IdentityConfigurationMetaDataImpl config = new
IdentityConfigurationMetaDataImpl();
+
+ //config.setIdentityStores(identityStores)
+
// TODO needs actual configuration, realms, identity stores, etc
- return new IdentityConfigurationMetaDataImpl();
+ return config;
}
}
Modified:
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/IdentitySessionProducer.java
===================================================================
---
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/IdentitySessionProducer.java 2010-06-15
12:22:40 UTC (rev 13149)
+++
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/IdentitySessionProducer.java 2010-06-15
14:19:38 UTC (rev 13150)
@@ -1,5 +1,8 @@
package org.jboss.seam.security.management.picketlink;
+import java.util.ArrayList;
+import java.util.List;
+
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
@@ -7,9 +10,15 @@
import org.picketlink.idm.api.IdentitySession;
import org.picketlink.idm.api.IdentitySessionFactory;
+import org.picketlink.idm.common.exception.IdentityConfigurationException;
import org.picketlink.idm.common.exception.IdentityException;
-import org.picketlink.idm.impl.api.IdentitySessionFactoryImpl;
+import org.picketlink.idm.impl.configuration.IdentityConfigurationImpl;
+import org.picketlink.idm.impl.configuration.metadata.IdentityConfigurationMetaDataImpl;
+import
org.picketlink.idm.impl.configuration.metadata.IdentityStoreConfigurationMetaDataImpl;
+import org.picketlink.idm.impl.configuration.metadata.RealmConfigurationMetaDataImpl;
import org.picketlink.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+import org.picketlink.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.picketlink.idm.spi.configuration.metadata.RealmConfigurationMetaData;
/**
* Produces IdentitySession instances for identity management-related operations
@@ -21,14 +30,35 @@
{
private IdentitySessionFactory factory;
- private String defaultRealm;
+ private String defaultRealm = "default";
@Inject IdentityConfigurationMetaData config;
@Inject
- public void init()
+ public void init() throws IdentityConfigurationException
{
- factory = new IdentitySessionFactoryImpl(config, null);
+ IdentityConfigurationMetaDataImpl metadata = new
IdentityConfigurationMetaDataImpl();
+
+ // Create the identity store configuration
+ List<IdentityStoreConfigurationMetaData> stores = new
ArrayList<IdentityStoreConfigurationMetaData>();
+ IdentityStoreConfigurationMetaDataImpl store = new
IdentityStoreConfigurationMetaDataImpl();
+ store.setId("jpa");
+
store.setClassName("org.jboss.seam.security.management.JpaIdentityStore");
+ stores.add(store);
+ metadata.setIdentityStores(stores);
+
+ // Create the default realm
+ RealmConfigurationMetaDataImpl realm = new RealmConfigurationMetaDataImpl();
+ realm.setIdentityRepositoryIdRef("jpa");
+ realm.setId("default");
+ List<RealmConfigurationMetaData> realms = new
ArrayList<RealmConfigurationMetaData>();
+ realms.add(realm);
+ metadata.setRealms(realms);
+
+ IdentityConfigurationImpl config = new IdentityConfigurationImpl();
+ config.configure(metadata);
+
+ factory = config.buildIdentitySessionFactory();
}
@Produces @RequestScoped IdentitySession createIdentitySession()
Modified: modules/security/trunk/pom.xml
===================================================================
--- modules/security/trunk/pom.xml 2010-06-15 12:22:40 UTC (rev 13149)
+++ modules/security/trunk/pom.xml 2010-06-15 14:19:38 UTC (rev 13150)
@@ -24,7 +24,7 @@
</prerequisites>
<properties>
- <seam.version>3.0.0.b01</seam.version>
+ <seam.version>3.0.0-SNAPSHOT</seam.version>
<!-- Use snapshot WeldX -->
<weld.extensions.version>1.0.0-SNAPSHOT</weld.extensions.version>
<!-- Seam-Drools is not yet released -->