• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IdentityManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.picketlink.idm.IdentityManager的典型用法代码示例。如果您正苦于以下问题:Java IdentityManager类的具体用法?Java IdentityManager怎么用?Java IdentityManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IdentityManager类属于org.picketlink.idm包,在下文中一共展示了IdentityManager类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: create

import org.picketlink.idm.IdentityManager; //导入依赖的package包/类
@PostConstruct
public void create() 
{

    // Create user john
    User john = new User("john");
    john.setEmail("[email protected]");
    john.setFirstName("John");
    john.setLastName("User");

    IdentityManager identityManager = this.partitionManager.createIdentityManager();

    identityManager.add(john);
    identityManager.updateCredential(john, new Password("123456"));

}
 
开发者ID:apache,项目名称:deltaspike,代码行数:17,代码来源:Initializer.java


示例2: create

import org.picketlink.idm.IdentityManager; //导入依赖的package包/类
public synchronized void create( @Observes PreAuthenticateEvent event ) {
  if ( alreadyDone ) {
    return;
  }

  alreadyDone = true;

  final IdentityManager identityManager = partitionManager.createIdentityManager();
  final RelationshipManager relationshipManager = partitionManager.createRelationshipManager();

  User admin = new User("admin");

  admin.setEmail("[email protected]");
  admin.setFirstName("");
  admin.setLastName("admin");

  User regular = new User("regular");

  regular.setEmail("[email protected]");
  regular.setFirstName("Regular");
  regular.setLastName("User");

  identityManager.add(admin);
  identityManager.add(regular);
  identityManager.updateCredential(admin, new Password("admin"));
  identityManager.updateCredential(regular, new Password("123"));

  Role roleDeveloper = new Role("simple");
  Role roleAdmin = new Role("admin");

  identityManager.add(roleDeveloper);
  identityManager.add(roleAdmin);

  relationshipManager.add(new Grant(admin, roleDeveloper));
  relationshipManager.add(new Grant(admin, roleAdmin));
}
 
开发者ID:Teiid-Designer,项目名称:teiid-webui,代码行数:37,代码来源:PicketLinkDefaultUsers.java


示例3: checkAdmin

import org.picketlink.idm.IdentityManager; //导入依赖的package包/类
/**
 * Checks to see if the user is currently logged in to the system by checking the Identity object.
 * 
 * @param servletContext
 *            the servletContext
 * @throws WebApplicationException
 *             if the user is not authenticated.
 */
public static void checkAdmin(ServletContext servletContext) throws WebApplicationException {
    Identity identity = new ServletInjector<Identity>().getManagedBean(servletContext, Identity.class);
    IdentityManager identityManager = new ServletInjector<IdentityManager>().getManagedBean(servletContext, IdentityManager.class);
    RelationshipManager relationshipManager = new ServletInjector<RelationshipManager>().getManagedBean(servletContext, RelationshipManager.class);
    
    if (identity == null
            || !hasRole(relationshipManager, identity.getAccount(), getRole(identityManager, TankConstants.TANK_GROUP_ADMIN))) {
        throw new WebApplicationException(buildForbiddenResponse("Insuficient Rights"));
    }
}
 
开发者ID:intuit,项目名称:Tank,代码行数:19,代码来源:AuthUtil.java


示例4: checkOwner

import org.picketlink.idm.IdentityManager; //导入依赖的package包/类
/**
 * Checks to see if the user is currently logged in to the system by checking the Identity object.
 * 
 * @param servletContext
 *            the servletContext
 * @param ownable
 *            the entiry to check if the user has rights to
 * @throws WebApplicationException
 *             if the user is not authenticated.
 */
public static void checkOwner(ServletContext servletContext, OwnableEntity ownable) throws WebApplicationException {
    checkLoggedIn(servletContext);
    Identity identity = new ServletInjector<Identity>().getManagedBean(servletContext, Identity.class);
    IdentityManager identityManager = new ServletInjector<IdentityManager>().getManagedBean(servletContext, IdentityManager.class);
    RelationshipManager relationshipManager = new ServletInjector<RelationshipManager>().getManagedBean(servletContext, RelationshipManager.class);
    
    if (hasRole(relationshipManager, identity.getAccount(), getRole(identityManager, TankConstants.TANK_GROUP_ADMIN))) {
        return;
    }
    if (StringUtils.isEmpty(ownable.getCreator()) || identity.getAccount().getId().equals(ownable.getCreator())) {
        return;
    }
    throw new WebApplicationException(buildForbiddenResponse("Insufficient Rights"));
}
 
