Package com.github.ebnew.ki4so.core.authentication

Examples of com.github.ebnew.ki4so.core.authentication.DefaultUserPrincipal


   
    //测试传入正确的凭据对象的情况。
    String username = "admin";
    UsernamePasswordCredential usernamePasswordCredential = new UsernamePasswordCredential();
    usernamePasswordCredential.setUsername(username);
    DefaultUserPrincipal principal = (DefaultUserPrincipal)resolver.resolvePrincipal(usernamePasswordCredential);
    Assert.assertNotNull(principal);
    Assert.assertEquals(username, principal.getId());
   
   
  }
View Full Code Here


    @Override
    public Principal resolvePrincipal(Credential credential) {
        //若类型匹配,则进行转换。
        if (credential != null && this.supports(credential)) {
            EncryCredential encryCredential = (EncryCredential) credential;
            DefaultUserPrincipal principal = new DefaultUserPrincipal();
            //解析加密后凭据信息。
            EncryCredentialInfo encryCredentialInfo = encryCredential.getEncryCredentialInfo();
            //设置用户名为唯一标识。
            if (encryCredentialInfo != null) {
                principal.setId(encryCredentialInfo.getUserId());
                //设置参数表为用户属性。
                principal.setAttributes(encryCredential.getParameters());
            }
            return principal;
        }
        return null;
    }
View Full Code Here

  @Override
  public Principal resolvePrincipal(Credential credential) {
    //若类型匹配,则进行转换。
    if(credential!=null && this.supports(credential)){
      UsernamePasswordCredential usernamePasswordCredential = (UsernamePasswordCredential)credential;
      DefaultUserPrincipal principal = new DefaultUserPrincipal();
      //设置用户名为唯一标识。
      principal.setId(usernamePasswordCredential.getUsername());
      //设置参数表为用户属性。
      principal.setAttributes(usernamePasswordCredential.getParameters());
      return principal;
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of com.github.ebnew.ki4so.core.authentication.DefaultUserPrincipal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.