jbPM4.4中的用户:
见:http://zybing.iteye.com/admin/blogs/778919
<binding class="org.jbpm.pvm.internal.wire.binding.IdentitySessionBinding" /> <binding class="org.jbpm.pvm.internal.wire.binding.IdentityServiceBinding" />
public Object parse(Element element, Parse parse, Parser parser) { ObjectDescriptor descriptor = new ObjectDescriptor(IdentityServiceImpl.class); descriptor.addInjection("commandService", new ReferenceDescriptor(CommandService.NAME_TX_REQUIRED_COMMAND_SERVICE)); return descriptor; }
public void createUser(String userId, String givenName, String familyName) { commandService.execute ( new CreateUserCmd(userId, givenName, familyName)); }
public Void execute(Environment environment) throws Exception { IdentitySession identitySession = environment.get(IdentitySession.class); identitySession.createUser(userId, givenName, familyName, businessEmail); return null; }
<binding class="org.jbpm.pvm.internal.wire.binding.IdentitySessionBinding" />
public Object parse(Element element, Parse parse, Parser parser) { ObjectDescriptor objectDescriptor = new ObjectDescriptor(IdentitySessionImpl.class); objectDescriptor.addTypedInjection("session", Session.class); return objectDescriptor; }
public String createUser(String userName, String givenName, String familyName, String businessEmail) { try { User user = findUserById(userName); if (user != null) { throw new JbpmException("Cannot create user, userId: [" + userName + "] has been used"); } } catch(Exception ex) { throw new JbpmException("Cannot create user, error while validating", ex); } UserImpl user = new UserImpl(userName, givenName, familyName); user.setBusinessEmail(businessEmail); long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class).getNextId(); user.setDbid(dbid); session.save(user); return user.getId(); }
<transaction-context> <object class="MyIdentitySessionImpl" /> </transaction-context>
<bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager"> <property name="providers"> <list> <ref local="daoAuthenticationProvider"/> <!-- Uncomment this for LDAP/SSO configuration <ref local="ldapAuthProvider"/> --> <!-- Uncomment this for CAS/SSO configuration <ref local="casAuthenticationProvider"/> --> <ref local="anonymousAuthenticationProvider"/> <!-- rememberMeAuthenticationProvider added programmatically --> </list> </property> </bean>
<bean id="daoAuthenticationProvider" class="org.acegisecurity.providers.dao.DaoAuthenticationProvider"> <property name="userDetailsService" ref="jdbcAuthenticationDao"/> <property name="userCache" ref="userCache"/> </bean>
<bean id="userCache" class="org.acegisecurity.providers.dao.cache.EhCacheBasedUserCache"> <property name="cache"> <bean class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager"> <bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/> </property> <property name="cacheName" value="userCache"/> </bean> </property> </bean>
userDetailsService:其中只有一个方法,就是loadUserByUsername,返回UserDetails接口(就是包括获取用户属性的一些方法)
UserDetails接口在SpringSecurity中有一个user类具体的实现;
UserDetails中,有一个方法是获取用户权限的,返回:grantedAuthority[], 这也是一个接口,就是获取到权限的名字,具体的实现GrantedAuthorityImpl。