开发者ID:intuit,项目名称:Tank,代码行数:25,代码来源:AuthUtil.java


示例5: setup

import org.picketlink.idm.IdentityManager; //导入依赖的package包/类
private void setup() {
    final IdentityManager identityManager = partitionManager.createIdentityManager();
    final RelationshipManager relationshipManager = partitionManager.createRelationshipManager();

    final User admin = new User("admin");
    final User director = new User("director");
    final User user = new User("user");
    final User guest = new User("guest");

    identityManager.add(admin);
    identityManager.add(director);
    identityManager.add(user);
    identityManager.add(guest);

    identityManager.updateCredential(admin,
                                     new Password("admin"));
    identityManager.updateCredential(director,
                                     new Password("director"));
    identityManager.updateCredential(user,
                                     new Password("user"));
    identityManager.updateCredential(guest,
                                     new Password("guest"));

    final Role roleAdmin = new Role("admin");
    final Role roleAnalyst = new Role("analyst");

    identityManager.add(roleAdmin);
    identityManager.add(roleAnalyst);

    relationshipManager.add(new Grant(admin,
                                      roleAnalyst));
    relationshipManager.add(new Grant(admin,
                                      roleAdmin));

    relationshipManager.add(new Grant(director,
                                      roleAnalyst));

    relationshipManager.add(new Grant(user,
                                      roleAnalyst));
}
 
开发者ID:kiegroup,项目名称:optaplanner-wb,代码行数:41,代码来源:PicketLinkDefaultUsers.java


示例6: setup

import org.picketlink.idm.IdentityManager; //导入依赖的package包/类
private void setup() {
    final IdentityManager identityManager = partitionManager.createIdentityManager();
    final RelationshipManager relationshipManager = partitionManager.createRelationshipManager();

    final User admin = new User("admin");
    final User director = new User("director");
    final User user = new User("user");
    final User guest = new User("guest");

    identityManager.add(admin);
    identityManager.add(director);
    identityManager.add(user);
    identityManager.add(guest);

    identityManager.updateCredential(admin, new Password("admin"));
    identityManager.updateCredential(director, new Password("director"));
    identityManager.updateCredential(user, new Password("user"));
    identityManager.updateCredential(guest, new Password("guest"));

    final Role roleAdmin = new Role("admin");
    final Role roleAnalyst = new Role("analyst");

    identityManager.add(roleAdmin);
    identityManager.add(roleAnalyst);

    relationshipManager.add(new Grant(admin, roleAnalyst));
    relationshipManager.add(new Grant(admin, roleAdmin));

    relationshipManager.add(new Grant(director, roleAnalyst));

    relationshipManager.add(new Grant(user, roleAnalyst));
}
 
开发者ID:kiegroup,项目名称:drools-wb,代码行数:33,代码来源:PicketLinkDefaultUsers.java


示例7: authenticate

