java类org.springframework.security.core.userdetails.memory.UserAttributeEditor的实例源码

ApiUserDetailsService.java 文件源码 项目:artsholland-platform 阅读 16 收藏 0 点赞 0 评论 0
@Override
public UserDetails loadUserByUsername(String apiKey)
        throws UsernameNotFoundException {
    String userPropsValue = userProperties.getProperty(apiKey);

    if (userPropsValue == null) {
        throw new UsernameNotFoundException(apiKey);
    }

    UserAttributeEditor configAttribEd = new UserAttributeEditor();
    configAttribEd.setAsText(userPropsValue);
    UserAttribute userAttributes = (UserAttribute) configAttribEd.getValue(); 

    UserDetails user = new User(apiKey, 
            userAttributes.getPassword(), 
            userAttributes.isEnabled(), 
            true, 
            true, 
            true, 
            userAttributes.getAuthorities());
    return user;
}
UserStore.java 文件源码 项目:incubator-taverna-server 阅读 21 收藏 0 点赞 0 评论 0
public void setBaselineUserProperties(Properties props) {
    UserAttributeEditor parser = new UserAttributeEditor();

    for (Object name : props.keySet()) {
        String username = (String) name;
        String value = props.getProperty(username);

        // Convert value to a password, enabled setting, and list of granted
        // authorities
        parser.setAsText(value);

        UserAttribute attr = (UserAttribute) parser.getValue();
        if (attr != null && attr.isEnabled())
            base.put(username, new BootstrapUserInfo(username, attr));
    }
}
VistaUserMapEditor.java 文件源码 项目:eHMP 阅读 20 收藏 0 点赞 0 评论 0
public static VistaUserMap addUsersFromProperties(VistaUserMap userMap, Properties props) {
    // Now we have properties, process each one individually
    UserAttributeEditor configAttribEd = new UserAttributeEditor();

    for (Iterator iter = props.keySet().iterator(); iter.hasNext(); ) {
        String key = (String) iter.next();
        String value = props.getProperty(key);

        // Convert value to a password, enabled setting, and list of granted authorities
        configAttribEd.setAsText(value);

        UserAttribute attr = (UserAttribute) configAttribEd.getValue();

        // Make a user object, assuming the properties were properly provided
        if (attr != null) {
            String duz = StringUtils.split(key, "@")[0];
            String stationNumber = StringUtils.split(key, "@")[1];
            String access = StringUtils.split(attr.getPassword(), ";")[0];
            String verify = StringUtils.split(attr.getPassword(), ";")[1];
            VistaUserDetails user = new VistaUser(new RpcHost("localhost"), new Random().toString(), stationNumber, stationNumber, duz, verify, "foobar", attr.isEnabled(), true, true, true, attr.getAuthorities());
            userMap.addUser(user);
        }
    }

    return userMap;
}
UserDetailsServiceImpl.java 文件源码 项目:pentaho-osgi-bundles 阅读 23 收藏 0 点赞 0 评论 0
public UserDetailsServiceImpl( ITenantedPrincipleNameResolver tenantedPrincipleNameResolver,
    Map<String, String> userDefMap ) {
  this.tenantedPrincipleNameResolver = tenantedPrincipleNameResolver;

  for ( String username : userDefMap.keySet() ) {

    UserAttributeEditor userAttributeEditor = new UserAttributeEditor();
    userAttributeEditor.setAsText( userDefMap.get( username ) );
    userDetailsList.put( username, new UserDetailsImpl( username, (UserAttribute) userAttributeEditor
        .getValue() ) );
  }
}


问题


面经


文章

微信
公众号

扫码关注公众号