Class: Certify::CertificatesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/certify/certificates_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /certificates POST /certificates.json



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/certify/certificates_controller.rb', line 32

def create
  # get the ca
  @authority = Authority.find(params[:certify_authority_id])

  # create the cert
  @certificate = @authority.certificates.build()

  # apply the csr
  @certificate.csr=params[:csr]

  # format
  respond_to do |format|
    if @certificate.save
      format.html { redirect_to authority_path(@authority), notice: 'Certificate was successfully created.' }
      format.json { render json: @certificate, status: :created, location: @certificate }
    else
      format.html { render action: "new" }
      format.json { render json: @certificate.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /certificates/1 DELETE /certificates/1.json



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/controllers/certify/certificates_controller.rb', line 56

def destroy
  # get the ca
  @authority = Authority.find(params[:certify_authority_id])

  # get the certificate
  @certificate = Certificate.find(params[:id])
  @certificate.destroy
  
  respond_to do |format|
    format.html { redirect_to authority_path(@authority), notice: 'Certificate removed' }
    format.json { head :no_content }
  end
end

#newObject

GET /certificates/new GET /certificates/new.json



17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/certify/certificates_controller.rb', line 17

def new
  # get the authority
  @authority = Authority.find(params[:certify_authority_id])

  # generate a new one
  @certificate = Certificate.new()

  respond_to do |format|
    format.html # new.html.erb
    format.json { render json: @certificate }
  end
end

#showObject

GET /certificates/1 GET /certificates/1.json



6
7
8
9
10
11
12
13
# File 'app/controllers/certify/certificates_controller.rb', line 6

def show
  @certificate = Certificate.find(params[:id])
  
  respond_to do |format|
    format.html # show.html.erb
    format.json { render json: @certificate }
  end
end