FreeRDP
CertificateDialog.m
1 
21 #import "CertificateDialog.h"
22 #import <freerdp/client/cmdline.h>
23 
24 #import <CoreGraphics/CoreGraphics.h>
25 
26 @interface CertificateDialog ()
27 
28 @property int result;
29 
30 @end
31 
32 @implementation CertificateDialog
33 
34 @synthesize textCommonName;
35 @synthesize textFingerprint;
36 @synthesize textIssuer;
37 @synthesize textSubject;
38 @synthesize textMismatch;
39 @synthesize messageLabel;
40 @synthesize serverHostname;
41 @synthesize commonName;
42 @synthesize fingerprint;
43 @synthesize issuer;
44 @synthesize subject;
45 @synthesize hostMismatch;
46 @synthesize changed;
47 @synthesize result;
48 
49 - (id)init
50 {
51  return [self initWithWindowNibName:@"CertificateDialog"];
52 }
53 
54 - (void)windowDidLoad
55 {
56  [super windowDidLoad];
57  // Implement this method to handle any initialization after your window controller's window has
58  // been loaded from its nib file.
59  [self.window setTitle:self.serverHostname];
60  if (self.changed)
61  [self.messageLabel setStringValue:[NSString stringWithFormat:@"Changed certificate for %@",
62  self.serverHostname]];
63  else
64  [self.messageLabel setStringValue:[NSString stringWithFormat:@"New Certificate for %@",
65  self.serverHostname]];
66 
67  if (!self.hostMismatch)
68  [self.textMismatch
69  setStringValue:[NSString stringWithFormat:
70  @"NOTE: The server name matches the certificate, good."]];
71  else
72  [self.textMismatch
73  setStringValue:[NSString
74  stringWithFormat:
75  @"ATTENTION: The common name does not match the server name!"]];
76  [self.textCommonName setStringValue:self.commonName];
77  [self.textFingerprint setStringValue:self.fingerprint];
78  [self.textIssuer setStringValue:self.issuer];
79  [self.textSubject setStringValue:self.subject];
80 }
81 
82 - (IBAction)onAccept:(NSObject *)sender
83 {
84  [NSApp stopModalWithCode:1];
85 }
86 
87 - (IBAction)onTemporary:(NSObject *)sender
88 {
89  [NSApp stopModalWithCode:2];
90 }
91 
92 - (IBAction)onCancel:(NSObject *)sender
93 {
94  [NSApp stopModalWithCode:0];
95 }
96 
97 - (int)runModal:(NSWindow *)mainWindow
98 {
99  if ([mainWindow respondsToSelector:@selector(beginSheet:completionHandler:)])
100  {
101  [mainWindow beginSheet:self.window completionHandler:nil];
102  self.result = [NSApp runModalForWindow:self.window];
103  [mainWindow endSheet:self.window];
104  }
105  else
106  {
107  [NSApp beginSheet:self.window
108  modalForWindow:mainWindow
109  modalDelegate:nil
110  didEndSelector:nil
111  contextInfo:nil];
112  self.result = [NSApp runModalForWindow:self.window];
113  [NSApp endSheet:self.window];
114  }
115 
116  [self.window orderOut:nil];
117  return self.result;
118 }
119 
120 - (void)dealloc
121 {
122  [textCommonName release];
123  [textFingerprint release];
124  [textIssuer release];
125  [textSubject release];
126  [messageLabel release];
127  [serverHostname release];
128  [commonName release];
129  [fingerprint release];
130  [issuer release];
131  [subject release];
132  [super dealloc];
133 }
134 
135 @end