Class: IISConfig::FtpSite

Inherits:
IISObject show all
Defined in:
lib/iisconfig/ftp_site.rb

Instance Method Summary collapse

Methods inherited from IISObject

#exist?

Constructor Details

#initializeFtpSite

Returns a new instance of FtpSite.



8
9
10
11
12
# File 'lib/iisconfig/ftp_site.rb', line 8

def initialize
  @bindings = []
  @authentication = []
  @allow_authorization = []
end

Instance Method Details

#addObject



47
48
49
50
51
52
53
54
55
56
# File 'lib/iisconfig/ftp_site.rb', line 47

def add
  args = []
  args << 'ADD'
  args << 'SITE'
  args << "/name:#{@name}"
  args << "/bindings:\"#{@bindings.join('","')}\""
  args << "/physicalPath:#{@physical_path.gsub(/\//, '\\')}"

  args
end

#allow_authorization(permissions, access) ⇒ Object



35
36
37
# File 'lib/iisconfig/ftp_site.rb', line 35

def allow_authorization(permissions, access)
  @allow_authorization << { :permissions => permissions, :access => access }
end

#allow_sslObject



39
40
41
# File 'lib/iisconfig/ftp_site.rb', line 39

def allow_ssl
  @ssl = :allow
end

#app_pool(pool) ⇒ Object



23
24
25
# File 'lib/iisconfig/ftp_site.rb', line 23

def app_pool(pool)
  @app_pool = pool
end

#binding(binding) ⇒ Object



19
20
21
# File 'lib/iisconfig/ftp_site.rb', line 19

def binding(binding)
  @bindings << binding
end

#build_commandsObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/iisconfig/ftp_site.rb', line 64

def build_commands()
  commands = []
  commands << delete if exist? :site, @name
  commands << add

  commands << %W{SET SITE /site.name:#{@name} /[path='/'].applicationPool:#{@app_pool}} unless @app_pool.nil?

  @allow_authorization.each do |a|
    permissions = a[:permissions].map { |p| p.capitalize }.join(',')
    roles = a[:access][:roles]
    users = a[:access][:users]
    commands << %W{SET CONFIG #{@name} /section:system.ftpserver/security/authorization /+[accessType='Allow',permissions='#{permissions}',roles='#{roles}',users='#{users}'] /commit:apphost}
  end

  @authentication.each do |a|
    commands << %W{SET CONFIG -section:system.applicationHost/sites /[name='#{@name}'].ftpServer.security.authentication.#{a}Authentication.enabled:true}
  end

  unless @ssl.nil?
    commands << %W{SET CONFIG -section:system.applicationHost/sites /[name='#{@name}'].ftpServer.security.ssl.controlChannelPolicy:"Ssl#{@ssl.capitalize}"}
    commands << %W{SET CONFIG -section:system.applicationHost/sites /[name='#{@name}'].ftpServer.security.ssl.dataChannelPolicy:"Ssl#{@ssl.capitalize}"}
  end

  commands
end

#deleteObject



43
44
45
# File 'lib/iisconfig/ftp_site.rb', line 43

def delete
  %W{DELETE SITE #{@name}}
end

#enable_authentication(*authentication) ⇒ Object



31
32
33
# File 'lib/iisconfig/ftp_site.rb', line 31

def enable_authentication(*authentication)
  @authentication += authentication
end

#name(name = nil) ⇒ Object



14
15
16
17
# File 'lib/iisconfig/ftp_site.rb', line 14

def name(name = nil)
  @name = name unless name.nil?
  @name
end

#physical_path(path) ⇒ Object



27
28
29
# File 'lib/iisconfig/ftp_site.rb', line 27

def physical_path(path)
  @physical_path = path
end

#required_pathsObject



58
59
60
61
62
# File 'lib/iisconfig/ftp_site.rb', line 58

def required_paths
  paths = []
  paths << @physical_path
  paths
end