Package hudson.model

Examples of hudson.model.User


        createPreviousNextRelationShip(this.previousBuildUpstreamBuild, this.upstreamBuildBetweenPreviousAndCurrent,
                this.upstreamBuild);
               
       
       
        User user1 = mock(User.class);
        when(user1.getProperty(Mailer.UserProperty.class)).thenReturn(new Mailer.UserProperty("this.one.should.not.be.included@example.com"));
        Set<User> badGuys1 = Sets.newHashSet(user1);
        when(this.previousBuildUpstreamBuild.getCulprits()).thenReturn(badGuys1);
       
        User user2 = mock(User.class);
        when(user2.getProperty(Mailer.UserProperty.class)).thenReturn(new Mailer.UserProperty("this.one.must.be.included@example.com"));
        Set<User> badGuys2 = Sets.newHashSet(user2);
        when(this.upstreamBuildBetweenPreviousAndCurrent.getCulprits()).thenReturn(badGuys2);
       
        User user3 = mock(User.class);
        when(user3.getProperty(Mailer.UserProperty.class)).thenReturn(new Mailer.UserProperty("this.one.must.be.included.too@example.com"));
        Set<User> badGuys3 = Sets.newHashSet(user3);
        when(this.upstreamBuild.getCulprits()).thenReturn(badGuys3);
       
       
        this.previousBuild = mock(AbstractBuild.class);
View Full Code Here


            if (idx >= 0) {
                String username = uidpassword.substring(0, idx);
                String password = uidpassword.substring(idx+1);

                // attempt to authenticate as API token
                User u = User.get(username);
                ApiTokenProperty t = u.getProperty(ApiTokenProperty.class);
                if (t!=null && t.matchesPassword(password)) {
                    // even if we fail to match the password, we aren't rejecting it.
                    // as the user might be passing in a real password.
                    SecurityContext oldContext = ACL.impersonate(u.impersonate());
                    try {
                        chain.doFilter(request,response);
                        return;
                    } finally {
                        SecurityContextHolder.setContext(oldContext);
View Full Code Here

    /**
     * Tests the UI interaction and authentication.
     */
    public void testBasics() throws Exception {
        jenkins.setSecurityRealm(createDummySecurityRealm());
        User u = User.get("foo");
        ApiTokenProperty t = u.getProperty(ApiTokenProperty.class);
        final String token = t.getApiToken();

        // make sure the UI shows the token
        HtmlPage config = createWebClient().goTo(u.getUrl() + "/configure");
        HtmlForm form = config.getFormByName("config");
        assertEquals(token, form.getInputByName("_.apiToken").getValueAttribute());

        // round-trip shouldn't change the API token
        submit(form);
        assertSame(t, u.getProperty(ApiTokenProperty.class));

        WebClient wc = createWebClient();
        wc.setCredentialsProvider(new CredentialsProvider() {
            public Credentials getCredentials(AuthScheme scheme, String host, int port, boolean proxy) throws CredentialsNotAvailableException {
                return new UsernamePasswordCredentials("foo", token);
View Full Code Here

    public boolean getInsensitiveSearch() {
        return insensitiveSearch;
    }
   
    public static boolean isCaseInsensitive(){
        User user = User.current();
        boolean caseInsensitive = false;
        if(user!=null && user.getProperty(UserSearchProperty.class).getInsensitiveSearch()){//Searching for anonymous user is case-sensitive
          caseInsensitive=true;
        }
        return caseInsensitive;
    }
View Full Code Here

         *      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 = Jenkins.getInstance().getSecurityRealm().loadUserByUsername(u.getId());

                UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(d,"",d.getAuthorities());
                token.setDetails(d);
                SecurityContextHolder.getContext().setAuthentication(token);
                return u;
View Full Code Here

         * <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);
        }
View Full Code Here

            rsp.setHeader("WWW-Authenticate","Basic realm=\"Jenkins user\"");
            return;
        }

        {// attempt to authenticate as API token
            User u = User.get(username);
            ApiTokenProperty t = u.getProperty(ApiTokenProperty.class);
            if (t!=null && t.matchesPassword(password)) {
                SecurityContextHolder.getContext().setAuthentication(u.impersonate());
                try {
                    chain.doFilter(request,response);
                } finally {
                    SecurityContextHolder.clearContext();
                }
View Full Code Here

     * @param csAuthorEmail user email.
     * @param createAccountBaseOnCommitterEmail true if create new user based on committer's email.
     * @return {@link User}
     */
    User findOrCreateUser(String csAuthor, String csAuthorEmail, boolean createAccountBaseOnCommitterEmail) {
        User user;
        if (createAccountBaseOnCommitterEmail) {
            user = User.get(csAuthorEmail, true);
            try {
                user.setFullName(csAuthor);
                user.save();
            } catch (IOException e) {
                LOGGER.log(Level.FINEST, "Could not set author name to user properties.", e);
            }
        } else {
            user = User.get(csAuthor, true);
        }

        // set email address for user if needed
        if (fixEmpty(csAuthorEmail) != null) {
            try {
                user.addProperty(new Mailer.UserProperty(csAuthorEmail));
            } catch (IOException e) {
                LOGGER.log(Level.FINEST, "Failed to add email to user properties.", e);
            }
        }
        return user;
View Full Code Here


    @Test
    public void testFindOrCreateUserBasedOnEmail() throws IOException {
        mockStatic(User.class);
        User user = createMock(User.class);
        user.setFullName(AUTHOR_NAME);
        user.save();
        user.addProperty(EasyMock.<UserProperty>anyObject());
        expect(User.get(AUTHOR_EMAIL, true)).andReturn(user);
        replay(User.class, user);
        GitChangeSet changeSet = new GitChangeSet(new ArrayList<String>(), true);
        changeSet.findOrCreateUser(AUTHOR_NAME, AUTHOR_EMAIL, true);
        verify(User.class, user);
View Full Code Here

    }

    @Test
    public void testFindOrCreateUserBasedOnName() throws IOException {
        mockStatic(User.class);
        User user = createMock(User.class);
        user.addProperty(EasyMock.<UserProperty>anyObject());
        expect(User.get(AUTHOR_NAME, true)).andReturn(user);
        replay(User.class, user);
        GitChangeSet changeSet = new GitChangeSet(new ArrayList<String>(), false);
        changeSet.findOrCreateUser(AUTHOR_NAME, AUTHOR_EMAIL, false);
        verify(User.class, user);
View Full Code Here

TOP

Related Classes of hudson.model.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.