Package org.geoserver.security

Examples of org.geoserver.security.GeoServerSecurityManager$FilterHelper


        return auth != null && auth.isAuthenticated() && !(auth instanceof AnonymousAuthenticationToken);
    }

    boolean runSecurityFilters(HttpServletRequest req, HttpServletResponse res, String... chainNames)
        throws IOException, ServletException {
        final GeoServerSecurityManager secMgr = GeoServerExtensions.bean(GeoServerSecurityManager.class);
        GeoServerSecurityFilterChain secFilterChain =
            new GeoServerSecurityFilterChain(secMgr.getSecurityConfig().getFilterChain());

        List<Filter> filters = new ArrayList<Filter>();
        for (String chainName : chainNames) {
            RequestFilterChain reqFilterChain = secFilterChain.getRequestChainByName(chainName);
            filters.addAll(Lists.transform(reqFilterChain.getCompiledFilterNames(), new Function<String, Filter>() {
                @Override
                public Filter apply(@Nullable String s) {
                    try {
                        return secMgr.loadFilter(s);
                    } catch (IOException e) {
                        //TODO: something better here
                        throw new RuntimeException("Unable to load security filter:" + s);
                    }
                }
View Full Code Here


        }

        @Override
        protected void doMarshal(Object source, HierarchicalStreamWriter writer,
                MarshallingContext context) {
            GeoServerSecurityManager secMgr = encryptPasswordFields ? getSecurityManager() : null;
            if (secMgr != null && secMgr.isInitialized()) {
                //set the hint for the map converter as to which fields to encode in the connection
                // parameter of this store
                context.put(BreifMapConverter.ENCRYPTED_FIELDS_KEY,
                    secMgr.getConfigPasswordEncryptionHelper().getEncryptedFields((StoreInfo)source));
            }

            super.doMarshal(source, writer, context);
        }
View Full Code Here

                            : WMSStoreInfoImpl.DEFAULT_READ_TIMEOUT);
                }
            }

            //process any parameters that require decryption
            GeoServerSecurityManager secMgr = encryptPasswordFields ? getSecurityManager() : null;
            if (secMgr != null) {
                secMgr.getConfigPasswordEncryptionHelper().decode(store);
            }

            log(Level.INFO, "Loaded store '" +  store.getName() "', " + (store.isEnabled() ? "enabled" : "disabled"));
            return store;
        }
View Full Code Here

    public void checkRoleIsUsed(GeoServerRole role) throws IOException {
       
        if (checkAgainstRules==false)
            return;
       
        GeoServerSecurityManager secMgr = getSecurityManager();
       
        List<String> keys = new ArrayList<String>();
        for (ServiceAccessRule rule :
            secMgr.getServiceAccessRuleDAO().getRulesAssociatedWithRole(role.getAuthority()))
            keys.add(rule.getKey());
        for (DataAccessRule rule :
            secMgr.getDataAccessRuleDAO().getRulesAssociatedWithRole(role.getAuthority()))
            keys.add(rule.getKey());
       
        if (keys.size()>0) {
            String ruleString = StringUtils.collectionToCommaDelimitedString(keys);   
            throw createSecurityException(ROLE_IN_USE_$2, role.getAuthority(),ruleString);
View Full Code Here

            Set<String> encryptionFields = (Set<String>)context.get(ENCRYPTED_FIELDS_KEY);
            if (encryptionFields==null) {
                encryptionFields=Collections.emptySet();
            }

            GeoServerSecurityManager secMgr = encryptPasswordFields ? getSecurityManager() : null;
            Map map = (Map) source;
            for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) {
                Map.Entry entry = (Map.Entry) iterator.next();
               
                if ( entry.getValue() == null ) {
                    continue;
                }
               
                writer.startNode("entry");
                writer.addAttribute( "key", entry.getKey().toString());
                if ( entry.getValue() != null ) {
                    Object value = entry.getValue();
                    String complexTypeId = getComplexTypeId(value.getClass());
                    if(complexTypeId == null) {
                        String str = Converters.convert(value, String.class);
                        if(str == null) {
                            str = value.toString();
                        }
                        if (encryptionFields.contains(entry.getKey()) && secMgr != null) {
                            str = secMgr.getConfigPasswordEncryptionHelper().encode(str);
                        }
                        writer.setValue(str);
                    } else {
                        writer.startNode(complexTypeId);
                        context.convertAnother(value);
View Full Code Here

        this.scriptMgr = scriptMgr;
    }

    @Override
    public final Resource findTarget(Request request, Response response) {
        GeoServerSecurityManager secMgr = scriptMgr.getSecurityManager();

        // ensure user authenticated
        if (!secMgr.checkAuthenticationForAdminRole()) {
            response.setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
            return null;
        }

        // extra step of requiring that teh admin password has been changed
        if (secMgr.checkForDefaultAdminPassword()) {
            response.setStatus(Status.CLIENT_ERROR_FORBIDDEN, "insecure password");
            return null;
        }

        return doFindTarget(request, response);
View Full Code Here

        this.config = config;
    }

    @Override
    public Component getPageBodyComponent(String id) {
        GeoServerSecurityManager secMgr = GeoServerExtensions.bean(GeoServerSecurityManager.class);
        if (secMgr.checkAuthenticationForAdminRole() && config.isEnabled()) {
            return new JDBCConfigStatusPanel(id, config);
        }
        return new WebMarkupContainer(id)// Placeholder
    }
View Full Code Here

            //getSecurityManager().saveRoleService(config);
        } catch (SecurityConfigException ex) {
            throw new IOException(ex);
        }

        GeoServerSecurityManager secMgr = createNiceMock(GeoServerSecurityManager.class);
        expect(secMgr.listRoleServices()).andReturn(
            new TreeSet<String>(Arrays.asList("default", "jdbc"))).anyTimes();
        replay(secMgr);
        validator = new JdbcSecurityConfigValidator(secMgr);

        JDBCRoleServiceConfig oldConfig = new JDBCRoleServiceConfig(config);
View Full Code Here

            validator.validateAddUserGroupService(config);
        } catch (SecurityConfigException ex) {
            throw new IOException(ex);
        }

        GeoServerSecurityManager secMgr = createNiceMock(GeoServerSecurityManager.class);
        expect(secMgr.listUserGroupServices()).andReturn(
            new TreeSet<String>(Arrays.asList("default", "jdbc"))).anyTimes();
       
        GeoServerPlainTextPasswordEncoder pwEncoder = getPlainTextPasswordEncoder();
        expect(secMgr.loadPasswordEncoder(pwEncoder.getName())).andReturn(pwEncoder).anyTimes();
        expect(secMgr.listPasswordValidators()).andReturn(
            new TreeSet<String>(Arrays.asList(PasswordValidator.DEFAULT_NAME))).anyTimes();
        replay(secMgr);

        validator = new JdbcSecurityConfigValidator(secMgr);
View Full Code Here

        return formTester.getForm().get("details:config.userGroupServiceName").getDefaultModelObjectAsString();
    }
   
    @Before
    public void clearAuthProvider() throws Exception {
        GeoServerSecurityManager secMgr = getSecurityManager();
        if (secMgr.listAuthenticationProviders().contains("default2")) {
            SecurityAuthProviderConfig config =
                    secMgr.loadAuthenticationProviderConfig("default2");
            secMgr.removeAuthenticationProvider(config);
        }
    }
View Full Code Here

TOP

Related Classes of org.geoserver.security.GeoServerSecurityManager$FilterHelper

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.