hudson.model.UserProperty Java Examples
The following examples show how to use
hudson.model.UserProperty.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HudsonPrivateSecurityRealmConfigurator.java From configuration-as-code-plugin with MIT License | 6 votes |
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()); }
Example #2
Source File: TestGitRepo.java From flaky-test-handler-plugin with Apache License 2.0 | 6 votes |
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(); }
Example #3
Source File: HudsonPrivateSecurityRealmConfigurator.java From configuration-as-code-plugin with MIT License | 5 votes |
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); } } } }
Example #4
Source File: OicSecurityRealm.java From oic-auth-plugin with MIT License | 5 votes |
@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); } } ); }
Example #5
Source File: OicSecurityRealm.java From oic-auth-plugin with MIT License | 5 votes |
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; }
Example #6
Source File: HudsonPrivateSecurityRealmConfigurator.java From configuration-as-code-plugin with MIT License | 4 votes |
@DataBoundSetter public void setProperties(List<UserProperty> properties) { this.properties = properties; }
Example #7
Source File: HudsonPrivateSecurityRealmConfigurator.java From configuration-as-code-plugin with MIT License | 4 votes |
public List<UserProperty> getProperties() { return properties; }
Example #8
Source File: OicUserProperty.java From oic-auth-plugin with MIT License | 4 votes |
@Override public UserProperty newInstance(User user) { LOGGER.fine("OicUserPropertyDescriptor.newInstance called, user:" + user); return new OicUserProperty(user.getId(), new GrantedAuthority[0]); }
Example #9
Source File: DingTalkUserProperty.java From dingtalk-plugin with MIT License | 4 votes |
@Override public UserProperty newInstance(User user) { return new DingTalkUserProperty(null); }
Example #10
Source File: DingTalkUserProperty.java From dingtalk-plugin with MIT License | 4 votes |
@Override public UserProperty newInstance(@Nullable StaplerRequest req, @Nonnull JSONObject formData) { return new DingTalkUserProperty(formData.optString("mobile")); }