import org.picketlink.idm.IdentityManager; //导入依赖的package包/类
@Override
@Transactional(qualifier = PicketLink.class)
public void authenticate() 
{
	if(!identity.isLoggedIn())
	{
		FacesContext context = FacesContext.getCurrentInstance();
		if (realm.isEmpty())
		{
			context.addMessage("Realm",new FacesMessage(messages.DomainRequired()));
		}
		if (credentials.getUserId().isEmpty())
		{
			context.addMessage("username",new FacesMessage(messages.UsernameRequired()));
		}
		if (credentials.getPassword().isEmpty())
		{
			context.addMessage("password",new FacesMessage(messages.PasswordRequired()));
		}
				
		Realm storedRealm = partitionManager.getPartition(Realm.class, realm);
		if(storedRealm == null)
		{
			context.addMessage(null,new FacesMessage(FacesMessage.SEVERITY_ERROR,"Error!", messages.LoginStatusFailure()));
			return;
		}
		IdentityManager identityManager = partitionManager.createIdentityManager(storedRealm);
		
		Password password = new Password(credentials.getPassword());
		UsernamePasswordCredentials m_credentials = new UsernamePasswordCredentials(credentials.getUserId(), password);
		identityManager.validateCredentials(m_credentials);
        org.picketlink.idm.credential.Credentials.Status status = m_credentials.getStatus();
        if (status == org.picketlink.idm.credential.Credentials.Status.INVALID)
        {
			context.addMessage(null,new FacesMessage(FacesMessage.SEVERITY_ERROR,"Error!", messages.LoginStatusFailure()));
			return;
        }
        IdentityQueryBuilder queryBuilder = identityManager.getQueryBuilder();
        IdentityQuery<User> query = queryBuilder.createIdentityQuery(User.class);

        // let's check if the user is stored by querying by name
        query.where(queryBuilder.equal(User.USER_NAME, credentials.getUserId()));

        List<User> users = query.getResultList();

        setStatus(AuthenticationStatus.SUCCESS);
        setAccount(users.get(0));
//		UserIdentity user = new UserIdentity();
//		user.setUsername(Username);
//		user.setPassword(Password);
//		model.SaveUser(user);
//		System.out.print("this is test");
	}
     //  this.viewNavigationHandler.navigateTo(Windows.contourdynamics.class);
}
 
开发者ID:Contourdynamics,项目名称:smartcommunication,代码行数:56,代码来源:CDidentityManager.java


示例8: create

import org.picketlink.idm.IdentityManager; //导入依赖的package包/类
@PostConstruct
public void create() throws Exception{
	Realm cd = new Realm(REALM_CD_NAME);
	Realm storedRealm = partitionManager.getPartition(Realm.class, cd.getName());
	if(storedRealm == null)
	{
		cd.setEnforceSSL(true);
		KeyPair keyPair = KeyPairGenerator.getInstance("RSA").generateKeyPair();
		cd.setPrivateKey(keyPair.getPrivate().getEncoded());
		cd.setPublickKey(keyPair.getPublic().getEncoded());
		cd.setNumberFailedLoginAttempts(3);
		partitionManager.add(cd);
 
    	IdentityManager cdIdentityManager = partitionManager.createIdentityManager(cd);
    	
        Role Administrator = new Role("Administrator");
        Role Customer = new Role("Customer");
        Role Consumer = new Role("Consumer");
        Role Vendor = new Role("Vendor");
        Role Contacts = new Role("Contacts");
        
        cdIdentityManager.add(Administrator);
        cdIdentityManager.add(Customer);
        cdIdentityManager.add(Consumer);
        cdIdentityManager.add(Vendor);
        cdIdentityManager.add(Contacts);
        
        User user = new User("admin");            
        cdIdentityManager.add(user);
        Password password = new Password("admin");
        cdIdentityManager.updateCredential(user, password); 
        
        RelationshipManager relationshipManager = partitionManager.createRelationshipManager();
        relationshipManager.add(new Grant(user, Administrator));
        
        
        Realm cdcustomer = new Realm(REALM_CDCustomer_NAME);
    	Realm customerRealm = partitionManager.getPartition(Realm.class, cdcustomer.getName());
    	
    	if(customerRealm == null)
    	{
    		cdcustomer.setEnforceSSL(true);
    		KeyPair keyPaircustomer = KeyPairGenerator.getInstance("RSA").generateKeyPair();
    		cdcustomer.setPrivateKey(keyPaircustomer.getPrivate().getEncoded());
    		cdcustomer.setPublickKey(keyPaircustomer.getPublic().getEncoded());
    		cdcustomer.setNumberFailedLoginAttempts(3);
    		partitionManager.add(cdcustomer);
 
        	IdentityManager cdIdentityManagercst = partitionManager.createIdentityManager(cdcustomer);
        	
        	User customer = new User("customer");            
        	cdIdentityManagercst.add(customer);
            Password demo = new Password("demo");
            cdIdentityManagercst.updateCredential(customer, demo); 
            relationshipManager.add(new Grant(customer, Customer));
            
            
            User consumer = new User("consumer");            
        	cdIdentityManagercst.add(consumer);
            cdIdentityManagercst.updateCredential(consumer, demo); 
            relationshipManager.add(new Grant(consumer, Consumer));
    	}
	}
}
 
开发者ID:Contourdynamics,项目名称:smartcommunication,代码行数:65,代码来源:SecurityInitializer.java


