1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.security; |
8 | |
|
9 | |
import org.mule.api.MuleEvent; |
10 | |
import org.mule.api.endpoint.InboundEndpoint; |
11 | |
import org.mule.api.lifecycle.InitialisationException; |
12 | |
import org.mule.api.security.AuthenticationFilter; |
13 | |
import org.mule.api.security.CredentialsAccessor; |
14 | |
import org.mule.api.security.CryptoFailureException; |
15 | |
import org.mule.api.security.EncryptionStrategyNotFoundException; |
16 | |
import org.mule.api.security.SecurityException; |
17 | |
import org.mule.api.security.SecurityProviderNotFoundException; |
18 | |
import org.mule.api.security.UnknownAuthenticationTypeException; |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | 0 | public abstract class AbstractAuthenticationFilter extends AbstractSecurityFilter implements AuthenticationFilter |
25 | |
{ |
26 | |
private boolean authenticate; |
27 | |
private CredentialsAccessor credentialsAccessor; |
28 | |
|
29 | |
public CredentialsAccessor getCredentialsAccessor() |
30 | |
{ |
31 | 0 | return credentialsAccessor; |
32 | |
} |
33 | |
|
34 | |
public void setCredentialsAccessor(CredentialsAccessor credentialsAccessor) |
35 | |
{ |
36 | 0 | this.credentialsAccessor = credentialsAccessor; |
37 | 0 | } |
38 | |
public boolean isAuthenticate() |
39 | |
{ |
40 | 0 | return authenticate; |
41 | |
} |
42 | |
|
43 | |
public void setAuthenticate(boolean authenticate) |
44 | |
{ |
45 | 0 | this.authenticate = authenticate; |
46 | 0 | } |
47 | |
|
48 | |
@Override |
49 | |
public void doFilter(MuleEvent event) |
50 | |
throws SecurityException, UnknownAuthenticationTypeException, CryptoFailureException, |
51 | |
SecurityProviderNotFoundException, EncryptionStrategyNotFoundException, InitialisationException |
52 | |
{ |
53 | 0 | authenticate(event); |
54 | 0 | } |
55 | |
|
56 | |
public void authenticate(MuleEvent event) |
57 | |
throws SecurityException, UnknownAuthenticationTypeException, CryptoFailureException, |
58 | |
SecurityProviderNotFoundException, EncryptionStrategyNotFoundException, |
59 | |
InitialisationException |
60 | |
{ |
61 | 0 | if (event.getEndpoint() instanceof InboundEndpoint) |
62 | |
{ |
63 | 0 | authenticateInbound(event); |
64 | |
} |
65 | |
else |
66 | |
{ |
67 | 0 | authenticateOutbound(event); |
68 | |
} |
69 | 0 | } |
70 | |
|
71 | |
protected abstract void authenticateInbound(MuleEvent event) |
72 | |
throws SecurityException, CryptoFailureException, SecurityProviderNotFoundException, |
73 | |
EncryptionStrategyNotFoundException, UnknownAuthenticationTypeException; |
74 | |
|
75 | |
protected abstract void authenticateOutbound(MuleEvent event) |
76 | |
throws SecurityException, SecurityProviderNotFoundException, CryptoFailureException; |
77 | |
|
78 | |
} |