类hudson.model.UserProperty源码实例Demo

下面列出了怎么用hudson.model.UserProperty的API类实例代码及写法,或者点击链接到github查看源代码。

private static Collection<UserWithPassword> getter(HudsonPrivateSecurityRealm target) {
    return target.getAllUsers().stream()
            .map(u -> {
                UserWithPassword user = new UserWithPassword(u.getId(), null);
                user.setName(u.getFullName());
                user.setDescription(u.getDescription());
                List<UserProperty> properties = u.getAllProperties()
                    .stream()
                    .filter(userProperty -> !userProperty.getClass().getName().equals("com.cloudbees.plugins.credentials.UserCredentialsProvider$UserCredentialsProperty"))
                    .collect(Collectors.toList());
                user.setProperties(properties);

                return user;
            })
            .collect(Collectors.toList());
}
 
源代码2 项目: flaky-test-handler-plugin   文件: TestGitRepo.java
public TestGitRepo(String name, File tmpDir, TaskListener listener) throws IOException, InterruptedException {
  this.name = name;
  this.listener = listener;

  envVars = new EnvVars();

  gitDir = tmpDir;
  User john = User.get(johnDoe.getName(), true);
  UserProperty johnsMailerProperty = new Mailer.UserProperty(johnDoe.getEmailAddress());
  john.addProperty(johnsMailerProperty);

  User jane = User.get(janeDoe.getName(), true);
  UserProperty janesMailerProperty = new Mailer.UserProperty(janeDoe.getEmailAddress());
  jane.addProperty(janesMailerProperty);

  // initialize the git interface.
  gitDirPath = new FilePath(gitDir);
  git = Git.with(listener, envVars).in(gitDir).getClient();

  // finally: initialize the repo
  git.init();
}
 
private static void setter(HudsonPrivateSecurityRealm target, Collection<UserWithPassword> value) throws IOException {
    for (UserWithPassword user : value) {
        User updatedUser = createAccount(target, user);
        updatedUser.setFullName(user.name);
        updatedUser.setDescription(user.description);
        if (user.getProperties() != null) {
            for (UserProperty property : user.getProperties()) {
                updatedUser.addProperty(property);
            }
        }
    }
}
 
源代码4 项目: oic-auth-plugin   文件: OicSecurityRealm.java
@Override
public SecurityComponents createSecurityComponents() {
    return new SecurityComponents(
            new AuthenticationManager() {
                public Authentication authenticate(Authentication authentication) throws AuthenticationException {
                    if (authentication instanceof AnonymousAuthenticationToken)
                        return authentication;
                    throw new BadCredentialsException("Unexpected authentication type: " + authentication);
                }
            },
            new UserDetailsService() {
	
	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
		// Retrieve the OicUserProperty to get the list of groups that has to be set in the OicUserDetails object.
		LOGGER.fine("loadUserByUsername in createSecurityComponents called, username: " + username);
		User u = User.get(username, false, Collections.emptyMap());
		if (u == null) {
			LOGGER.fine("loadUserByUsername in createSecurityComponents called, no user '" + username + "' found");
			throw new UsernameNotFoundException(username);
		}
		LOGGER.fine("loadUserByUsername in createSecurityComponents called, user: " + u);
		List<UserProperty> props = u.getAllProperties();
		LOGGER.fine("loadUserByUsername in createSecurityComponents called, number of props: " + props.size());
		GrantedAuthority[] auths = new GrantedAuthority[0];
		for (UserProperty prop: props) {
			LOGGER.fine("loadUserByUsername in createSecurityComponents called, prop of type: " + prop.getClass().toString());
			if (prop instanceof OicUserProperty) {
				OicUserProperty oicProp = (OicUserProperty) prop;
				LOGGER.fine("loadUserByUsername in createSecurityComponents called, oic prop found with username: " + oicProp.getUserName());
				auths = oicProp.getAuthoritiesAsGrantedAuthorities();
				LOGGER.fine("loadUserByUsername in createSecurityComponents called, oic prop with auths size: " + auths.length);
			}
		}
		return new OicUserDetails(username, auths);
	}
}
    );
}
 
源代码5 项目: oic-auth-plugin   文件: OicSecurityRealm.java
private UsernamePasswordAuthenticationToken loginAndSetUserData(String userName, IdToken idToken, GenericJson userInfo) throws IOException {

        GrantedAuthority[] grantedAuthorities = determineAuthorities(idToken, userInfo);
        if(LOGGER.isLoggable(Level.FINEST)) {
		    StringBuilder grantedAuthoritiesAsString = new StringBuilder("(");
		    for(GrantedAuthority grantedAuthority : grantedAuthorities) {
		        grantedAuthoritiesAsString.append(" ").append(grantedAuthority.getAuthority());
            }
            grantedAuthoritiesAsString.append(" )");
		    LOGGER.finest("GrantedAuthorities:" + grantedAuthoritiesAsString);
        }

        UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(userName, "", grantedAuthorities);

        SecurityContextHolder.getContext().setAuthentication(token);

        User user = User.get(token.getName());
        // Store the list of groups in a OicUserProperty so it can be retrieved later for the UserDetails object.
        user.addProperty(new OicUserProperty(userName, grantedAuthorities));

        if(emailFieldName!=null) {
	        String email = userInfo == null ? getField(idToken, emailFieldName) : (String) getField(userInfo, emailFieldName);
	        if (email != null) {
	            user.addProperty(new Mailer.UserProperty(email));
	        }
        }

        if(fullNameFieldName!=null) {
		    String fullName = userInfo == null ? getField(idToken, fullNameFieldName) : (String) getField(userInfo, fullNameFieldName);
		    if (fullName != null) {
		        user.setFullName(fullName);
		    }
        }

        OicUserDetails userDetails = new OicUserDetails(userName, grantedAuthorities);
        SecurityListener.fireAuthenticated(userDetails);

        return token;
    }
 
@DataBoundSetter
public void setProperties(List<UserProperty> properties) {
    this.properties = properties;
}
 
public List<UserProperty> getProperties() {
    return properties;
}
 
源代码8 项目: oic-auth-plugin   文件: OicUserProperty.java
@Override
public UserProperty newInstance(User user) {
	LOGGER.fine("OicUserPropertyDescriptor.newInstance called, user:" + user);
	return new OicUserProperty(user.getId(), new GrantedAuthority[0]);
}
 
源代码9 项目: dingtalk-plugin   文件: DingTalkUserProperty.java
@Override
public UserProperty newInstance(User user) {
  return new DingTalkUserProperty(null);
}
 
源代码10 项目: dingtalk-plugin   文件: DingTalkUserProperty.java
@Override
public UserProperty newInstance(@Nullable StaplerRequest req, @Nonnull JSONObject formData) {
  return new DingTalkUserProperty(formData.optString("mobile"));
}
 
 类所在包
 同包方法