示例9: checkForDefaultGroups

import org.picketlink.idm.IdentityManager; //导入依赖的package包/类
/**
 * 
 * @param partitionManager 
 */
private void checkForDefaultGroups(PartitionManager partitionManager) {
    
    final IdentityManager identityManager = 
            partitionManager.createIdentityManager(this.defaultRealm);
    
    final IdentityQuery<Group> query = identityManager
            .createIdentityQuery(Group.class);

    query.setParameter(Group.NAME, "Administradores");

    final List<Group> groups = query.getResultList();
    
    if (groups.isEmpty()) {
        
        this.logger.info("Creating default groups");
        
        identityManager.add(new Group("Administradores"));
    }
}
 
开发者ID:arthurgregorio,项目名称:exemplos,代码行数:24,代码来源:SecurityInitializer.java


示例10: checkForDefaultRoles

import org.picketlink.idm.IdentityManager; //导入依赖的package包/类
/**
 * 
 * @param partitionManager 
 */
private void checkForDefaultRoles(PartitionManager partitionManager) {
    
    final IdentityManager identityManager = 
            partitionManager.createIdentityManager(this.defaultRealm);
    
    final IdentityQuery<Role> query = identityManager
            .createIdentityQuery(Role.class);

    query.setParameter(Role.NAME, ApplicationRoles.ADMINISTRATOR);

    List<Role> roles = query.getResultList();
    
    if (roles.isEmpty()) {
        
        this.logger.info("Creating default roles");
        
        identityManager.add(new Role(ApplicationRoles.ADMINISTRATOR));
    }
}
 
开发者ID:arthurgregorio,项目名称:exemplos,代码行数:24,代码来源:SecurityInitializer.java


示例11: create

import org.picketlink.idm.IdentityManager; //导入依赖的package包/类
/**
 * Creates example users so people can log in while trying out the app.
 */
