Package org.geoserver.geofence.services.dto

Examples of org.geoserver.geofence.services.dto.AuthUser


        @Override
        public AuthUser load(NamePw user) throws NoAuthException {
            if(LOGGER.isLoggable(Level.FINE))
                LOGGER.log(Level.FINE, "Loading user '"+user.getName()+"'");
            AuthUser auth = realRuleReaderService.authorize(user.getName(), user.getPw());
            if(auth==null)
                throw new NoAuthException("Can't auth user ["+user.getName()+"]");
            return auth;
        }
View Full Code Here


        public ListenableFuture<AuthUser> reload(final NamePw user, AuthUser authUser) throws NoAuthException {
            if(LOGGER.isLoggable(Level.FINE))
                LOGGER.log(Level.FINE, "Reloading user '"+user.getName()+"'");

            // this is a sync implementation
            AuthUser auth = realRuleReaderService.authorize(user.getName(), user.getPw());
            if(auth==null)
                throw new NoAuthException("Can't auth user ["+user.getName()+"]");
            return Futures.immediateFuture(auth);

            // todo: we may want a asynchronous implementation
View Full Code Here

        LOGGER.log(Level.FINE, "Auth request with {0}", authentication);

        if (authentication instanceof UsernamePasswordAuthenticationToken) {
            UsernamePasswordAuthenticationToken inTok =  (UsernamePasswordAuthenticationToken)authentication;

            AuthUser authUser = null;
            try {
                authUser = ruleReaderService.authorize(
                        inTok.getPrincipal().toString(),
                        inTok.getCredentials().toString());
            } catch (Exception e) {
                LOGGER.log(Level.SEVERE, "Error in authenticating with GeoFence", e);
                throw new AuthenticationException("Error in GeoFence communication", e) {};
            }

            if(authUser != null) {
                LOGGER.log(Level.FINE, "User {0} authenticated: {1}", new Object[]{inTok.getPrincipal(), authUser});

                List<GrantedAuthority> roles = new ArrayList<GrantedAuthority>();
                roles.addAll(inTok.getAuthorities());
                roles.add(GeoServerRole.AUTHENTICATED_ROLE);
                if(authUser.getRole() == AuthUser.Role.ADMIN) {
                    roles.add(GeoServerRole.ADMIN_ROLE);
                    roles.add(new SimpleGrantedAuthority("ADMIN")); // needed for REST?!?
                }

                outTok = new UsernamePasswordAuthenticationToken(
View Full Code Here

    }

    private void doAuth(ServletRequest request, ServletResponse response) {

        BasicUser basicUser = getBasicAuth(request);
        AuthUser authUser = null;

        if(basicUser != null) {
            LOGGER.fine("Checking auth for user " + basicUser.name);
            authUser = ruleReaderService.authorize(basicUser.name, basicUser.pw);

            if(authUser == null) {
                LOGGER.info("Could not authenticate user " + basicUser.name);
            }

        } else {
            LOGGER.fine("No basicauth");
        }
       
        if(authUser != null) {
            LOGGER.fine("Found user " + authUser);
           
            List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
            authorities.add(GeoServerRole.AUTHENTICATED_ROLE);

            if(authUser.getRole() == AuthUser.Role.ADMIN) {
                authorities.add(GeoServerRole.ADMIN_ROLE);
                authorities.add(new SimpleGrantedAuthority("ADMIN")); // needed for REST?!?
            } else {
                authorities.add(new SimpleGrantedAuthority(USER_ROLE)); // ??
            }
View Full Code Here

TOP

Related Classes of org.geoserver.geofence.services.dto.AuthUser

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.