protected void checkValidationResponse( ValidationResponse response ) throws ConfigurationException { if ( response != null && !response.isValid() ) { throw new InvalidConfigurationException( response ); } }
protected void validate( CPathMappingItem pathItem ) throws InvalidConfigurationException { ValidationResponse response = this.validator.validateGroupsSettingPathMappingItem( null, pathItem ); if ( !response.isValid() ) { throw new InvalidConfigurationException( response ); } }
protected void validate( CRepositoryTarget target ) throws InvalidConfigurationException { ValidationResponse response = validator.validateRepositoryTarget( null, target ); if ( !response.isValid() ) { throw new InvalidConfigurationException( response ); } }
public void updateConfiguration( Configuration newConfig ) throws ConfigurationException { try { lock.lock(); newConfig.setVersion( Configuration.MODEL_VERSION ); ValidationResponse validationResponse = this.validateConfig( newConfig ); if ( !validationResponse.isValid() ) { throw new InvalidConfigurationException( validationResponse ); } this.configuration = newConfig; this.save(); } finally { lock.unlock(); } }
protected void validateRepository( CRepository settings, boolean create ) throws ConfigurationException { ApplicationValidationContext ctx = getRepositoryValidationContext(); if ( !create && !StringUtils.isEmpty( settings.getId() ) ) { // remove "itself" from the list to avoid hitting "duplicate repo" problem ctx.getExistingRepositoryIds().remove( settings.getId() ); } ValidationResponse vr = configurationValidator.validateRepository( ctx, settings ); if ( !vr.isValid() ) { throw new InvalidConfigurationException( vr ); } }
protected Configuration load() throws IOException { if (!configurationFile.exists()) { return new Configuration(); } final Configuration result = ModelloUtils.load(Configuration.MODEL_VERSION, this.configurationFile, kenaiRealmModelReader, new ModelloModelUpgrader("1.0.0", Configuration.MODEL_VERSION) { @Override public void doUpgrade(final Reader reader, final Writer writer) throws IOException, XmlPullParserException { // no model structure change, merely the version final Configuration conf = new KenaiRealmConfigurationXpp3Reader().read(reader); conf.setVersion(Configuration.MODEL_VERSION); new KenaiRealmConfigurationXpp3Writer().write(writer, conf); } }); final ValidationResponse vr = validateConfig(result); if (vr.isValid()) { return result; } else { log.warn("Invalid Kenai Realm configuration, not using it ", new InvalidConfigurationException(vr)); return new Configuration(); } }
public synchronized void saveConfiguration() throws IOException { if ( applyConfiguration() ) { // TODO: when NEXUS-2215 is fixed, this should be remove/moved/cleaned // START <<< // validate before we do anything ValidationRequest request = new ValidationRequest( configurationSource.getConfiguration() ); ValidationResponse response = configurationValidator.validateModel( request ); if ( !response.isValid() ) { this.getLogger().error( "Saving nexus configuration caused unexpected error:\n" + response.toString() ); throw new IOException( "Saving nexus configuration caused unexpected error:\n" + response.toString() ); } // END <<< configurationSource.storeConfiguration(); // we successfully saved config eventBus.post( new ConfigurationSaveEvent( this ) ); } }
public void setRealms( List<String> realms ) throws InvalidConfigurationException { ValidationResponse vr = validator.validateRealms( this.initializeContext(), realms ); if ( vr.isValid() ) { this.getConfiguration().setRealms( realms ); } else { throw new InvalidConfigurationException( vr ); } }
public void setAnonymousPassword( String anonymousPassword ) throws InvalidConfigurationException { ValidationResponse vr = validator.validateAnonymousPassword( this.initializeContext(), anonymousPassword ); if ( vr.isValid() ) { this.getConfiguration().setAnonymousPassword( anonymousPassword ); } else { throw new InvalidConfigurationException( vr ); } }
public void setAnonymousUsername( String anonymousUsername ) throws InvalidConfigurationException { ValidationResponse vr = validator.validateAnonymousUsername( this.initializeContext(), anonymousUsername ); if ( vr.isValid() ) { this.getConfiguration().setAnonymousUsername( anonymousUsername ); } else { throw new InvalidConfigurationException( vr ); } }
public void createPrivilege( CPrivilege privilege, SecurityValidationContext context ) throws InvalidConfigurationException { if ( context == null ) { context = initializeContext(); } ValidationResponse vr = validator.validatePrivilege( context, privilege, false ); if ( vr.isValid() ) { getConfiguration().addPrivilege( privilege ); logValidationWarnings( vr ); } else { throw new InvalidConfigurationException( vr ); } }
public void createRole( CRole role, SecurityValidationContext context ) throws InvalidConfigurationException { if ( context == null ) { context = initializeContext(); } ValidationResponse vr = validator.validateRole( context, role, false ); if ( vr.isValid() ) { getConfiguration().addRole( role ); logValidationWarnings( vr ); } else { throw new InvalidConfigurationException( vr ); } }
public void createUser( CUser user, String password, Set<String> roles, SecurityValidationContext context ) throws InvalidConfigurationException { if ( context == null ) { context = initializeContext(); } // set the password if its not null if ( password != null && password.trim().length() > 0 ) { user.setPassword(this.passwordService.encryptPassword(password)); } ValidationResponse vr = validator.validateUser( context, user, roles, false ); if ( vr.isValid() ) { getConfiguration().addUser( user ); createOrUpdateUserRoleMapping( buildUserRoleMapping( user.getId(), roles ) ); logValidationWarnings( vr ); } else { throw new InvalidConfigurationException( vr ); } }
public void updatePrivilege( CPrivilege privilege, SecurityValidationContext context ) throws InvalidConfigurationException, NoSuchPrivilegeException { if ( context == null ) { context = initializeContext(); } ValidationResponse vr = validator.validatePrivilege( context, privilege, true ); if ( vr.isValid() ) { deletePrivilege( privilege.getId(), false ); getConfiguration().addPrivilege( privilege ); logValidationWarnings( vr ); } else { throw new InvalidConfigurationException( vr ); } }
public void updateRole( CRole role, SecurityValidationContext context ) throws InvalidConfigurationException, NoSuchRoleException { if ( context == null ) { context = initializeContext(); } ValidationResponse vr = validator.validateRole( context, role, true ); if ( vr.isValid() ) { deleteRole( role.getId(), false ); getConfiguration().addRole( role ); logValidationWarnings( vr ); } else { throw new InvalidConfigurationException( vr ); } }
/** * A method to append a validation response to this validation response. The errors list and warnings list are * simply appended, and the isValid is logically AND-ed and isModified is logically OR-ed. * * @param validationResponse */ public void append( ValidationResponse validationResponse ) { for ( ValidationMessage msg : validationResponse.getValidationErrors() ) { if ( getValidationError( msg.getKey() ) != null ) { msg.setKey( msg.getKey() + "(" + key++ + ")" ); } addValidationError( msg ); } for ( ValidationMessage msg : validationResponse.getValidationWarnings() ) { if ( getValidationWarning( msg.getKey() ) != null ) { msg.setKey( msg.getKey() + "(" + key++ + ")" ); } addValidationWarning( msg ); } setValid( isValid() && validationResponse.isValid() ); setModified( isModified() || validationResponse.isModified() ); }
public void updateUser( CUser user, Set<String> roles, SecurityValidationContext context ) throws InvalidConfigurationException, UserNotFoundException { if ( context == null ) { context = initializeContext(); } ValidationResponse vr = validator.validateUser( context, user, roles, true ); if ( vr.isValid() ) { deleteUser( user.getId() ); getConfiguration().addUser( user ); this.createOrUpdateUserRoleMapping( this.buildUserRoleMapping( user.getId(), roles ) ); logValidationWarnings( vr ); } else { throw new InvalidConfigurationException( vr ); } }
if ( vResponse.isValid() )