@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; }
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)); } }
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; }
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() ) ); } }