public synchronized void create(@Observes PreAuthenticateEvent event) {
    if (done) {
        return;
    }

    done = true;

    final IdentityManager identityManager = partitionManager.createIdentityManager();
    final RelationshipManager relationshipManager = partitionManager.createRelationshipManager();

    User admin = new User("admin");

    admin.setEmail("[email protected]");
    admin.setFirstName("John");
    admin.setLastName("Doe");

    User nonAdmin = new User("joe");

    nonAdmin.setEmail("[email protected]");
    nonAdmin.setFirstName("Joe");
    nonAdmin.setLastName("Doe");

    identityManager.add(admin);
    identityManager.add(nonAdmin);
    identityManager.updateCredential(admin,
                                     new Password("admin"));
    identityManager.updateCredential(nonAdmin,
                                     new Password("joe"));

    Role roleSimple = new Role("simple");
    Role roleAdmin = new Role("admin");

    identityManager.add(roleSimple);
    identityManager.add(roleAdmin);

    relationshipManager.add(new Grant(admin,
                                      roleSimple));
    relationshipManager.add(new Grant(admin,
                                      roleAdmin));

    relationshipManager.add(new Grant(nonAdmin,
                                      roleSimple));
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:47,代码来源:PicketLinkDefaultUsers.java


示例12: create

import org.picketlink.idm.IdentityManager; //导入依赖的package包/类
/**
 * Creates example users so people can log in while trying out the app.
 */
public synchronized void create(@Observes PreAuthenticateEvent event) {
    if (done) {
        return;
    }

    done = true;

    final IdentityManager identityManager = partitionManager.createIdentityManager();
    final RelationshipManager relationshipManager = partitionManager.createRelationshipManager();

    User admin = new User("admin");

    admin.setEmail("[email protected]");
    admin.setFirstName("John");
    admin.setLastName("Doe");

    User nonAdmin = new User("joe");

    nonAdmin.setEmail("[email protected]");
    nonAdmin.setFirstName("Joe");
    nonAdmin.setLastName("Doe");

    identityManager.add(admin);
    identityManager.add(nonAdmin);
    identityManager.updateCredential(admin,
                                     new Password("admin"));
    identityManager.updateCredential(nonAdmin,
                                     new Password("123"));

    Role roleSimple = new Role("simple");
    Role roleAdmin = new Role("admin");

    identityManager.add(roleSimple);
    identityManager.add(roleAdmin);

    relationshipManager.add(new Grant(admin,
                                      roleSimple));
    relationshipManager.add(new Grant(admin,
                                      roleAdmin));
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:44,代码来源:PicketLinkDefaultUsers.java


示例13: getIdentityManager

import org.picketlink.idm.IdentityManager; //导入依赖的package包/类
public IdentityManager getIdentityManager() {
    return identityManager;
}
 
开发者ID:arun-gupta,项目名称:wildfly-samples,代码行数:4,代码来源:UserRegistration.java


示例14: setIdentityManager

import org.picketlink.idm.IdentityManager; //导入依赖的package包/类
public void setIdentityManager(IdentityManager identityManager) {
    this.identityManager = identityManager;
}
 
开发者ID:arun-gupta,项目名称:wildfly-samples,代码行数:4,代码来源:UserRegistration.java


示例15: create

import org.picketlink.idm.IdentityManager; //导入依赖的package包/类
@PostConstruct
public void create()
{
   if (partitionManager.getPartition(Realm.class, Realm.DEFAULT_REALM) == null)
   {
      partitionManager.add(new Realm(Realm.DEFAULT_REALM));
   }

   IdentityManager im = partitionManager.createIdentityManager();
   User u = new User();

   u.setFirstName("Shane");
   u.setLastName("Bryzak");
   u.setUsername("sbryzak");
   im.add(u);
   im.updateCredential(u, new Password("password"));

   Project p = new Project();
   p.setName("Meeting Planner");
   p.setDescription("Simplified meeting and event planning, provides comprehensive features for venue, resource and attendee management.");
   p.setStage("Dev");
   p.setImageUrl("images/planner.jpg");
   p.setUpdates(16);
   p.setViews(3);
   entityManager.persist(p);

   ProjectAccess pa = new ProjectAccess();
   pa.setProject(p);
   pa.setAccessLevel(AccessLevel.OWNER);
   pa.setUserId(u.getId());

   entityManager.persist(pa);

   p = new Project();
   p.setName("Customer Directory");
   p.setDescription("Basic customer contact directory, with highly customisable attributes and RESTful interface for managing and querying entities.");
   p.setStage("Production");
   p.setImageUrl("images/directory.jpg");
   p.setUpdates(73);
   p.setViews(22);
   entityManager.persist(p);

   pa = new ProjectAccess();
   pa.setProject(p);
   pa.setAccessLevel(AccessLevel.OWNER);
   pa.setUserId(u.getId());

   entityManager.persist(pa);
}
 
开发者ID:forgeide,项目名称:forgeide,代码行数:50,代码来源:IDMInitializer.java


示例16: checkForDefaultUsers

import org.picketlink.idm.IdentityManager; //导入依赖的package包/类
/**
 * 
 * @param partitionManager 
 */
private void checkForDefaultUsers(PartitionManager partitionManager) {

    final IdentityManager identityManager = 
            partitionManager.createIdentityManager(this.defaultRealm);
    
    final IdentityQuery<User> query = identityManager
            .createIdentityQuery(User.class);

    query.setParameter(User.USER_NAME, "admin");

    List<User> users = query.getResultList();
    
    if (users.isEmpty()) {
        
        this.logger.info("Creating default users");
        
        final User user = new User("admin", new Person(
                "Administrador", "[email protected]"));
        
        user.setCreatedDate(new Date());
        user.setEnabled(true);
        user.setExpirationDate(null);
        
        identityManager.add(user);

        identityManager.updateCredential(user, new Password("admin"));
        
        final RelationshipManager relationshipManager = 
                partitionManager.createRelationshipManager();
        
        final IdentityQuery<Role> roleQuery = 
                identityManager.createIdentityQuery(Role.class);

        roleQuery.setParameter(Role.NAME, ApplicationRoles.ADMINISTRATOR);
        
        final Role administratorRole = roleQuery.getResultList().get(0);
        
        relationshipManager.add(new Grant(user, administratorRole));
    }
}
 
开发者ID:arthurgregorio,项目名称:exemplos,代码行数:45,代码来源:SecurityInitializer.java



注:本文中的org.picketlink.idm.IdentityManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PopupDateField类代码示例发布时间:2022-05-22
下一篇:
Java IoUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap