Package org.acegisecurity

Examples of org.acegisecurity.Authentication


     *
     * @throws AccessDeniedException
     *      if the user doesn't have the permission.
     */
    public final void checkPermission(Permission p) {
        Authentication a = Jenkins.getAuthentication();
        if(!hasPermission(a,p))
            throw new AccessDeniedException2(a,p);
    }
View Full Code Here


     * but instead of marking the build as aborted, mark it as specified result.
     *
     * @since 1.417
     */
    public void interrupt(Result result) {
        Authentication a = Jenkins.getAuthentication();
        if(a instanceof AnonymousAuthenticationToken || a==ACL.SYSTEM)
            interrupt(result, new CauseOfInterruption[0]);
        else {
            // worth recording who did it
            // avoid using User.get() to avoid deadlock.
            interrupt(result, new UserInterruption(a.getName()));
        }
    }
View Full Code Here

    /**
     * Gets the {@link Authentication} object that represents the user
     * associated with the current request.
     */
    public static Authentication getAuthentication() {
        Authentication a = SecurityContextHolder.getContext().getAuthentication();
        // on Tomcat while serving the login page, this is null despite the fact
        // that we have filters. Looking at the stack trace, Tomcat doesn't seem to
        // run the request through filters when this is the login request.
        // see http://www.nabble.com/Matrix-authorization-problem-tp14602081p14886312.html
        if(a==null)
View Full Code Here

            return "test command";
        }

        @Override
        protected int run() throws Exception {
            Authentication auth = Jenkins.getAuthentication();
            Assert.assertNotSame(Jenkins.ANONYMOUS,auth);
            Assert.assertEquals("abc", auth.getName());
            return 0;
        }
View Full Code Here

            return "makes sure that the command is running as anonymous user";
        }

        @Override
        protected int run() throws Exception {
            Authentication auth = Jenkins.getAuthentication();
            Assert.assertSame(Jenkins.ANONYMOUS,auth);
            return 0;
        }
View Full Code Here

    public String getShortDescription() {
        return Messages.WhoAmICommand_ShortDescription();
    }

    protected int run() {
        Authentication a = Jenkins.getAuthentication();
        stdout.println("Authenticated as: "+a.getName());
        stdout.println("Authorities:");
        for (GrantedAuthority ga : a.getAuthorities()) {
            stdout.println("  "+ga.getAuthority());
        }
        return 0;
    }
View Full Code Here

        return Jenkins.ANONYMOUS;
    }

    @Override
    protected int run() throws Exception {
        Authentication a = Jenkins.getAuthentication();
        if (a== Jenkins.ANONYMOUS)
            throw new CmdLineException("No credentials specified."); // this causes CLI to show the command line options.

        ClientAuthenticationCache store = new ClientAuthenticationCache(checkChannel());
        store.set(a);
View Full Code Here

     * 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 = Jenkins.getAuthentication();
        if(a instanceof AnonymousAuthenticationToken)
            return null;
        return get(a.getName());
    }
View Full Code Here

                            registerOptionHandlers();
                            CmdLineParser parser = new CmdLineParser(null);
                            try {
                                SecurityContext sc = SecurityContextHolder.getContext();
                                Authentication old = sc.getAuthentication();
                                try {
                                    //  build up the call sequence
                                    Stack<Method> chains = new Stack<Method>();
                                    Method method = m;
                                    while (true) {
                                        chains.push(method);
                                        if (Modifier.isStatic(method.getModifiers()))
                                            break; // the chain is complete.

                                        // the method in question is an instance method, so we need to resolve the instance by using another resolver
                                        Class<?> type = method.getDeclaringClass();
                                        method = findResolver(type);
                                        if (method==null) {
                                            stderr.println("Unable to find the resolver method annotated with @CLIResolver for "+type);
                                            return 1;
                                        }
                                    }

                                    List<MethodBinder> binders = new ArrayList<MethodBinder>();

                                    while (!chains.isEmpty())
                                        binders.add(new MethodBinder(chains.pop(),this,parser));

                                    // authentication
                                    CliAuthenticator authenticator = Jenkins.getInstance().getSecurityRealm().createCliAuthenticator(this);
                                    new ClassParser().parse(authenticator,parser);

                                    // fill up all the binders
                                    parser.parseArgument(args);

                                    Authentication auth = authenticator.authenticate();
                                    if (auth== Jenkins.ANONYMOUS)
                                        auth = loadStoredAuthentication();
                                    sc.setAuthentication(auth); // run the CLI with the right credential
                                    hudson.checkPermission(Jenkins.READ);
View Full Code Here

        if(!usingSSO) {
            log.info("SSO is not enabled. Skipping CustomUserRegistry functionality.");
            return null;
        }
       
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
       
        if(authentication == null) {
            log.warn("No Authentication found in SecurityContextHolder.");
            return null;
        }
       
        Object oPrincipal = authentication.getPrincipal();
       
        if(oPrincipal == null) {
            log.warn("Principal is null. Skipping auto-registration.");
            return null;
        }
View Full Code Here

TOP

Related Classes of org.acegisecurity.Authentication

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.