Package org.acegisecurity

Examples of org.acegisecurity.Authentication


                .bean("authenticationManager");
        List<AuthenticationProvider> list = new ArrayList<AuthenticationProvider>();
        list.add(new TestingAuthenticationProvider());
        providerManager.setProviders(list);

        Authentication admin = new TestingAuthenticationToken("admin", "geoserver",
                new GrantedAuthority[] { new XACMLRole("ROLE_ADMINISTRATOR") });
        // Authentication anonymous = new TestingAuthenticationToken("anonymous", null, null);
        SecurityContextHolder.getContext().setAuthentication(admin);

    }
View Full Code Here


            Label label = new Label("footerMessage", new StringResourceModel("GeoServerHomePage.footer", this, new Model(params)));
            label.setEscapeModelStrings(false);
            add(label);
        }
       
        Authentication auth = getSession().getAuthentication();
        if(isAdmin(auth)) {
            Fragment f = new Fragment("catalogLinks", "catalogLinksFragment", this);
            Catalog catalog = getCatalog();
            f.add(new BookmarkablePageLink("layersLink", LayerPage.class)
                .add(new Label( "nlayers", ""+catalog.getLayers().size())));
View Full Code Here

    public static final PageAuthorizer DEFAULT_AUTHORIZER = new DefaultPageAuthorizer();

    public GeoServerSecuredPage() {
        super();
        Authentication auth = getSession().getAuthentication();
        if(auth == null || !auth.isAuthenticated()) {
            // emulate what acegi url control would do so that we get a proper redirect after login
            HttpServletRequest httpRequest = ((WebRequest) getRequest()).getHttpServletRequest();
            ExceptionTranslationFilter translator = (ExceptionTranslationFilter) getGeoServerApplication().getBean("consoleExceptionTranslationFilter");
            SavedRequest savedRequest = new SavedRequest(httpRequest, translator.getPortResolver());
           
View Full Code Here

    }

    public static AcegiSecurityException unauthorizedAccess(String resourceName) {
        // not hide, and not filtering out a list, this
        // is an unauthorized direct resource access, complain
        Authentication user = user();
        if (user == null || user.getAuthorities().length == 0)
            return new InsufficientAuthenticationException("Cannot access "
                    + resourceName + " as anonymous");
        else
            return new AccessDeniedException("Cannot access "
                    + resourceName + " with the current privileges");
View Full Code Here

    }
   
    public static AcegiSecurityException unauthorizedAccess() {
        // not hide, and not filtering out a list, this
        // is an unauthorized direct resource access, complain
        Authentication user = user();
        if (user == null || user.getAuthorities().length == 0)
            return new InsufficientAuthenticationException("Operation unallowed with the current privileges");
        else
            return new AccessDeniedException("Operation unallowed with the current privileges");
    }
View Full Code Here

        if(bestMatch != null) {
            Set<String> allowedRoles = bestMatch.getRoles();
            // if the rule is not the kind that allows everybody in check if the current
            // user is authenticated and has one of the required roles
            if(!allowedRoles.contains(ServiceAccessRule.ANY) && !allowedRoles.isEmpty()) {
                Authentication user = SecurityContextHolder.getContext().getAuthentication();
               
                if (user == null || user.getAuthorities().length == 0)
                    throw new InsufficientAuthenticationException("Cannot access "
                            + service + "." + method + " as anonymous");
               
                boolean roleFound = false;
                for (GrantedAuthority role : user.getAuthorities()) {
                    if(allowedRoles.contains(role.getAuthority())) {
                        roleFound = true;
                        break;
                    }
                }
View Full Code Here

    protected DefaultTransaction getDatastoreTransaction(TransactionType request)
    throws IOException {
        DefaultTransaction transaction = new DefaultTransaction();
        // use handle as the log messages
        String username = "anonymous";
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        if(authentication != null) {
            Object principal = authentication.getPrincipal();
            if(principal instanceof UserDetails) {
                username = ((UserDetails) principal).getUsername();
            }
        }
       
View Full Code Here

     *
     * @return
     */
    public static boolean isLoggedIn(HttpServletRequest request) {
        // check the user is not the anonymous one
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

        return (authentication != null)
        && !(authentication instanceof AnonymousAuthenticationToken);
    }
View Full Code Here

      add(new Label("pageTitle", getPageTitle()));

        // login form
        WebMarkupContainer loginForm = new WebMarkupContainer("loginform");
        add(loginForm);
        final Authentication user = GeoServerSession.get().getAuthentication();
        final boolean anonymous = user == null;
        loginForm.setVisible(anonymous);

        WebMarkupContainer logoutForm = new WebMarkupContainer("logoutform");
        logoutForm.setVisible(user != null);

        add(logoutForm);
        logoutForm.add(new Label("username", anonymous ? "Nobody" : user.getName()));

        // home page link
        add( new BookmarkablePageLink( "home", GeoServerHomePage.class )
            .add( new Label( "label", new StringResourceModel( "home", (Component)null, null ) )  ) );
       
View Full Code Here

     * Filters out all of the pages that cannot be accessed by the current user
     * @param pageList
     * @return
     */
    private List<MenuPageInfo> filterSecured(List<MenuPageInfo> pageList) {
        Authentication user = getSession().getAuthentication();
        List<MenuPageInfo> result = new ArrayList<MenuPageInfo>();
        for (MenuPageInfo page : pageList) {
            final Class<GeoServerBasePage> pageClass = page.getComponentClass();
            if(GeoServerSecuredPage.class.isAssignableFrom(pageClass) &&
                    !page.getPageAuthorizer().isAccessAllowed(pageClass, user))
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.