/** * List of all {@link UserProperty}s exposed primarily for the remoting API. */ @Exported(name = "property", inline = true) public List<UserProperty> getAllProperties() { if (hasPermission(Jenkins.ADMINISTER)) { return Collections.unmodifiableList(properties); } return Collections.emptyList(); }
/** * With ADMINISTER permission, can delete users with persisted data but can't delete self. */ public boolean canDelete() { final IdStrategy strategy = idStrategy(); return hasPermission(Jenkins.ADMINISTER) && !strategy.equals(id, Jenkins.getAuthentication().getName()) && UserIdMapper.getInstance().isMapped(id); }
public class Course { public void enroll( User user, Student student ) { if( user.hasPermission( Permission.OVERRIDE_COURSE_RULES ) ) { add( student ); } else if( hasEnrollmentDatePassed() ) { throw new CourseException( "Enrollment date has passed." ); } else if( isClassFull() ) { throw new CourseException( "Course is full" ); } else { add( student ); } } }
private String checkPermission(User user, Sender sender) { if (!user.hasPermission(Hudson.READ)) { return sender.getNickname() + ": you may not read that user!"; } return null; }
/** * List of all {@link UserProperty}s exposed primarily for the remoting API. */ @Exported(name="property",inline=true) public List<UserProperty> getAllProperties() { if (hasPermission(Jenkins.ADMINISTER)) { return Collections.unmodifiableList(properties); } return Collections.emptyList(); }
private String checkPermission(User user, Sender sender) { if (!user.hasPermission(Hudson.READ)) { return sender.getNickname() + ": you may not read that user!"; } return null; }
/** * With ADMINISTER permission, can delete users with persisted data but * can't delete self. */ public boolean canDelete() { return hasPermission(Hudson.ADMINISTER) && !id.equals(HudsonSecurityManager.getAuthentication().getName()) && new File(getRootDir(), id).exists(); }
/** * With ADMINISTER permission, can delete users with persisted data but can't delete self. */ public boolean canDelete() { return hasPermission(Hudson.ADMINISTER) && !id.equals(Hudson.getAuthentication().getName()) && new File(getRootDir(), id).exists(); }
/** * With ADMINISTER permission, can delete users with persisted data but can't delete self. */ public boolean canDelete() { return hasPermission(Hudson.ADMINISTER) && !id.equals(Hudson.getAuthentication().getName()) && new File(getRootDir(), id).exists(); }
/** * With ADMINISTER permission, can delete users with persisted data but can't delete self. */ public boolean canDelete() { return hasPermission(Hudson.ADMINISTER) && !id.equals(Hudson.getAuthentication().getName()) && new File(getRootDir(), id).exists(); }
/** * With ADMINISTER permission, can delete users with persisted data but can't delete self. */ public boolean canDelete() { final IdStrategy strategy = idStrategy(); return hasPermission(Jenkins.ADMINISTER) && !strategy.equals(id, Jenkins.getAuthentication().getName()) && new File(getRootDir(), strategy.filenameOf(id)).exists(); }
/** * Checks if the current user has permission to create a credential. * * @param context the context. * @param includeUser whether they can use their own credentials store. * @return {@code true} if they can create a permission. * @since FIXME */ @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // used via jelly public boolean hasCreatePermission(ModelObject context, boolean includeUser) { if (includeUser) { User current = User.current(); if (current != null && current.hasPermission(CREATE)) { return true; } } if (context == null) { StaplerRequest request = Stapler.getCurrentRequest(); if (request != null) { context = request.findAncestorObject(ModelObject.class); } } for (CredentialsStore store : CredentialsProvider.lookupStores(context)) { if (store.hasPermission(CREATE)) { return true; } } return false; }
/** * Checks if the current user has permission to create a credential. * * @param context the context. * @param includeUser whether they can use their own credentials store. * @return {@code true} if they can create a permission. * @since FIXME */ @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // used via jelly public boolean hasCreatePermission(ModelObject context, boolean includeUser) { if (includeUser) { User current = User.current(); if (current != null && current.hasPermission(CREATE)) { return true; } } if (context == null) { StaplerRequest request = Stapler.getCurrentRequest(); if (request != null) { context = request.findAncestorObject(ModelObject.class); } } for (CredentialsStore store : CredentialsProvider.lookupStores(context)) { if (store.hasPermission(CREATE)) { return true; } } return false; }