/** * Your implementation will call this method to add this identifier to the current user * of an already authenticated session. * * <p> * This method will record the identifier in {@link FederatedLoginServiceUserProperty} so that * in the future the user can login to Hudson with the identifier. */ public void addToCurrentUser() throws IOException { User u = User.current(); if (u==null) throw new IllegalStateException("Current request is unauthenticated"); addTo(u); }
/** * Locates the user who owns this identifier. */ @CheckForNull public final User locateUser() { Class<? extends FederatedLoginServiceUserProperty> pt = getUserPropertyClass(); String id = getIdentifier(); for (User u : User.getAll()) { if (u.getProperty(pt).has(id)) return u; } return null; }
/** * Call this method to authenticate the user when you confirmed (via your protocol specific work) that * the current HTTP request indeed owns this identifier. * * <p> * This method will locate the user who owns this identifier, associate the credential with * the current session. IOW, it signs in the user. * * @throws UnclaimedIdentityException * If this identifier is not claimed by anyone. If you just let this exception propagate * to the caller of your "doXyz" method, it will either render an error page or initiate * a user registration session (provided that {@link SecurityRealm} supports that.) */ @SuppressWarnings("ACL.impersonate") @Nonnull public User signin() throws UnclaimedIdentityException { User u = locateUser(); if (u!=null) { // login as this user UserDetails d = Jenkins.getInstance().getSecurityRealm().loadUserByUsername(u.getId()); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(d,"",d.getAuthorities()); token.setDetails(d); SecurityContextHolder.getContext().setAuthentication(token); return u; } else { // Unassociated identity. throw new UnclaimedIdentityException(this); } }
/** * Call this method to authenticate the user when you confirmed (via * your protocol specific work) that the current HTTP request indeed * owns this identifier. * * <p> This method will locate the user who owns this identifier, * associate the credential with the current session. IOW, it signs in * the user. * * @throws UnclaimedIdentityException If this identifier is not claimed * by anyone. If you just let this exception propagate to the caller of * your "doXyz" method, it will either render an error page or initiate * a user registration session (provided that {@link SecurityRealm} * supports that.) */ public User signin() throws UnclaimedIdentityException { User u = locateUser(); if (u != null) { // login as this user UserDetails d = HudsonSecurityEntitiesHolder.getHudsonSecurityManager().getSecurityRealm().loadUserByUsername(u.getId()); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(d, "", d.getAuthorities()); token.setDetails(d); SecurityContextHolder.getContext().setAuthentication(token); return u; } else { // Unassociated identity. throw new UnclaimedIdentityException(this); } }
/** * Call this method to authenticate the user when you confirmed (via your protocol specific work) that * the current HTTP request indeed owns this identifier. * * <p> * This method will locate the user who owns this identifier, associate the credential with * the current session. IOW, it signs in the user. * * @throws UnclaimedIdentityException * If this identifier is not claimed by anyone. If you just let this exception propagate * to the caller of your "doXyz" method, it will either render an error page or initiate * a user registration session (provided that {@link SecurityRealm} supports that.) */ public User signin() throws UnclaimedIdentityException { User u = locateUser(); if (u!=null) { // login as this user UserDetails d = Hudson.getInstance().getSecurityRealm().loadUserByUsername(u.getId()); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(d,"",d.getAuthorities()); token.setDetails(d); SecurityContextHolder.getContext().setAuthentication(token); return u; } else { // Unassociated identity. throw new UnclaimedIdentityException(this); } }
/** * Call this method to authenticate the user when you confirmed (via your protocol specific work) that * the current HTTP request indeed owns this identifier. * * <p> * This method will locate the user who owns this identifier, associate the credential with * the current session. IOW, it signs in the user. * * @throws UnclaimedIdentityException * If this identifier is not claimed by anyone. If you just let this exception propagate * to the caller of your "doXyz" method, it will either render an error page or initiate * a user registration session (provided that {@link SecurityRealm} supports that.) */ @SuppressWarnings("ACL.impersonate") @Nonnull public User signin() throws UnclaimedIdentityException { User u = locateUser(); if (u!=null) { // login as this user UserDetails d = Jenkins.getInstance().getSecurityRealm().loadUserByUsername(u.getId()); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(d,"",d.getAuthorities()); token.setDetails(d); SecurityContextHolder.getContext().setAuthentication(token); return u; } else { // Unassociated identity. throw new UnclaimedIdentityException(this); } }
/** * Call this method to authenticate the user when you confirmed (via your protocol specific work) that * the current HTTP request indeed owns this identifier. * * <p> * This method will locate the user who owns this identifier, associate the credential with * the current session. IOW, it signs in the user. * * @throws UnclaimedIdentityException * If this identifier is not claimed by anyone. If you just let this exception propagate * to the caller of your "doXyz" method, it will either render an error page or initiate * a user registration session (provided that {@link SecurityRealm} supports that.) */ public User signin() throws UnclaimedIdentityException { User u = locateUser(); if (u!=null) { // login as this user UserDetails d = Hudson.getInstance().getSecurityRealm().loadUserByUsername(u.getId()); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(d,"",d.getAuthorities()); token.setDetails(d); SecurityContextHolder.getContext().setAuthentication(token); return u; } else { // Unassociated identity. throw new UnclaimedIdentityException(this); } }
/** * Call this method to authenticate the user when you confirmed (via your protocol specific work) that * the current HTTP request indeed owns this identifier. * * <p> * This method will locate the user who owns this identifier, associate the credential with * the current session. IOW, it signs in the user. * * @throws UnclaimedIdentityException * If this identifier is not claimed by anyone. If you just let this exception propagate * to the caller of your "doXyz" method, it will either render an error page or initiate * a user registration session (provided that {@link SecurityRealm} supports that.) */ public User signin() throws UnclaimedIdentityException { User u = locateUser(); if (u!=null) { // login as this user UserDetails d = Hudson.getInstance().getSecurityRealm().loadUserByUsername(u.getId()); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(d,"",d.getAuthorities()); token.setDetails(d); SecurityContextHolder.getContext().setAuthentication(token); return u; } else { // Unassociated identity. throw new UnclaimedIdentityException(this); } }
/** * Your implementation will call this method to add this identifier to * the current user of an already authenticated session. * * <p> This method will record the identifier in * {@link FederatedLoginServiceUserProperty} so that in the future the * user can login to Hudson with the identifier. */ public void addToCurrentUser() throws IOException { User u = User.current(); if (u == null) { throw new IllegalStateException("Current request is unauthenticated"); } addTo(u); }
/** * Your implementation will call this method to add this identifier to the current user * of an already authenticated session. * * <p> * This method will record the identifier in {@link FederatedLoginServiceUserProperty} so that * in the future the user can login to Hudson with the identifier. */ public void addToCurrentUser() throws IOException { User u = User.current(); if (u==null) throw new IllegalStateException("Current request is unauthenticated"); addTo(u); }
/** * Locates the user who owns this identifier. */ @CheckForNull public final User locateUser() { Class<? extends FederatedLoginServiceUserProperty> pt = getUserPropertyClass(); String id = getIdentifier(); for (User u : User.getAll()) { if (u.getProperty(pt).has(id)) return u; } return null; }
/** * Your implementation will call this method to add this identifier to the current user * of an already authenticated session. * * <p> * This method will record the identifier in {@link FederatedLoginServiceUserProperty} so that * in the future the user can login to Hudson with the identifier. */ public void addToCurrentUser() throws IOException { User u = User.current(); if (u==null) throw new IllegalStateException("Current request is unauthenticated"); addTo(u); }
/** * Locates the user who owns this identifier. */ public final User locateUser() { Class<? extends FederatedLoginServiceUserProperty> pt = getUserPropertyClass(); String id = getIdentifier(); for (User u : User.getAll()) { if (u.getProperty(pt).has(id)) return u; } return null; }
/** * Locates the user who owns this identifier. */ public final User locateUser() { Class<? extends FederatedLoginServiceUserProperty> pt = getUserPropertyClass(); String id = getIdentifier(); for (User u : User.getAll()) { if (u.getProperty(pt).has(id)) return u; } return null; }
/** * Creates an account and associates that with the given identity. Used in conjunction * with {@link #commenceSignup(FederatedIdentity)}. */ public User doCreateAccountWithFederatedIdentity(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { User u = _doCreateAccount(req,rsp,"signupWithFederatedIdentity.jelly"); if (u!=null) ((FederatedIdentity)req.getSession().getAttribute(FEDERATED_IDENTITY_SESSION_KEY)).addTo(u); return u; }
@Override public String toString() { return getIdentifier(); } }
/** * Your implementation will call this method to add this identifier to the current user * of an already authenticated session. * * <p> * This method will record the identifier in {@link FederatedLoginServiceUserProperty} so that * in the future the user can login to Hudson with the identifier. */ public void addToCurrentUser() throws IOException { User u = User.current(); if (u==null) throw new IllegalStateException("Current request is unauthenticated"); addTo(u); }
@Override public String toString() { return getIdentifier(); } }
/** * Adds this identity to the specified user. */ public void addTo(User u) throws IOException { FederatedLoginServiceUserProperty p = u.getProperty(getUserPropertyClass()); if (p == null) { p = (FederatedLoginServiceUserProperty) UserProperty.all().find(getUserPropertyClass()).newInstance(u); u.addProperty(p); } p.addIdentifier(getIdentifier()); }
/** * Creates an account and associates that with the given identity. Used in * conjunction with {@link #commenceSignup(FederatedIdentity)}. */ public User doCreateAccountWithFederatedIdentity(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { User u = _doCreateAccount(req, rsp, "signupWithFederatedIdentity.jelly"); if (u != null) { ((FederatedIdentity) req.getSession().getAttribute(FEDERATED_IDENTITY_SESSION_KEY)).addTo(u); } return u; } private static final String FEDERATED_IDENTITY_SESSION_KEY = HudsonPrivateSecurityRealm.class.getName() + ".federatedIdentity";