当前位置: 首页>>代码示例>>Java>>正文


Java Password类代码示例

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


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

示例1: authenticate

import org.picketlink.idm.credential.Password; //导入依赖的package包/类
/**
 * Autentica o usuario no banco de dados pelo modelo de seguranca
 */
@Override
public void authenticate() {

    final UsernamePasswordCredentials userCredentials = 
            new UsernamePasswordCredentials(this.wbCredentials.getUsername(),
                    new Password(this.wbCredentials.getPassword()));

    try {
        this.identityManager.validateCredentials(userCredentials);

        this.defineStatus(userCredentials.getStatus());
        
        if (this.getStatus() == AuthenticationStatus.SUCCESS) {
            this.setAccount(userCredentials.getValidatedAccount());
        } 
    } catch (Exception ex) {
        this.setStatus(AuthenticationStatus.FAILURE);
        logger.error("Error in an attempt to authenticate {}", 
                this.wbCredentials.getUsername(), ex);
    }
}
 
开发者ID:arthurgregorio,项目名称:web-budget,代码行数:25,代码来源:Authenticator.java

示例2: save

import org.picketlink.idm.credential.Password; //导入依赖的package包/类
/**
 *
 * @param user
 */
@Transactional
public void save(User user) {

    // validamos os dados do usuario
    final User found = this.findUserByUsername(user.getUsername());

    if (found != null) {
        throw new InternalServiceError("user.error.duplicated-username");
    }

    // pegamos o grupo e setamos o user no membership dele
    final GroupMembership groupMembership = user.getGroupMembership();

    // pegamos a senha antes de salvar o usuario
    final String unsecurePassword = user.getPassword();

    // salvamos
    this.identityManager.add(user);

    // atualizamos o usuario com a senha
    this.identityManager.updateCredential(user, new Password(unsecurePassword));

    // concedemos ao usuario o grant para o grupo que ele escolheu
    this.relationshipManager.add(groupMembership);
}
 
开发者ID:arthurgregorio,项目名称:web-budget,代码行数:30,代码来源:AccountService.java

示例3: updateProfile

import org.picketlink.idm.credential.Password; //导入依赖的package包/类
/**
 *
 * @param user
 */
@Transactional
public void updateProfile(User user) {

    // limpa a senha para nao ser trocada quando em testes
    if (ApplicationUtils.isStageRunning(ProjectStage.SystemTest)
            && user.getUsername().equals("admin")) {
        user.setPassword(null);
    }

    // pegamos a senha antes de salvar o usuario
    final String unsecurePassword = user.getPassword();

    // atualizamos o usuario com a senha
    if (unsecurePassword != null && !unsecurePassword.isEmpty()) {
        this.identityManager.updateCredential(user, new Password(unsecurePassword));
    } else {
        // salvamos
        this.identityManager.update(user);
    }
}
 
开发者ID:arthurgregorio,项目名称:web-budget,代码行数:25,代码来源:AccountService.java

示例4: create

import org.picketlink.idm.credential.Password; //导入依赖的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

示例5: create

import org.picketlink.idm.credential.Password; //导入依赖的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

示例6: setup

import org.picketlink.idm.credential.Password; //导入依赖的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

示例7: getPassword

import org.picketlink.idm.credential.Password; //导入依赖的package包/类
/**
 * 
 * @return 
 */
@NotNull(message = "{authentication.password}")
public String getPassword() {
    if (this.secret instanceof Password) {
        Password password = (Password) this.secret;
        return new String(password.getValue());
    }
    return null;
}
 
开发者ID:arthurgregorio,项目名称:web-budget,代码行数:13,代码来源:CustomCredentials.java

示例8: setPassword

import org.picketlink.idm.credential.Password; //导入依赖的package包/类
/**
 * 
 * @param password 
 */
public void setPassword(final String password) {
    if (password == null) {
        throw new IllegalArgumentException("Password can not be null.");
    }
    this.secret = new Password(password.toCharArray());
}
 
开发者ID:arthurgregorio,项目名称:web-budget,代码行数:11,代码来源:CustomCredentials.java

示例9: update

import org.picketlink.idm.credential.Password; //导入依赖的package包/类
/**
 *
 * @param user
 */
@Transactional
public void update(User user) {

    // limpa a senha para nao ser trocada quando em testes
    if (ApplicationUtils.isStageRunning(ProjectStage.SystemTest)
            && user.getUsername().equals("admin")) {
        return;
    }

    // pegamos o grupo
    final GroupMembership groupMembership = user.getGroupMembership();

    // removemos o vinculo antigo
    this.listMembershipsByUser(user).forEach(membership -> {
        this.removeFromGroup(membership.getGroup(), user);
    });

    // pegamos a senha antes de salvar o usuario
    final String unsecurePassword = user.getPassword();

    // atualizamos o usuario com a senha
    if (unsecurePassword != null && !unsecurePassword.isEmpty()) {
        this.identityManager.updateCredential(user, new Password(unsecurePassword));
    } else {
        // salvamos
        this.identityManager.update(user);
    }

    // concedemos ao usuario o grant para o grupo que ele escolheu
    this.relationshipManager.add(groupMembership);
}
 
开发者ID:arthurgregorio,项目名称:web-budget,代码行数:36,代码来源:AccountService.java

示例10: setup

import org.picketlink.idm.credential.Password; //导入依赖的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

示例11: register

import org.picketlink.idm.credential.Password; //导入依赖的package包/类
@POST
@Consumes("application/json")
@Produces(MediaType.APPLICATION_JSON)
public User register(RegistrationParams params) throws Exception
{
   User user = new User();
   user.setUsername(params.getUsername());
   user.setFirstName(params.getFirstName());
   user.setLastName(params.getLastName());

   identityManager.add(user);
   identityManager.updateCredential(user, new Password(params.getPassword()));

   return user;
}
 
开发者ID:forgeide,项目名称:forgeide,代码行数:16,代码来源:RegistrationService.java

示例12: authenticate

import org.picketlink.idm.credential.Password; //导入依赖的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

示例13: create

import org.picketlink.idm.credential.Password; //导入依赖的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

示例14: create

import org.picketlink.idm.credential.Password; //导入依赖的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

示例15: create

import org.picketlink.idm.credential.Password; //导入依赖的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


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