This commit is contained in:
Martin Lensment 2015-07-24 17:10:24 +03:00
parent c38680a3b1
commit 1d82fb9052
3 changed files with 12 additions and 5 deletions

View file

@ -10,9 +10,7 @@ class EppController < ApplicationController
before_action :validate_against_schema
def validate_against_schema
return if ['hello', 'error', 'keyrelay'].include?(params[:action])
params[:schema] = 'epp-1.0.xsd' unless params[:schema]
xsd = Nokogiri::XML::Schema(File.read("lib/schemas/#{params[:schema]}"))
xsd.validate(params[:nokogiri_frame]).each do |error|
schema.validate(params[:nokogiri_frame]).each do |error|
epp_errors << {
code: 2001,
msg: error
@ -73,6 +71,13 @@ class EppController < ApplicationController
render_epp_response '/epp/error'
end
def schema
# TODO: Support multiple schemas
return DOMAIN_SCHEMA if params[:epp_object_type] == :domain
return CONTACT_SCHEMA if params[:epp_object_type] == :contact
EPP_SCHEMA
end
def generate_svtrid
# rubocop: disable Style/VariableName
@svTRID = "ccReg-#{format('%010d', rand(10**10))}"