翻译于 2013/06/17 08:17
<dependency> <groupId>org.jboss.seam</groupId> <artifactId>seam-bom</artifactId> <version>3.1.0.Final</version> <scope>import</scope> <type>pom</type> </dependency>这可以确保我在整个项目中使用的seam-jar版本正确。
<dependency> <groupId>org.jboss.seam.security</groupId> <artifactId>seam-security</artifactId> <scope>compile</scope> </dependency>
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="urn:java:ee" xmlns:security=" urn:java:org.jboss.seam.security" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd"> <interceptors> <class>org.jboss.seam.security.SecurityInterceptor</class> </interceptors> <security:IdentityImpl> <s:modifies /> <security:authenticatorClass>com.czetsuya.security.Authenticator </security:authenticatorClass> </security:IdentityImpl> </beans>
package com.czetsuya.security; import javax.enterprise.inject.Model; import javax.inject.Inject; import org.jboss.seam.security.BaseAuthenticator; import org.jboss.seam.security.Credentials; import org.picketlink.idm.impl.api.PasswordCredential; import org.picketlink.idm.impl.api.model.SimpleUser; @Model public class Authenticator extends BaseAuthenticator { @Inject Credentials credentials; public Authenticator() { } @Override public void authenticate() { System.out.println("logging in: " + credentials.getUsername()); if ("demo".equals(credentials.getUsername()) && credentials.getCredential() instanceof PasswordCredential && "demo".equals (((PasswordCredential) credentials.getCredential()).getValue())) { setStatus(AuthenticationStatus.SUCCESS); setUser(new SimpleUser("demo")); } } }
评论删除后,数据将无法恢复
评论(5)
Seam 3 Security 在几个项目使用了,对 JPA支持不错。LDAP 就是要费点力,可能使用 JBoss PicketBox 好点。