Package org.apache.activemq.shiro.authc
Class DefaultAuthenticationPolicy
- java.lang.Object
-
- org.apache.activemq.shiro.authc.DefaultAuthenticationPolicy
-
- All Implemented Interfaces:
AuthenticationPolicy
public class DefaultAuthenticationPolicy extends Object implements AuthenticationPolicy
- Since:
- 5.10.0
-
-
Constructor Summary
Constructors Constructor Description DefaultAuthenticationPolicy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apache.shiro.subject.PrincipalCollection
createAssumedIdentity(ConnectionReference conn)
Returns a ShiroPrincipalCollection
representing the identity to assume (without true authentication) for the specified Connection.protected boolean
credentialsAvailable(ConnectionReference conn)
Returnstrue
if the client connection has supplied credentials to authenticate itself,false
otherwise.void
customizeSubject(org.apache.shiro.subject.Subject.Builder subjectBuilder, ConnectionReference conn)
Allows customization of theSubject
being built for the specified client connection.String
getAnonymousAccountRealmName()
String
getAnonymousAccountUsername()
String
getSystemAccountRealmName()
String
getSystemAccountUsername()
boolean
isAnonymousAccessAllowed()
protected boolean
isAnonymousAccount(org.apache.shiro.subject.Subject subject)
protected boolean
isAssumeIdentity(ConnectionReference conn)
Returnstrue
if an unauthenticated connection should still assume a specific identity,false
otherwise.boolean
isAuthenticationRequired(SubjectConnectionReference conn)
Returnstrue
if the connection'sSubject
instance should be authenticated,false
otherwise.protected boolean
isSystemAccount(org.apache.shiro.subject.Subject subject)
protected boolean
isSystemConnection(ConnectionReference conn)
boolean
isVmConnectionAuthenticationRequired()
protected boolean
matches(org.apache.shiro.subject.PrincipalCollection principals, String username, String realmName)
void
setAnonymousAccessAllowed(boolean anonymousAccessAllowed)
void
setAnonymousAccountRealmName(String anonymousAccountRealmName)
void
setAnonymousAccountUsername(String anonymousAccountUsername)
void
setSystemAccountRealmName(String systemAccountRealmName)
void
setSystemAccountUsername(String systemAccountUsername)
void
setVmConnectionAuthenticationRequired(boolean vmConnectionAuthenticationRequired)
-
-
-
Method Detail
-
isVmConnectionAuthenticationRequired
public boolean isVmConnectionAuthenticationRequired()
-
setVmConnectionAuthenticationRequired
public void setVmConnectionAuthenticationRequired(boolean vmConnectionAuthenticationRequired)
-
getSystemAccountUsername
public String getSystemAccountUsername()
-
setSystemAccountUsername
public void setSystemAccountUsername(String systemAccountUsername)
-
getSystemAccountRealmName
public String getSystemAccountRealmName()
-
setSystemAccountRealmName
public void setSystemAccountRealmName(String systemAccountRealmName)
-
isAnonymousAccessAllowed
public boolean isAnonymousAccessAllowed()
-
setAnonymousAccessAllowed
public void setAnonymousAccessAllowed(boolean anonymousAccessAllowed)
-
getAnonymousAccountUsername
public String getAnonymousAccountUsername()
-
setAnonymousAccountUsername
public void setAnonymousAccountUsername(String anonymousAccountUsername)
-
getAnonymousAccountRealmName
public String getAnonymousAccountRealmName()
-
setAnonymousAccountRealmName
public void setAnonymousAccountRealmName(String anonymousAccountRealmName)
-
credentialsAvailable
protected boolean credentialsAvailable(ConnectionReference conn)
Returnstrue
if the client connection has supplied credentials to authenticate itself,false
otherwise.- Parameters:
conn
- the client's connection context- Returns:
true
if the client connection has supplied credentials to authenticate itself,false
otherwise.
-
isAuthenticationRequired
public boolean isAuthenticationRequired(SubjectConnectionReference conn)
Description copied from interface:AuthenticationPolicy
Returnstrue
if the connection'sSubject
instance should be authenticated,false
otherwise.- Specified by:
isAuthenticationRequired
in interfaceAuthenticationPolicy
- Parameters:
conn
- the subject's connection- Returns:
true
if the connection'sSubject
instance should be authenticated,false
otherwise.
-
isAnonymousAccount
protected boolean isAnonymousAccount(org.apache.shiro.subject.Subject subject)
-
isSystemAccount
protected boolean isSystemAccount(org.apache.shiro.subject.Subject subject)
-
matches
protected boolean matches(org.apache.shiro.subject.PrincipalCollection principals, String username, String realmName)
-
isSystemConnection
protected boolean isSystemConnection(ConnectionReference conn)
-
customizeSubject
public void customizeSubject(org.apache.shiro.subject.Subject.Builder subjectBuilder, ConnectionReference conn)
Description copied from interface:AuthenticationPolicy
Allows customization of theSubject
being built for the specified client connection. This allows for any pre-existing connection-specific identity or state to be applied to theSubject.Builder
before theSubject
instance is actually created. NOTE: This method is called by theSubjectFilter
before the filter chain is executed (and before an authentication attempt occurs). Implementations MUST NOT attempt to actuallybuild
the subject or perform an authentication attempt in this method.- Specified by:
customizeSubject
in interfaceAuthenticationPolicy
- Parameters:
subjectBuilder
- the builder for the Subject that will be created representing the associated client connectionconn
- a reference to the client's connection metadata- See Also:
SubjectFilter
-
isAssumeIdentity
protected boolean isAssumeIdentity(ConnectionReference conn)
Returnstrue
if an unauthenticated connection should still assume a specific identity,false
otherwise. This method will only be called if there are no connectioncredentialsAvailable
. If a client supplies connection credentials, they will always be used to authenticate the client with that identity. Iftrue
is returned, the assumed identity will be returned bycreateAssumedIdentity
.Warning
This method exists primarily to support the system and anonymous accounts - it is probably unsafe to returntrue
in most other scenarios.- Parameters:
conn
- a reference to the client's connection- Returns:
true
if an unauthenticated connection should still assume a specific identity,false
otherwise.
-
createAssumedIdentity
protected org.apache.shiro.subject.PrincipalCollection createAssumedIdentity(ConnectionReference conn)
Returns a ShiroPrincipalCollection
representing the identity to assume (without true authentication) for the specified Connection. This method is only called ifisAssumeIdentity(ConnectionReference)
istrue
.- Parameters:
conn
- a reference to the client's connection- Returns:
- a Shiro
PrincipalCollection
representing the identity to assume (without true authentication) for the specified Connection.
-
-