public final class SecurityManager extends Scope implements SecurityConstants
Details on client authentication protocol:
Once the TLS connection is established and certificates are exchanged and
verified:
String
userID followed by char[] password. UserID is serialized using
writeUTF() method. Password is serialized using
writeShort() encoding the array length, plus
writeChar for every character in the array.
A unique session ID is assigned to each security context upon creation. Whenever a thread is assigned to a context, it is mapped to a new ID. While the thread IDs (which are integers) could theoretically wrap, such that a thread associated with a very long running context could be assigned an ID already in use, the combination of session ID and thread ID is guaranteed always to be unique, and it is really only this combination which is meaningful for practical use.
| Modifier and Type | Class and Description |
|---|---|
class |
SecurityManager.CertificateSecurityManager
Wrapper class for certificate / encryption related logic.
|
class |
SecurityManager.ContextSecurityManager
Wrapper class for Context related logic.
|
static interface |
SecurityManager.EncryptedKeyStoreFunction
An interface to expose the
SecurityManager.CertificateSecurityManager.getEncryptedKeyStoreWorker(java.lang.String, java.lang.String, java.lang.String, com.goldencode.p2j.main.ServerKeyStore.Store) to threads
which have proper server context. |
private class |
SecurityManager.HookClassLoader
This class extends
ClassLoader to enable the loading of
a class file stored as a byte array in memory. |
private class |
SecurityManager.PasswordChange
Implements password change that requires the privilege of running within
the initial security context.
|
private class |
SecurityManager.SecurityCacheRefresh
Implements concurrent security cache refresh function.
|
class |
SecurityManager.SessionSecurityManager
Wrapper class for session related logic.
|
class |
SecurityManager.SsoSecurityManager
Wrapper class for SSO related logic.
|
class |
SecurityManager.VirtualConnectionSecurityManager
Wrapper class for virtual connection related logic.
|
| Modifier and Type | Field and Description |
|---|---|
AccountExtUtil |
accountExt
Container for the account ext logic.
|
private static int |
ALWAYS_RETRY
Constant used when no retries are allowed in authentication process.
|
private SecurityCache |
cache
Caches context data.
|
private int |
cacheSerial
Last used serial number for security cache creation.
|
SecurityManager.CertificateSecurityManager |
certificateSm
Wrapper for certificate related logic.
|
private BootstrapConfig |
cfg
The bootstrap configuration.
|
private java.util.Map<java.lang.Object,java.lang.Boolean> |
cleanupLocks
Map containing flags which inform other threads that cleanup for a
certain context is in progress, so they should skip it.
|
SecurityManager.ContextSecurityManager |
contextSm
Wrapper for context related logic.
|
private boolean |
init
Flag to detect if we are initialized or not.
|
private java.util.Map<java.lang.String,java.util.concurrent.atomic.AtomicInteger> |
interactiveSessions
Tracks the total number of interactive sessions currently active by user account name.
|
private int |
interactiveUsers
Records the current number of user accounts which have at least one active interactive session.
|
LegacyWebSecurityManager |
legacyWebSm
Container for the legacy web security logic.
|
private static CentralLogger |
LOG
Logger.
|
private int |
nextThreadID
Next available, unique thread ID.
|
(package private) java.lang.Object |
pwchSync
Object for serializing password change requests.
|
private static java.lang.ThreadGroup |
secThreads
Thread group for all security threads.
|
private static SecurityManager |
securityManager
Reference to the singleton instance.
|
(package private) SecurityManagerAuthenticator |
serverAuthenticator
Authenticator instance.
|
SecurityManager.SessionSecurityManager |
sessionSm
Wrapper for session related logic.
|
SecurityManager.SsoSecurityManager |
ssoSm
Wrapper for SSO related logic.
|
private static java.lang.ThreadLocal<java.lang.Integer> |
THREAD_ID
The thread ID, to uniquely identify the Java Thread.
|
private TransportSecurity |
tranSec
Provides network socket security services.
|
private boolean |
useGCM
Use Galois/counter mode ciphers
Disabling this mode will allow only "confidentiality only" modes
(no AEAD) which can be more efficient
|
private java.lang.Object |
userLimitLock
Manages access to user limit state.
|
SecurityManager.VirtualConnectionSecurityManager |
virtualSm
Wrapper for virtual connection related logic.
|
AUTH_ACTION_ABORT, AUTH_ACTION_CONTINUE, AUTH_ACTION_DONE, AUTH_ACTION_RETRY, AUTH_MODE_CUSTOM, AUTH_MODE_HIGHEST, AUTH_MODE_IDPW, AUTH_MODE_LOWEST, AUTH_MODE_NONE, AUTH_MODE_X509, AUTH_MODE_X509_IDPW, AUTH_REQ_PROCESS, AUTH_REQ_PROGRAM, AUTH_REQ_SSO, AUTH_REQ_USER, AUTH_RESULT_INSUFFICIENT_RIGHTS, AUTH_RESULT_INVALID_PASSWORD, AUTH_RESULT_INVALID_USERID, AUTH_RESULT_NONE, AUTH_RESULT_PER_USER_SESSION_LIMIT_REACHED, AUTH_RESULT_SKIP_TO_NEXT, AUTH_RESULT_SUCCESS, AUTH_RESULT_SYSTEM_SESSION_LIMIT_REACHED, AUTH_RESULT_UNSPECIFIED_FAILURE, PKT_SIZE_SKIP_TO_NEXT| Modifier | Constructor and Description |
|---|---|
private |
SecurityManager(BootstrapConfig bc)
Private constructor to enable this as a singleton class.
|
| Modifier and Type | Method and Description |
|---|---|
private boolean |
adminAccess()
Checks the rights of the caller to perform admin operations.
|
int |
adminGetCacheSerial(boolean scope)
Gets the server's account name.
|
java.lang.String |
adminGetServerName(boolean scope)
Gets the server's account name.
|
int |
adminRefresh(java.util.List<java.lang.String[]> msgBuf)
Refreshes the security cache from the current state of the directory.
|
(package private) java.lang.Object[] |
allowAccount(java.lang.String pid,
java.lang.String uid,
boolean iact)
Check if the given account is allowed to be used by an authentication request.
|
AuthData |
authenticateClient(NetSocket socket,
BootstrapConfig config)
Performs the requester side of a process or interactive client
authentication.
|
private AuthData |
authenticateClientWorker(NetSocket socket,
BootstrapConfig config)
Core worker for
authenticateClient(). |
java.lang.Object |
authenticateLocal(NetSocket socket)
Implements the server side of the authentication procedure for
processes or interactive clients.
|
java.lang.Object |
authenticateRemote(java.lang.String identity)
Verifies peer's credentials and performs remote authentication.
|
java.lang.Object |
authenticateServer(BootstrapConfig cfg)
Authenticate the current in-JVM thread using the configured certificate.
|
int |
authenticateServer(java.lang.Object sessionId,
java.lang.String userid,
java.lang.String password)
After this call the initial security context of the admin server will be established.
|
boolean |
changePassword()
Initiates the password change procedure, calls the configured password
input hook, and changes the password for the current user when it is
verified.
|
private boolean |
checkMaxSystemUsers(SecurityCache sc,
java.lang.String uid)
Detect if the total number of interactive user accounts in use exceeds the allowed number of
interactive users.
|
boolean |
checkShutdownAccess()
Checks access rights of the current subject with regards to the
"shutdown" instance of the "system" abstract resource.
|
private boolean |
checkUserAccountLimit(SecurityCache sc,
java.lang.String uid)
Detect if total number of simultaneous sessions from the given user account is more than the
configured per-account limit.
|
static void |
clearInstance()
Clean the storage caches.
|
boolean |
closeBatch(boolean disposition)
Notifies the Security Manager about a batch editing session to be
closed assuming the security cache to be refreshed.
|
boolean |
closeBatch(boolean disposition,
boolean refresh)
Notifies the Security Manager about a batch editing session to be
closed.
|
void |
closeRightsSearch(int handle,
boolean decision,
boolean cache)
Terminates the open search of Rights and frees up the related resources.
|
void |
closeRightsSearch(java.lang.String subject,
int handle,
boolean decision)
Terminates the open search of Rights and frees up the related resources.
|
static SecurityManager |
createInstance(BootstrapConfig bc)
Instantiates SecurityManager as a singleton.
|
java.lang.Object |
evaluate(int resourceId,
java.lang.Object link,
java.lang.String expr)
Compiles and evalautes an expression.
|
java.lang.String[] |
filterCiphers(java.lang.String[] ciphers)
Filter allowed ciphers
|
private Account |
getAccount(java.lang.String uid)
Get the account associated with the given user id.
|
java.lang.String |
getAccountAlias(java.lang.String subjectId)
Get the certificate alias for the specified subject.
|
java.lang.String[] |
getAccountIds()
Returns ALL subject IDs associated with the current context.
|
java.lang.String[] |
getAccountIds(java.lang.String acct)
Get all the subject IDs associated with the given P2J account.
|
java.lang.String[] |
getAccountsForAppserver(java.lang.String appServer)
Get the accounts configured to start the given appserver.
|
private static java.util.function.Predicate<AccessControlList> |
getAclMatcher(AbstractResource plugin,
java.lang.String instName)
Returns a predicate capable to filter access control list based on the supplied plugin and resource
name.
|
AccessControlList[] |
getACLs(int resourceId)
Returns the array of all ACLs defined for the specified resource type.
|
java.lang.String[] |
getAllSubjects()
Gets IDs of all defined accounts.
|
java.lang.String[] |
getAllUsers()
Gets IDs of all defined user accounts.
|
java.lang.String |
getAppServer()
Returns the the appserver associated with the current context.
|
java.lang.String |
getAppserverForProcess(java.lang.String pid)
Resolve the appserver associated with the given process ID.
|
java.lang.String |
getBrokerForProcess(java.lang.String pid)
Resolve the broker associated with the given process ID.
|
(package private) SecurityCache |
getCache()
Safely gets the reference to the security cache in a multithreaded
environment.
|
java.lang.Boolean |
getCachedDecision(int resourceId,
java.lang.String instanceName,
int mode)
Searches the cache for a previously made decision.
|
(package private) BootstrapConfig |
getConfig()
Returns the bootstrap configuration used to construct this instance.
|
java.util.Map<java.lang.String,java.util.Map<java.lang.Integer,Rights>> |
getConsolidatedACLs(java.lang.String type)
Get a map of consolidated ACL's, per each function.
|
static Control |
getCurrentContextControl()
Gives the context local information of a currently running thread.
|
java.lang.String |
getCustomClientExt()
Gets custom client extension plugin name.
|
java.lang.String |
getCustomServerExt()
Gets custom server extension plugin name.
|
Scope |
getEnclosingScope()
Gets the parent scope for this scope.
|
private java.lang.String |
getHookParam(SecurityCache cache,
java.lang.String hookName)
Get the default "option" value (specified into directory) for the given
custom auth hook.
|
java.lang.String |
getIdByOrdinal(int ordinal)
Gets IDs by thier ordinals.
|
static SecurityManager |
getInstance()
Returns the reference to the instance of SecurityManager.
|
AbstractResource |
getMandatoryPluginInstance(java.lang.String resourceTypeName)
Searches abstract resource registry for a plugin that is responsible
for the resources of the specified type.
|
Rights |
getNextRights(int handle)
Returns an instance of Rights interface to be used next in the access
rights check loop.
|
Rights |
getNextRights(java.lang.String subject,
int handle)
Returns an instance of Rights interface to be used next in the access
rights check loop.
|
java.lang.String[] |
getOsUserCredByFwdAcc(java.lang.String fwdUsername)
Returns the OS username and password associated with FWD username.
|
java.lang.String[] |
getOsUserCredByName(java.lang.String osUser)
Returns the OS username and password associated with FWD username.
|
private java.lang.String[] |
getOsUserPassFromNode(DirectoryService ds,
java.lang.String parentNodeId,
java.lang.String osUser)
Reads the directory node where the OS user details are supposed to reside.
|
java.lang.String |
getPeerHost()
Get the peer (remote) host for this session.
|
int |
getPeerPort()
Get the peer (remote) port for this session.
|
private NetSocket |
getPeerSocket()
Get the peer (remote) socket for this session.
|
AbstractResource |
getPluginInstance(java.lang.String resourceTypeName)
Searches abstract resource registry for a plugin that is responsible
for the resources of the specified type.
|
java.lang.String |
getServerAlias()
Get the certificate alias for the running sever.
|
java.lang.String |
getServerId()
Get the server account ID.
|
private java.util.Map<java.lang.String,java.util.Set<java.lang.Integer>> |
getSubjectsByInstanceName(int resourceId)
Consolidate all the subjects for each instance with defined ACLs, for
the given resources.
|
java.lang.String |
getSystemPassword(java.lang.String subjectId)
Get the system user password used to authenticate this subjectId on the machine running
the P2J server.
|
java.lang.String |
getSystemUser(java.lang.String subjectId)
Get the system user used to authenticate this subjectId on the machine running the P2J
server.
|
java.lang.Integer |
getThreadId()
Get the identifier mapped to the current thread.
|
java.lang.String |
getUserId()
Returns the subject ID associated with the current context.
|
java.lang.String |
getWebServerAlias()
Get the certificate alias for the web sever.
|
private static int |
hostMatch(java.lang.String host,
java.util.List<java.lang.String> list)
Compares the list of DNS names with the given host name.
|
static boolean |
initialized()
Returns a flag indicating the readiness of the security manager to
properly operate.
|
boolean |
isClient()
Returns
true if this is a client (not server) application. |
boolean |
isEditing()
Checks to see if a batch editing is in progress.
|
boolean |
isGroupDefined(java.lang.String uid)
Checks whether the specified group account exists.
|
boolean |
isPasswordAged()
Gets password age status for the current account.
|
boolean |
isProcessDefined(java.lang.String pid)
Checks whether the specified process account exists.
|
boolean |
isServer()
Returns
true if this is the server application. |
boolean |
isServerAccount()
Checks if the current context is the server one.
|
boolean |
isUserDefined(java.lang.String uid)
Checks whether the specified user account exists.
|
(package private) void |
logResource(SecurityCache cache,
int resourceId,
java.lang.String instanceName,
int mode,
boolean decision)
Creates an audit record for a resource instance access event.
|
(package private) void |
logResource(SecurityCache cache,
int resourceId,
java.lang.String instanceName,
int mode,
boolean decision,
java.lang.String message)
Creates an audit record for a resource instance access event.
|
private Authenticator |
obtainCustomAuthHook(java.lang.String hookName)
Get an instance of the in-process authentication class.
|
private Authenticator |
obtainCustomClientHook(NetSocket dis)
Gets custom authentication class and parameters from the server and runs
the specified method.
|
int |
openBatch(java.lang.String nodeId)
Notifies the Security Manager about a batch editing session to be
started for the specified directory branch.
|
int |
openRightsSearch(int resourceId,
java.lang.String instanceName,
int mode)
Creates a search handle.
|
int |
openRightsSearch(java.lang.String subject,
int resourceId,
java.lang.String instanceName,
int mode)
Creates a search handle.
|
(package private) java.lang.Object[] |
postAuthenticateWorker(java.lang.Object sid,
java.lang.String pid,
java.lang.String uid,
boolean iact)
Implements the server side of the authentication procedure for
processes or interactive clients.
|
private AuthenticationResponse |
runCustomServerHook(SecurityCache sc,
java.lang.String targetHookName,
Authenticator serverAuth,
java.lang.String entity,
byte[] auth)
Instantiates and runs the server side of the custom authentication hook.
|
private boolean |
sendAuthResult(NetSocket socket,
int authResult,
int authAction)
Worker to send back the authentication result and a disposition code.
|
private boolean |
sendAuthType(NetSocket socket,
BootstrapConfig cfg)
Send the client's requested authorization type on the given connection.
|
private void |
setCache(SecurityCache cache)
Safely sets the reference to the security cache in a mutithreaded
environment.
|
void |
setCleanupLock(java.lang.Object context,
java.lang.Object lock)
Set the context cleanup
lock, to avoid concurrent cleanups. |
(package private) boolean |
setPassword(java.lang.String newPassword)
Sets new password for the current user account.
|
static void |
stopAfterInterrupt(Control control)
Sets the context local to a control of a Conversation thread.
|
java.lang.String |
toString()
Returns the string representation of this object.
|
static boolean |
updateCachedUserAccount(UserDef user)
Find and update user account stored in cache.
|
getLibraries, getLibraryClasses, getLibsByClass, getVariableList, getVariablespublic final SecurityManager.ContextSecurityManager contextSm
public final SecurityManager.SessionSecurityManager sessionSm
public final SecurityManager.CertificateSecurityManager certificateSm
public final SecurityManager.VirtualConnectionSecurityManager virtualSm
public final SecurityManager.SsoSecurityManager ssoSm
public final LegacyWebSecurityManager legacyWebSm
public final AccountExtUtil accountExt
final SecurityManagerAuthenticator serverAuthenticator
final java.lang.Object pwchSync
private static final CentralLogger LOG
private static final int ALWAYS_RETRY
private static SecurityManager securityManager
private static java.lang.ThreadGroup secThreads
private BootstrapConfig cfg
private SecurityCache cache
private int cacheSerial
private TransportSecurity tranSec
private int nextThreadID
private static final java.lang.ThreadLocal<java.lang.Integer> THREAD_ID
private boolean init
private int interactiveUsers
private java.util.Map<java.lang.String,java.util.concurrent.atomic.AtomicInteger> interactiveSessions
private java.lang.Object userLimitLock
private java.util.Map<java.lang.Object,java.lang.Boolean> cleanupLocks
private final boolean useGCM
private SecurityManager(BootstrapConfig bc) throws ConfigurationException, java.lang.NoSuchMethodException
createInstance(com.goldencode.p2j.cfg.BootstrapConfig).bc - an instance of BootstrapConfig class used to get
the security related configuration informationConfigurationException - may be thrown in SecurityCachejava.lang.NoSuchMethodException - may be thrown in SecurityCachepublic static void clearInstance()
throws RestrictedUseException
RestrictedUseException - If called outside of expected code.public static SecurityManager createInstance(BootstrapConfig bc) throws ConfigurationException, java.lang.NoSuchMethodException
bc - an instance of BootstrapConfig class used to get
the security related configuration informationSecurityManagerConfigurationException - may be thrown in SecurityManager constructorjava.lang.NoSuchMethodException - may be thrown in SecurityCachepublic static SecurityManager getInstance()
SecurityManagerpublic static boolean initialized()
true if the security manager is ready to accept
requests.public static boolean updateCachedUserAccount(UserDef user) throws RestrictedUseException
user - User account parameters.true if account is found and updated.
false if account not found.RestrictedUseException - If called improperly.public static Control getCurrentContextControl() throws RestrictedUseException
RestrictedUseException - If called improperly.public static void stopAfterInterrupt(Control control) throws RestrictedUseException
control - Control related to a Conversation thread.RestrictedUseException - If called improperly.public java.lang.String getCustomServerExt()
public java.lang.String getCustomClientExt()
private static int hostMatch(java.lang.String host,
java.util.List<java.lang.String> list)
host - name to checklist - list of namesprivate Authenticator obtainCustomAuthHook(java.lang.String hookName)
private Authenticator obtainCustomClientHook(NetSocket dis)
The AUTHCUSTOM packet is two consecutive strings written using the
writeUTF() method. The first is the class name, followed
by the parameters. The no parameter case is handled as if it was an
empty string.
dis - The input stream to read from.public java.lang.String adminGetServerName(boolean scope)
scope - true means using the latest security cache,
otherwise the session security cachenullpublic int adminGetCacheSerial(boolean scope)
scope - true means using the latest security cache,
otherwise the session security cachepublic int adminRefresh(java.util.List<java.lang.String[]> msgBuf)
msgBuf - list to receive messages if logmode enables admin messagespublic final Scope getEnclosingScope()
getEnclosingScope in class ScopeScope object, which is null.public void setCleanupLock(java.lang.Object context,
java.lang.Object lock)
lock, to avoid concurrent cleanups.context - The SecurityContext instance to configure.lock - The instance on which to lock for context cleanup.public AuthData authenticateClient(NetSocket socket, BootstrapConfig config) throws RestrictedUseException
If required, the server's X.509 certificate is validated first. If this does not fail, its DNS name is checked as defined in RFC2830, p3.6:
The next and last step is the client authentication procedure.
Restricted use. This method checks the caller to be
com.goldencode.p2j.net.SessionManager.createQueue().
socket - The socket identifying this connection.config - BootstrapConfig instance which should override the security
manager's version; null to use default config.null if authentication failed.RestrictedUseException - If called improperly.private AuthData authenticateClientWorker(NetSocket socket, BootstrapConfig config)
authenticateClient(). Temporarily uses the provided configuration instance.socket - The socket identifying this connection.config - BootstrapConfig instance which should override the security
Can't be null.null if authentication failed.public java.lang.Object authenticateLocal(NetSocket socket) throws RestrictedUseException
Restricted use. This method checks the caller to be
com.goldencode.p2j.net.RouterSessionManager$Incoming.run().
There are two major classes of connections: certified and anonymous.
socket - Socket identifying this connection.null for failures
or a string describing normal client exit from authentication.RestrictedUseException - If called improperly.public java.lang.Object authenticateServer(BootstrapConfig cfg) throws RestrictedUseException
cfg - The configuration.null if authentication failed.RestrictedUseException - If this method is called from restricted contextpublic int authenticateServer(java.lang.Object sessionId,
java.lang.String userid,
java.lang.String password)
throws RestrictedUseException
sessionId - The session iduserid - The user idpassword - The passwordRestrictedUseException - If this method is called from restricted contextpublic java.lang.String[] getOsUserCredByFwdAcc(java.lang.String fwdUsername)
fwdUsername - The FWD account.public java.lang.String[] getOsUserCredByName(java.lang.String osUser)
osUser - The OS username.private java.lang.String[] getOsUserPassFromNode(DirectoryService ds, java.lang.String parentNodeId, java.lang.String osUser)
ds - The directory service.parentNodeId - The parent directory node.osUser - The OS user ID.public java.lang.String getServerId()
public java.lang.String getUserId()
The subject ID returned is either userID, or processId, if no user is logged on.
public java.lang.String getAppServer()
If no appserver is associated with the current context, it returns null
public java.lang.String getPeerHost()
public int getPeerPort()
public java.lang.String getServerAlias()
null if not called on a server thread.public java.lang.String getWebServerAlias()
null if not called on a server thread.public java.lang.String getAccountAlias(java.lang.String subjectId)
null.public java.lang.String getSystemUser(java.lang.String subjectId)
Utils.DirScope.BOTH.
If none configured, default to the subject ID.
subjectId - The subject ID.public java.lang.String getSystemPassword(java.lang.String subjectId)
Utils.DirScope.BOTH.
If none configured, default to null.
subjectId - The subject ID.public java.lang.Integer getThreadId()
public java.lang.String[] getAccountIds(java.lang.String acct)
acct - The P2J subject ID.public java.lang.String[] getAccountIds()
The first subject ID in the array is either a userID or a processId (if no user is logged on). All subsequent subject IDs are the list of group names. Note that as long as there is a security context, there will be at least 1 subject ID. The group subject IDs will only be there if the user or process belongs to 1 or more groups.
public java.lang.Object authenticateRemote(java.lang.String identity)
throws RestrictedUseException
Restricted use. This method checks the caller to be
com.goldencode.p2j.net.RouterSessionManager.authenticateRemote().
identity - remote application/client identity in the form "processID/userID"nullRestrictedUseException - if called improperlypublic AbstractResource getPluginInstance(java.lang.String resourceTypeName)
Note that the security cache has to be taken from the security context of the thread, since in the current cache the resource plugin can be either registered under different ID or even be dropped.
resourceTypeName - resource type nameAbstractResource objectpublic AbstractResource getMandatoryPluginInstance(java.lang.String resourceTypeName)
Note that the security cache has to be taken from the security context of the thread, since in the current cache the resource plugin can be either registered under different ID or even be dropped.
resourceTypeName - resource type nameAbstractResource object, never null.java.lang.IllegalStateException - when the requested plugin is not available.public java.lang.Boolean getCachedDecision(int resourceId,
java.lang.String instanceName,
int mode)
Plugins call this method to check whether a cached access check decision is available. Cached access check decisions are identified by triplets of {resourceId, instanceName, mode} exactly as they were specified when the decision was taken.
Note that the security cache has to be taken from the security context of the thread.
resourceId - resource identityinstanceName - resource instance namemode - access mode (requested rights) the decision was made aboutBoolean that wraps a decision, or null
if not available.public int openRightsSearch(int resourceId,
java.lang.String instanceName,
int mode)
Plugins call this method to initiate the access rights search for the specified resource instance and requested rights.
Note that the security cache has to be taken from the security context of the thread.
resourceId - The resource identity.instanceName - The resource instance name.mode - The access mode (requested rights) the decision was made about.private static java.util.function.Predicate<AccessControlList> getAclMatcher(AbstractResource plugin, java.lang.String instName)
AbstractResource.getACLMatcher() to retrieve a predicate, which is
then used to filter matching ACLs. If no predicate is returned by the supplied plugin a default
matching mechanism will be used as a fallback. The standard matching mechanism involves simple string
comparison of the supplied resource name and the resource name defined in the ACLs.plugin - A valid security plugin. Must not be null.instName - Resource instance name.public Rights getNextRights(int handle)
Plugins cast Rights to their own classes and use their custom methods to perform the check.
Note that the security cache has to be taken from the security context of the thread.
handle - search handleRightspublic void closeRightsSearch(int handle,
boolean decision,
boolean cache)
Note that the security cache has to be taken from the security context of the thread.
handle - search handledecision - true or false decision just madecache - true if the decision has to be cachedpublic int openRightsSearch(java.lang.String subject,
int resourceId,
java.lang.String instanceName,
int mode)
Plugins call this method to initiate the access rights search for the specified resource instance and requested rights.
Note that the security cache has to be taken from the security context of the thread.
The search handle is created for the specified subject.
subject - subject ID to which this search belongs.resourceId - resource identityinstanceName - resource instance namemode - access mode (requested rights) the decision was made aboutpublic Rights getNextRights(java.lang.String subject, int handle)
Plugins cast Rights to their own classes and use their custom methods to perform the check.
Note that the security cache has to be taken from the security context of the thread.
subject - subject ID to which the search handle belongs.handle - search handleRightspublic void closeRightsSearch(java.lang.String subject,
int handle,
boolean decision)
Note that the security cache has to be taken from the security context of the thread.
subject - subject ID to which the search handle belongs.handle - search handledecision - true or false decision just madepublic java.lang.Object evaluate(int resourceId,
java.lang.Object link,
java.lang.String expr)
The expression may refer to Security Manager's variables and functions and to the plugin's variables and functions, should one decide to expose any.
The current implementation arbitrates names clashes using natural scoping provided by Expression Engine, which can be modified by using qualifiers in the expression.
Note that the security cache has to be taken from the security context of the thread.
resourceId - resource identitylink - an Object that supplies the raw data for this computation and is
shared between the resource plugin and its library of exportsexpr - expression to compile and evaluatenull is returnedpublic int openBatch(java.lang.String nodeId)
Restricted use. This method checks the caller to be:
DirectoryService calls this method before it opens a batch. This method checks the subject's access rights to the "system", "change" instance, if the batch is for any branch of "/security".
The action is different for master servers versus regular ones. Only master servers are allowed to edit the P2J security directory. Regular servers cannot edit, but still need this call as a way of refreshing their internal caches.
Note that the security cache has to be taken from the security context of the thread.
nodeId - Subtree which will be edited.public boolean isEditing()
Restricted use. This method checks the caller to be:
true if there is an open editing batchpublic boolean closeBatch(boolean disposition)
DirectoryService calls this method after having successfully commited
the changes to the directory (disposition is true) or to
signal rollback.
Restricted use. This method checks the caller to be:
disposition - If this parameter is true then changes need to
be committed. Otherwise they are just thrown away and lock is
removed.true if operation was successful and tree was
successfully updated.public boolean closeBatch(boolean disposition,
boolean refresh)
DirectoryService calls this method after having successfully commited
the changes to the directory (disposition is true) or to
signal rollback.
Restricted use. This method checks the caller to be:
disposition - If this parameter is true then changes need to
be committed. Otherwise they are just thrown away and lock is
removed.refresh - when committing the batch, tells whether to refresh the
security cache or nottrue if operation was successful and tree was
successfully updated.public boolean checkShutdownAccess()
true if access is allowed.public boolean isServerAccount()
Note that the value returned by this method is sometimes different that isServer().
This is because isServer() will return true on all contexts created on
P2J server application, while this method will return false for eventual client
contexts additionally created inside the process (like an appserver Agent
class instance entity).
true only when called on server account context.public boolean isServer()
true if this is the server application.
Ultimately, this method checks the type attribute of the root node of the bootstrap
configuration file. If the current process was launched using a server value, then
this method returns true.
true if current process is the P2J server application.public boolean isClient()
true if this is a client (not server) application. This is the complementary
of the above method.true if on the client.public boolean isUserDefined(java.lang.String uid)
uid - user IDtrue if such user account existspublic boolean isProcessDefined(java.lang.String pid)
pid - process IDtrue if such process account existspublic java.lang.String getAppserverForProcess(java.lang.String pid)
pid - The process ID.null if the passed ID is not for a process or there is no
associated appserver for the process.public java.lang.String getBrokerForProcess(java.lang.String pid)
pid - The process ID.null if the passed ID is not for a process or there is no
associated broker for the process.public boolean isGroupDefined(java.lang.String uid)
uid - group IDtrue is such group account existspublic java.lang.String[] getAccountsForAppserver(java.lang.String appServer)
appServer is
null, this will return an array of length 0.appServer - The appserver for which the accounts are needed.public java.lang.String[] getAllUsers()
public java.lang.String[] getAllSubjects()
public java.lang.String getIdByOrdinal(int ordinal)
ordinal - ordinal number of some subject IDpublic AccessControlList[] getACLs(int resourceId)
resourceId - resource identityAccessControlLists. The array is empty if
the caller has no access rights to the system/accounts resource
instance.public java.util.Map<java.lang.String,java.util.Map<java.lang.Integer,Rights>> getConsolidatedACLs(java.lang.String type)
type - The resource type name for which the consolidated ACLs are
neededprivate java.util.Map<java.lang.String,java.util.Set<java.lang.Integer>> getSubjectsByInstanceName(int resourceId)
resourceId - resource identitypublic boolean changePassword()
true if password has been changed successfully.public boolean isPasswordAged()
true if this password is too old and needs changingpublic java.lang.String toString()
toString in class java.lang.ObjectSecurityCache getCache()
SecurityCacheBootstrapConfig getConfig()
BootstrapConfig associated with this
objectprivate boolean adminAccess()
true if the caller has sufficient rightsprivate Account getAccount(java.lang.String uid)
uid - user IDnullvoid logResource(SecurityCache cache, int resourceId, java.lang.String instanceName, int mode, boolean decision, java.lang.String message)
cache - security cache where to log this eventresourceId - resource identityinstanceName - resource instance namemode - access mode (requested rights) the decision was made aboutdecision - access decisionmessage - additional textvoid logResource(SecurityCache cache, int resourceId, java.lang.String instanceName, int mode, boolean decision)
cache - security cache where to log this eventresourceId - resource identityinstanceName - resource instance namemode - access mode (requested rights) the decision was made aboutdecision - access decisionboolean setPassword(java.lang.String newPassword)
newPassword - new password as plain texttrue if password has been set successfullyprivate boolean sendAuthType(NetSocket socket, BootstrapConfig cfg)
This method inspects the bootstrap configuration to see what kind of authentication to pick:
security.keystore.processalias is set;
AUTH_REQ_PROCESS will be sent.
security.keystore.processalias is not set, but
security.authentication.type is set and equals
PROGRAM;
AUTH_REQ_PROGRAM will be sent.
AUTH_REQ_USER will be sent.
socket - The socket on which to write our type.cfg - The attempted connection's configuration.true if successfulprivate void setCache(SecurityCache cache)
In the multithreaded environment, after the closing of a batch editing
session, a newly created thread rereads the directory and builds a new
instance of SecurityCache while the existing one continues
to serve the needs of the server. This call is the last step in the
refreshing of the security cache.
cache - reference to a copy of SecurityCacheprivate AuthenticationResponse runCustomServerHook(SecurityCache sc, java.lang.String targetHookName, Authenticator serverAuth, java.lang.String entity, byte[] auth)
Accepts the byte array produced by the client side authorization hook as the authentication input, and custom parameters.
sc - The security cache generation to be used.targetHookName - The name of the custom auth hook to run as it is represented
into the directory. Cannot be null.serverAuth - The instance of the server hook or null to
obtain the default processing.entity - Custom parameters.auth - The authorization input from the client.public java.lang.String[] filterCiphers(java.lang.String[] ciphers)
ciphers - available ciphersprivate boolean sendAuthResult(NetSocket socket, int authResult, int authAction)
socket - The socket to send on.authResult - The authentication result.authAction - The authentication disposition code.true if sent successfully.private java.lang.String getHookParam(SecurityCache cache, java.lang.String hookName)
cache - The security cache generation to be used.hookName - The name of the target custom hook.java.lang.Object[] allowAccount(java.lang.String pid,
java.lang.String uid,
boolean iact)
pid - The local process account being authenticated.uid - The local user account being authenticated.iact - true if this is a call that can be an interactive user session.null.
Otherwise, it returns an Object[5] array with the indexes:
0 = auth result (see SecurityConstants.AUTH_RESULT*),
1 = auth action (see SecurityConstants.AUTH_ACTION*),
2 = not used
3 = not used
4 = not usedjava.lang.Object[] postAuthenticateWorker(java.lang.Object sid,
java.lang.String pid,
java.lang.String uid,
boolean iact)
throws RestrictedUseException
sid - The new session id.pid - The local process account being authenticated.uid - The local user account being authenticated.iact - true if this is a call that can be an interactive user session.RestrictedUseExceptionprivate boolean checkUserAccountLimit(SecurityCache sc, java.lang.String uid)
sc - The current security cache.uid - The userid of the interactive accounttrue if a user limit is NOT exceeded.private boolean checkMaxSystemUsers(SecurityCache sc, java.lang.String uid)
sc - The current security cache.uid - The userid of the interactive accounttrue if the max user limit is NOT exceeded.private NetSocket getPeerSocket()