java.lang.Object
colesico.framework.security.DefaultSecurityKit
- All Implemented Interfaces:
SecurityInterceptor,SecurityKit
public class DefaultSecurityKit extends java.lang.Object implements SecurityInterceptor
Default security kit implementation.
Extend this class to customize principal control.
- Author:
- Vladlen Larionov
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDefaultSecurityKit.PrincipalHolder -
Field Summary
Fields Modifier and Type Field Description protected javax.inject.Provider<colesico.framework.teleapi.DataPort>dataPortProvprotected colesico.framework.ioc.scope.ThreadScopethreadScopeFields inherited from interface colesico.framework.security.SecurityInterceptor
INTERCEPT_REQUIRE_AUTHORITY_METHOD, INTERCEPT_REQUIRE_PRINCIPAL_METHODFields inherited from interface colesico.framework.security.SecurityKit
REQUIRE_AUTHORITY_METHOD, REQUIRE_PRINCIPAL_METHOD -
Constructor Summary
Constructors Constructor Description DefaultSecurityKit(colesico.framework.ioc.scope.ThreadScope threadScope, javax.inject.Provider<colesico.framework.teleapi.DataPort> dataPortProv) -
Method Summary
Modifier and Type Method Description <P extends Principal>
PgetPrincipal()Returns active valid principal if it present.booleanhasAuthority(java.lang.String... authorityId)Check active principal for at least one valid authority.protected booleanhasAuthorityControl(Principal principal, java.lang.String... authorityId)Override this method to get more specific authority controljava.lang.ObjectinterceptRequireAuthority(colesico.framework.service.InvocationContext context)java.lang.ObjectinterceptRequirePrincipal(colesico.framework.service.InvocationContext context)protected PrincipalprincipalReadControl(colesico.framework.teleapi.DataPort<java.lang.Object,java.lang.Object> port)Override this method to get more specific principal read control This method is used to fine grained control of user principal: check validity, enrich with extra data, e.t.c.protected voidprincipalWriteControl(colesico.framework.teleapi.DataPort<java.lang.Object,java.lang.Object> port, Principal principal)Override this method to get more specific principal write control.voidsetPrincipal(Principal principal)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface colesico.framework.security.SecurityKit
requireAuthority, requirePrincipal
-
Field Details
-
threadScope
protected final colesico.framework.ioc.scope.ThreadScope threadScope -
dataPortProv
protected final javax.inject.Provider<colesico.framework.teleapi.DataPort> dataPortProv
-
-
Constructor Details
-
DefaultSecurityKit
@Inject public DefaultSecurityKit(colesico.framework.ioc.scope.ThreadScope threadScope, javax.inject.Provider<colesico.framework.teleapi.DataPort> dataPortProv)
-
-
Method Details
-
principalReadControl
protected Principal principalReadControl(colesico.framework.teleapi.DataPort<java.lang.Object,java.lang.Object> port)Override this method to get more specific principal read control This method is used to fine grained control of user principal: check validity, enrich with extra data, e.t.c.- Parameters:
port-- Returns:
- Valid principal or null
-
principalWriteControl
protected void principalWriteControl(colesico.framework.teleapi.DataPort<java.lang.Object,java.lang.Object> port, Principal principal)Override this method to get more specific principal write control. This method is used to fine grain write control of user principal.- Parameters:
port-principal-
-
hasAuthorityControl
Override this method to get more specific authority control- Parameters:
principal-authorityId-- Returns:
-
getPrincipal
Description copied from interface:SecurityKitReturns active valid principal if it present.- Specified by:
getPrincipalin interfaceSecurityKit- Returns:
- null if principal is invalid or absent.
-
setPrincipal
- Specified by:
setPrincipalin interfaceSecurityKit
-
hasAuthority
public final boolean hasAuthority(java.lang.String... authorityId)Description copied from interface:SecurityKitCheck active principal for at least one valid authority.- Specified by:
hasAuthorityin interfaceSecurityKit- Returns:
- false if all are invalid
-
interceptRequirePrincipal
public final java.lang.Object interceptRequirePrincipal(colesico.framework.service.InvocationContext context)- Specified by:
interceptRequirePrincipalin interfaceSecurityInterceptor
-
interceptRequireAuthority
public final java.lang.Object interceptRequireAuthority(colesico.framework.service.InvocationContext context)- Specified by:
interceptRequireAuthorityin interfaceSecurityInterceptor
-