private Repository createRepository( final String role, final String hint ) throws InvalidConfigurationException { try { return Repository.class.cast( plexusContainer.lookup( role, hint ) ); } catch ( ComponentLookupException e ) { throw new InvalidConfigurationException( "Could not lookup a new instance of Repository!", e ); } } }
protected void checkValidationResponse( ValidationResponse response ) throws ConfigurationException { if ( response != null && !response.isValid() ) { throw new InvalidConfigurationException( response ); } }
protected LocalRepositoryStorage getLocalRepositoryStorage( String repoId, String provider ) throws InvalidConfigurationException { try { return getPlexusContainer().lookup( LocalRepositoryStorage.class, provider ); } catch ( ComponentLookupException e ) { throw new InvalidConfigurationException( "Repository " + repoId + " have local storage with unsupported provider: " + provider, e ); } }
protected RemoteRepositoryStorage getRemoteRepositoryStorage( final String repoId, final String remoteUrl, final String provider ) throws InvalidConfigurationException { try { final String mungledHint = remoteProviderHintFactory.getRoleHint( remoteUrl, provider ); return getPlexusContainer().lookup( RemoteRepositoryStorage.class, mungledHint ); } catch ( ComponentLookupException e ) { throw new InvalidConfigurationException( "Repository " + repoId + " have remote storage with unsupported provider: " + provider, e ); } catch ( IllegalArgumentException e ) { throw new InvalidConfigurationException( "Repository " + repoId + " have remote storage with unsupported provider: " + provider, e ); } } }
public void validateTime(String key, Date date) throws InvalidConfigurationException { if (date.before(new Date())) { ValidationResponse vr = new ApplicationValidationResponse(); ValidationMessage vm = new ValidationMessage(key, "Time cannot be in the past."); vr.addValidationError(vm); throw new InvalidConfigurationException(vr); } }
protected void validate( CPathMappingItem pathItem ) throws InvalidConfigurationException { ValidationResponse response = this.validator.validateGroupsSettingPathMappingItem( null, pathItem ); if ( !response.isValid() ) { throw new InvalidConfigurationException( response ); } }
public void validateTime( String key, Date date ) throws InvalidConfigurationException { if ( date.before( new Date() ) ) { ValidationResponse vr = new ApplicationValidationResponse(); ValidationMessage vm = new ValidationMessage( key, "Time cannot be in the past." ); vr.addValidationError( vm ); throw new InvalidConfigurationException( vr ); } }
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 void checkUsersStatus(String status) throws InvalidConfigurationException { boolean found = false; for (UserStatus userStatus : UserStatus.values()) { if (userStatus.name().equals(status)) { found = true; } } if (!found) { ValidationResponse response = new ValidationResponse(); response.addValidationError(new ValidationMessage("status", "Users status is not valid.")); throw new InvalidConfigurationException(response); } }
protected void checkUsersStatus( String status ) throws InvalidConfigurationException { boolean found = false; for ( UserStatus userStatus : UserStatus.values() ) { if ( userStatus.name().equals( status ) ) { found = true; } } if ( !found ) { ValidationResponse response = new ValidationResponse(); response.addValidationError( new ValidationMessage( "status", "Users status is not valid." ) ); throw new InvalidConfigurationException( response ); } }
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 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 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 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 ); } }
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 ); } }