/** * Checks if the current user is anonymous. */ public static boolean isAnonymous() { return Hudson.getAuthentication() instanceof AnonymousAuthenticationToken; }
/** * Checks if the current security principal has this permission. * * @return false * if the user doesn't have the permission. */ public final boolean hasPermission(Permission p) { return hasPermission(Hudson.getAuthentication(),p); }
/** * If the current thread carries the {@link CNAuthentication} object as the context, * returns it. Or else null. */ public static CNAuthentication get() { return cast(Hudson.getAuthentication()); }
public boolean isLoggedIn() { Authentication authentication = Hudson.getAuthentication(); if (authentication.getName().equals("anonymous")) { return false; } else { return true; } } }
/** * Checks if the current security principal has this permission. * * @return false * if the user doesn't have the permission. */ public final boolean hasPermission(Permission p) { return hasPermission(Hudson.getAuthentication(),p); }
/** * 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(); }
/** * Gets the {@link User} object representing the currently logged-in user, or null * if the current user is anonymous. * @since 1.172 */ public static User current() { Authentication a = Hudson.getAuthentication(); if(a instanceof AnonymousAuthenticationToken) return null; return get(a.getName()); }
/** * Check if the current user has the given {@link Permission} on the {@link AccessControlled} object given * * @param ac the {@link AccessControlled} object * @param permission the {@link Permission} * @param <AC> * @return {@code true} if the user has the {@link Permission}, {@code false} otherwise */ protected <AC extends AccessControlled> boolean hasPermission(AC ac, Permission permission) { Authentication authentication = Hudson.getAuthentication(); return authentication != Hudson.ANONYMOUS && ac.getACL().hasPermission(authentication, permission); }
/** * Check if the current user has the given {@link Permission} on the {@link AccessControlled} object given * * @param ac the {@link AccessControlled} object * @param permission the {@link Permission} * @param <AC> * @return {@code true} if the user has the {@link Permission}, {@code false} otherwise */ protected <AC extends AccessControlled> boolean hasPermission(AC ac, Permission permission) { return ac.getACL().hasPermission(Hudson.getAuthentication(), permission); }
protected void main(Channel channel) throws IOException, InterruptedException { // capture the identity given by the transport, since this can be useful for SecurityRealm.createCliAuthenticator() channel.setProperty(CLICommand.TRANSPORT_AUTHENTICATION, getAuthentication()); channel.setProperty(CliEntryPoint.class.getName(), new CliManagerImpl()); } });
protected void main(Channel channel) throws IOException, InterruptedException { // capture the identity given by the transport, since this can be useful for SecurityRealm.createCliAuthenticator() channel.setProperty(CLICommand.TRANSPORT_AUTHENTICATION, getAuthentication()); channel.setProperty(CliEntryPoint.class.getName(), new CliManagerImpl()); } });
public boolean isInGroupList() { Set<String> groups = getUsersAsSet(); GrantedAuthority[] authorities = Hudson.getAuthentication().getAuthorities(); for (GrantedAuthority authority : authorities) { if (groups.contains(authority.getAuthority())) return true; } return false; }
protected void main(Channel channel) throws IOException, InterruptedException { // capture the identity given by the transport, since this can be useful for SecurityRealm.createCliAuthenticator() channel.setProperty(CLICommand.TRANSPORT_AUTHENTICATION, getAuthentication()); channel.setProperty(CliEntryPoint.class.getName(), new CliManagerImpl()); } });
@Override protected int run() throws Exception { Authentication a = Hudson.getAuthentication(); if (a==Hudson.ANONYMOUS) throw new CmdLineException("No credentials specified."); // this causes CLI to show the command line options. ClientAuthenticationCache store = new ClientAuthenticationCache(channel); store.set(a); return 0; }
@Override protected int run() throws Exception { Authentication a = Hudson.getAuthentication(); if (a == HudsonSecurityManager.ANONYMOUS) { throw new CmdLineException("No credentials specified."); // this causes CLI to show the command line options. } ClientAuthenticationCache store = new ClientAuthenticationCache(channel); store.set(a); return 0; } }
@Override protected int run() throws Exception { Authentication a = Hudson.getAuthentication(); if (a==Hudson.ANONYMOUS) throw new CmdLineException("No credentials specified."); // this causes CLI to show the command line options. ClientAuthenticationCache store = new ClientAuthenticationCache(channel); store.set(a); return 0; }
public HttpResponse doDoDisconnect(@QueryParameter String offlineMessage) throws IOException, ServletException { if (channel!=null) { //does nothing in case computer is already disconnected checkPermission(Hudson.ADMINISTER); offlineMessage = Util.fixEmptyAndTrim(offlineMessage); disconnect(OfflineCause.create(Messages._SlaveComputer_DisconnectedBy( Hudson.getAuthentication().getName(), offlineMessage!=null ? " : " + offlineMessage : "") )); } return new HttpRedirect("."); }
public HttpResponse doDoDisconnect(@QueryParameter String offlineMessage) throws IOException, ServletException { if (channel!=null) { //does nothing in case computer is already disconnected checkPermission(Hudson.ADMINISTER); offlineMessage = Util.fixEmptyAndTrim(offlineMessage); disconnect(OfflineCause.create(Messages._SlaveComputer_DisconnectedBy( Hudson.getAuthentication().getName(), offlineMessage!=null ? " : " + offlineMessage : "") )); } return new HttpRedirect("."); }
/** * Schedules the downgrade of this plugin. */ public Future<UpdateCenterJob> deployBackup() { Hudson.getInstance().checkPermission(Hudson.ADMINISTER); UpdateCenter uc = Hudson.getInstance().getUpdateCenter(); return uc.addJob(uc.new PluginDowngradeJob(this, UpdateSite.this, Hudson.getAuthentication())); } /**
/** * Schedules the downgrade of this plugin. */ public Future<UpdateCenterJob> deployBackup() { Hudson.getInstance().checkPermission(Hudson.ADMINISTER); UpdateCenter uc = Hudson.getInstance().getUpdateCenter(); return uc.addJob(uc.new PluginDowngradeJob(this, UpdateSite.this, Hudson.getAuthentication())); } /**