-
Notifications
You must be signed in to change notification settings - Fork 182
/
PlainAuthenticationState.java
63 lines (54 loc) · 2 KB
/
PlainAuthenticationState.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.icegreen.greenmail.smtp.auth;
import com.icegreen.greenmail.smtp.commands.AuthCommand.AuthMechanism;
import com.icegreen.greenmail.util.SaslMessage;
/**
* Details from the {@link AuthMechanism#PLAIN} authorization mechanism, when
* that mechanism was used for authentication.
*/
public class PlainAuthenticationState implements AuthenticationState, UsernameAuthentication {
private final String authorizationId;
private final String authenticationId;
private final String password;
/**
* @param saslMessage The parsed message sent by the client with the {@code AUTH} command.
*/
public PlainAuthenticationState(SaslMessage saslMessage) {
this(saslMessage.getAuthzid(), saslMessage.getAuthcid(), saslMessage.getPasswd());
}
@Override
public String getType() {
return AuthMechanism.PLAIN.name();
}
/**
* @param authorizationId The authorization ID sent by the client with the {@code AUTH} command.
* @param authenticationId The authentication ID sent by the client with the {@code AUTH} command.
* @param password The password sent by the client with the {@code AUTH} command.
*/
public PlainAuthenticationState(String authorizationId, String authenticationId, String password) {
this.authorizationId = authorizationId;
this.authenticationId = authenticationId;
this.password = password;
}
/**
* @return The authorization ID sent by the client with the {@code AUTH} command.
*/
public String getAuthorizationId() {
return authorizationId;
}
/**
* @return The authentication ID sent by the client with the {@code AUTH} command.
*/
public String getAuthenticationId() {
return authenticationId;
}
/**
* @return password The password sent by the client with the {@code AUTH} command.
*/
public String getPassword() {
return password;
}
@Override
public String getUsername() {
return authenticationId;
}
}