MCCredentialsRequest.st
changeset 1050 202d91849493
equal deleted inserted replaced
1048:582b3a028cbc 1050:202d91849493
       
     1 "{ Package: 'stx:goodies/monticello' }"
       
     2 
       
     3 "{ NameSpace: Smalltalk }"
       
     4 
       
     5 Notification subclass:#MCCredentialsRequest
       
     6 	instanceVariableNames:'username password url'
       
     7 	classVariableNames:''
       
     8 	poolDictionaries:''
       
     9 	category:'SCM-Monticello-RemoteRepositories'
       
    10 !
       
    11 
       
    12 MCCredentialsRequest comment:'I am used to prompt in a UI indepentent way for a username and a password.
       
    13 If the user successfully entered the two strings I return an MCServerCredential if not I return nil.'
       
    14 !
       
    15 
       
    16 
       
    17 !MCCredentialsRequest class methodsFor:'signalling'!
       
    18 
       
    19 signalUrl: aUrl
       
    20 	^ self new 
       
    21 		url: aUrl;
       
    22 		signal
       
    23 !
       
    24 
       
    25 signalUrl: aUrl username: username password: password
       
    26 	^ self new 
       
    27 		url: aUrl;
       
    28 		username: username;
       
    29 		password: password;
       
    30 		signal
       
    31 ! !
       
    32 
       
    33 !MCCredentialsRequest methodsFor:'accessing'!
       
    34 
       
    35 password
       
    36 	^ password
       
    37 !
       
    38 
       
    39 password: anObject
       
    40 	password := anObject
       
    41 !
       
    42 
       
    43 passwordMessagePrompt
       
    44 	^ 'Please enter a password for ', self url asString
       
    45 !
       
    46 
       
    47 url
       
    48 	^ url
       
    49 !
       
    50 
       
    51 url: anObject
       
    52 	url := anObject
       
    53 !
       
    54 
       
    55 userMessagePrompt
       
    56 	^ 'Please enter a username for ', self url asString
       
    57 !
       
    58 
       
    59 username
       
    60 	^ username
       
    61 !
       
    62 
       
    63 username: anObject
       
    64 	username := anObject
       
    65 ! !
       
    66 
       
    67 !MCCredentialsRequest methodsFor:'exceptiondescription'!
       
    68 
       
    69 defaultAction
       
    70 	
       
    71 	username := UIManager default
       
    72 			request: self userMessagePrompt
       
    73 			initialAnswer: self username
       
    74 			title: 'User' translated.
       
    75 	(username isNil or: [ username isEmpty ])
       
    76 		ifTrue: [ ^ nil ].
       
    77 	password := UIManager default
       
    78 			requestPassword: self passwordMessagePrompt.
       
    79 	^ MCServerCredentials user: username password: password
       
    80 ! !
       
    81 
       
    82 !MCCredentialsRequest class methodsFor:'documentation'!
       
    83 
       
    84 version
       
    85     ^ '$Header$'
       
    86 !
       
    87 
       
    88 version_CVS
       
    89     ^ '$Header$'
       
    90 ! !
       
    91