Package org.geoserver.security.password

Examples of org.geoserver.security.password.MasterPasswordProviderConfig


    class MasterPasswordProviderHelper extends
        HelperBase<MasterPasswordProvider, MasterPasswordProviderConfig> {

        @Override
        public MasterPasswordProvider load(String name) throws IOException {
            MasterPasswordProviderConfig config = loadConfig(name);
            if (config == null) {
                return null;
            }

            //look up the provider for this config
            MasterPasswordProvider provider = null;

            for (GeoServerSecurityProvider p  : lookupSecurityProviders()) {
                if (p.getMasterPasswordProviderClass() == null) {
                    continue;
                }
                if (p.getMasterPasswordProviderClass().getName().equals(config.getClassName())) {
                    provider = p.createMasterPasswordProvider(config);
                    break;
                }   
            }
            if (provider == null) {
                throw new IOException("No master password provider matching config: " + config);
            }

            //ensure that the provider is a final class
            if (!Modifier.isFinal(provider.getClass().getModifiers())) {
                throw new RuntimeException("Master password provider class: " +
                    provider.getClass().getCanonicalName() + " is not final");
            }

            provider.setName(config.getName());
            provider.setSecurityManager(GeoServerSecurityManager.this);
            provider.initializeFromConfig(config);
            return provider;
        }
View Full Code Here


     */
    public synchronized void saveMasterPasswordConfig(MasterPasswordConfig config,
        char[] currPasswd, char[] newPasswd, char[] newPasswdConfirm) throws Exception {

        //load the (possibly new) master password provider
        MasterPasswordProviderConfig mpProviderConfig =
            loadMasterPassswordProviderConfig(config.getProviderName());
        MasterPasswordProvider mpProvider = loadMasterPasswordProvider(config.getProviderName());

        if (mpProviderConfig.isReadOnly()) {
            //new password comes from the provider
            newPasswd = mpProvider.getMasterPassword();
        }

        //first validate the password change
        MasterPasswordChangeRequest req = new MasterPasswordChangeRequest();
        req.setCurrentPassword(currPasswd);
        req.setNewPassword(newPasswd);
        req.setConfirmPassword(newPasswdConfirm);

        MasterPasswordChangeValidator val = new MasterPasswordChangeValidator(this);
        val.validateChangeRequest(req);

        //validate the new config
        MasterPasswordConfigValidator validator = new MasterPasswordConfigValidator(this);
        validator.validateMasterPasswordConfig(config);

        //save the current config to fall back to               
        MasterPasswordConfig oldConfig = new MasterPasswordConfig(this.masterPasswordConfig);
        String oldMasterPasswdDigest = masterPasswdDigest;

        KeyStoreProvider ksProvider = getKeyStoreProvider();
        synchronized (ksProvider) {
            ksProvider.prepareForMasterPasswordChange(currPasswd, newPasswdConfirm);
            try {
                if (!mpProviderConfig.isReadOnly()) {
                    //write it back first
                    try {
                        mpProvider.setMasterPassword(newPasswd);
                    } catch (Exception e) {
                        throw new IOException(e);
View Full Code Here

        getPasswordPolicyRoot();
        getFilterRoot();
        getMasterPasswordProviderRoot();

        //master password configuration
        MasterPasswordProviderConfig mpProviderConfig = loadMasterPassswordProviderConfig("default");
        if (mpProviderConfig == null) {
            mpProviderConfig = new URLMasterPasswordProviderConfig();
            mpProviderConfig.setName("default");
            mpProviderConfig.setClassName(URLMasterPasswordProvider.class.getCanonicalName());
            mpProviderConfig.setReadOnly(false);

            ((URLMasterPasswordProviderConfig)mpProviderConfig).setURL(new URL("file:passwd"));
            ((URLMasterPasswordProviderConfig)mpProviderConfig).setEncrypting(true);
            saveMasterPasswordProviderConfig(mpProviderConfig, false);

            //save out the default master password
            MasterPasswordProvider mpProvider =
                loadMasterPasswordProvider(mpProviderConfig.getName());
            File propFile = new File(getSecurityRoot(), "users.properties");
            Properties userprops=null;
            if (propFile.exists())                 
                userprops = Util.loadPropertyFile(propFile);           
            mpProvider.setMasterPassword(extractMasterPasswordForMigration(userprops));
        }

        MasterPasswordConfig mpConfig = new MasterPasswordConfig();
        mpConfig.setProviderName(mpProviderConfig.getName());
        saveMasterPasswordConfig(mpConfig);

        // check for services.properties, create if necessary
        File serviceFile = new File(getSecurityRoot(), "services.properties");
        if (serviceFile.exists()==false) {
View Full Code Here

 
  @Before
  public void clearSecurityStuff() throws Exception {
    Set<String> mpProviders = getSecurityManager().listMasterPasswordProviders();
    if (mpProviders.contains("default2")) {
      MasterPasswordProviderConfig default2 = getSecurityManager().loadMasterPassswordProviderConfig("default2");
      getSecurityManager().removeMasterPasswordProvder(default2);
    }
  }
View Full Code Here

        add(form);

        form.add(new Label("providerName"));
       
        MasterPasswordConfig config = configModel.getObject();
        MasterPasswordProviderConfig providerConfig = null;
        try {
             providerConfig =
                 getSecurityManager().loadMasterPassswordProviderConfig(config.getProviderName());
        } catch (IOException e) {
            throw new WicketRuntimeException(e);
        }

        //TODO: this will cause the master password to stored as a string in plain text, without the
        // ability to scramble it... not much we can do because wicket works with strings...
        // potentially look into a way to store as char or byte array so string never gets
        // created
        form.add(new PasswordTextField("currentPassword", new Model()));
        form.add(new PasswordTextField("newPassword", new Model())
            .setEnabled(!providerConfig.isReadOnly()));
        form.add(new PasswordTextField("newPasswordConfirm", new Model()));

        form.add(new SubmitLink("save", form) {
            @Override
            public void onSubmit() {
View Full Code Here

TOP

Related Classes of org.geoserver.security.password.MasterPasswordProviderConfig

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.