Class GrouperMcpAuthUser
java.lang.Object
edu.internet2.middleware.grouper.ws.mcp.GrouperMcpAuthUser
holds the authenticated MCP user identity, regardless of whether
they authenticated via OAuth JWT or via normal WS authentication
(HTTP Basic, container auth, etc.).
When the user authenticated via OAuth JWT, the consent scope booleans
reflect what the user approved on the consent page. When the user
authenticated via normal WS auth (HTTP Basic, container, etc.), the
consent scope booleans are all false and isOAuthAuthenticated()
returns false, meaning consent scopes are not applicable and only
group membership is used for authorization.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildReadwriteScopeDeniedError(String entityType, String entityName) build a scope denial error message that includes when the JWT was issued, so the user can tell if they need to re-authenticate to get updated scopes.readwrite scope restriction: folder paths the user consented to.readwrite scope restriction: group paths the user consented to.readwrite scope restriction: subject IDs/identifiers the user consented to.when the JWT was issued (from the "iat" claim), or null if not OAuth authenticatedlongmember internal id from grouper_members for the authenticated userinternal id of the OAuth client, or null if not OAuth authenticatedthe resolved Grouper subject for the authenticated userbooleancheck if the user has any group or folder values in the readwrite scope.booleancheck if the user has any subject values in the readwrite scope.booleanwhether readwrite data-scope restrictions are active.booleanwhether the user consented to the adminReadonly scopebooleanwhether the user consented to the adminReadwrite scopebooleanwhether the user consented to the readonly scopebooleanwhether the user consented to the readwrite scopebooleanwhether the user consented to the sqlReadonly scopebooleanisGroupInReadwriteScope(String groupName) Check if a group name is within the readwrite scope restriction.booleanisGroupInReadwriteScope(String groupName, String groupUuid) Check if a group is within the readwrite scope restriction by checking both the group name and UUID against the scope lists.booleanwhether this user authenticated via OAuth JWTbooleanisStemInReadwriteScope(String stemName) Check if a stem (folder) name is within the readwrite scope restriction.booleanisStemInReadwriteScope(String stemName, String stemUuid) Check if a stem (folder) is within the readwrite scope restriction by checking both the stem name and UUID against the scope lists.booleanisSubjectInReadwriteScope(String subjectIdOrIdentifier) Check if a subject ID or identifier is within the readwrite scope restriction.booleanisSubjectInReadwriteScope(List<String> subjectIdsAndIdentifiers) Check if any of the given subject identifiers (subjectId, subjectIdentifier0, subjectIdentifier1, subjectIdentifier2, etc.) are within the readwrite scope restriction.voidsetConsentReadwriteFolders(List<String> consentReadwriteFolders1) set the readwrite folder scope restrictionvoidsetConsentReadwriteGroups(List<String> consentReadwriteGroups1) set the readwrite group scope restrictionvoidsetConsentReadwriteScopeRestricted(boolean consentReadwriteScopeRestricted1) set whether readwrite data-scope restrictions are activevoidsetConsentReadwriteSubjects(List<String> consentReadwriteSubjects1) set the readwrite subject scope restrictionvoidsetConsentScopeAdminReadonly(boolean consentScopeAdminReadonly1) set whether the user consented to the adminReadonly scopevoidsetConsentScopeAdminReadwrite(boolean consentScopeAdminReadwrite1) set whether the user consented to the adminReadwrite scopevoidsetConsentScopeReadonly(boolean consentScopeReadonly1) set whether the user consented to the readonly scopevoidsetConsentScopeReadwrite(boolean consentScopeReadwrite1) set whether the user consented to the readwrite scopevoidsetConsentScopeSqlReadonly(boolean consentScopeSqlReadonly1) set whether the user consented to the sqlReadonly scopevoidsetJwtIssuedAt(Date jwtIssuedAt1) set when the JWT was issuedvoidsetMemberInternalId(long memberInternalId1) set the member internal idvoidsetOAuthAuthenticated(boolean oAuthAuthenticated1) set whether this user authenticated via OAuth JWTvoidsetOauthClientInternalId(Long oauthClientInternalId1) set the oauth client internal id
-
Constructor Details
-
GrouperMcpAuthUser
constructor- Parameters:
subject- the resolved Grouper subject
-
-
Method Details
-
getSubject
the resolved Grouper subject for the authenticated user- Returns:
- the subject
-
getMemberInternalId
public long getMemberInternalId()member internal id from grouper_members for the authenticated user- Returns:
- the member internal id
-
setMemberInternalId
public void setMemberInternalId(long memberInternalId1) set the member internal id- Parameters:
memberInternalId1-
-
isOAuthAuthenticated
public boolean isOAuthAuthenticated()whether this user authenticated via OAuth JWT- Returns:
- true if OAuth JWT authenticated
-
setOAuthAuthenticated
public void setOAuthAuthenticated(boolean oAuthAuthenticated1) set whether this user authenticated via OAuth JWT- Parameters:
oAuthAuthenticated1-
-
isConsentScopeReadonly
public boolean isConsentScopeReadonly()whether the user consented to the readonly scope- Returns:
- true if readonly was consented
-
setConsentScopeReadonly
public void setConsentScopeReadonly(boolean consentScopeReadonly1) set whether the user consented to the readonly scope- Parameters:
consentScopeReadonly1-
-
isConsentScopeReadwrite
public boolean isConsentScopeReadwrite()whether the user consented to the readwrite scope- Returns:
- true if readwrite was consented
-
setConsentScopeReadwrite
public void setConsentScopeReadwrite(boolean consentScopeReadwrite1) set whether the user consented to the readwrite scope- Parameters:
consentScopeReadwrite1-
-
isConsentScopeSqlReadonly
public boolean isConsentScopeSqlReadonly()whether the user consented to the sqlReadonly scope- Returns:
- true if sqlReadonly was consented
-
setConsentScopeSqlReadonly
public void setConsentScopeSqlReadonly(boolean consentScopeSqlReadonly1) set whether the user consented to the sqlReadonly scope- Parameters:
consentScopeSqlReadonly1-
-
isConsentScopeAdminReadonly
public boolean isConsentScopeAdminReadonly()whether the user consented to the adminReadonly scope- Returns:
- true if adminReadonly was consented
-
setConsentScopeAdminReadonly
public void setConsentScopeAdminReadonly(boolean consentScopeAdminReadonly1) set whether the user consented to the adminReadonly scope- Parameters:
consentScopeAdminReadonly1-
-
isConsentScopeAdminReadwrite
public boolean isConsentScopeAdminReadwrite()whether the user consented to the adminReadwrite scope- Returns:
- true if adminReadwrite was consented
-
setConsentScopeAdminReadwrite
public void setConsentScopeAdminReadwrite(boolean consentScopeAdminReadwrite1) set whether the user consented to the adminReadwrite scope- Parameters:
consentScopeAdminReadwrite1-
-
getOauthClientInternalId
internal id of the OAuth client, or null if not OAuth authenticated- Returns:
- the oauth client internal id
-
setOauthClientInternalId
set the oauth client internal id- Parameters:
oauthClientInternalId1-
-
getConsentReadwriteFolders
readwrite scope restriction: folder paths the user consented to. null or empty means no folder restriction, unless consentReadwriteScopeRestricted is true (then empty means nothing allowed).- Returns:
- the folder paths
-
setConsentReadwriteFolders
set the readwrite folder scope restriction- Parameters:
consentReadwriteFolders1-
-
getConsentReadwriteGroups
readwrite scope restriction: group paths the user consented to. null or empty means no group restriction, unless consentReadwriteScopeRestricted is true (then empty means nothing allowed).- Returns:
- the group paths
-
setConsentReadwriteGroups
set the readwrite group scope restriction- Parameters:
consentReadwriteGroups1-
-
getConsentReadwriteSubjects
readwrite scope restriction: subject IDs/identifiers the user consented to. null or empty means no subject restriction, unless consentReadwriteScopeRestricted is true (then empty means nothing allowed).- Returns:
- the subject IDs
-
setConsentReadwriteSubjects
set the readwrite subject scope restriction- Parameters:
consentReadwriteSubjects1-
-
isConsentReadwriteScopeRestricted
public boolean isConsentReadwriteScopeRestricted()whether readwrite data-scope restrictions are active. when true, empty restriction lists mean "nothing is allowed" for that category. when false, empty lists mean "no restriction" (all allowed).- Returns:
- true if restrictions are active
-
setConsentReadwriteScopeRestricted
public void setConsentReadwriteScopeRestricted(boolean consentReadwriteScopeRestricted1) set whether readwrite data-scope restrictions are active- Parameters:
consentReadwriteScopeRestricted1-
-
isGroupInReadwriteScope
Check if a group name is within the readwrite scope restriction. First checks the name directly against the scope lists. If no match is found, resolves the group to get its UUID and checks that as well. This allows the scope list to contain either group names or UUIDs.- Parameters:
groupName- the full group name (ID path)- Returns:
- true if the group is in the readwrite scope
-
isGroupInReadwriteScope
Check if a group is within the readwrite scope restriction by checking both the group name and UUID against the scope lists. If no folder/group restrictions are set: when consentReadwriteScopeRestricted is false all groups are in scope; when true, groups are in scope only if at least one other dimension (subjects) has values (meaning this dimension is simply unscoped, not blocked). A group is in scope if its name or UUID matches a consented group entry, or if its name starts with a consented folder path followed by ":".- Parameters:
groupName- the full group name (ID path), may be nullgroupUuid- the group UUID, may be null- Returns:
- true if the group is in the readwrite scope
-
isStemInReadwriteScope
Check if a stem (folder) name is within the readwrite scope restriction. First checks the name directly against the scope lists. If no match is found, resolves the stem to get its UUID and checks that as well. This allows the scope list to contain either stem names or UUIDs.- Parameters:
stemName- the full stem name (ID path)- Returns:
- true if the stem is in the readwrite scope
-
isStemInReadwriteScope
Check if a stem (folder) is within the readwrite scope restriction by checking both the stem name and UUID against the scope lists. If no folder restrictions are set: when consentReadwriteScopeRestricted is false all stems are in scope; when true, stems are in scope only if at least one other dimension has values (meaning this dimension is simply unscoped, not blocked). A stem is in scope if its name or UUID matches a consented folder entry, or if its name starts with a consented folder path followed by ":".- Parameters:
stemName- the full stem name (ID path), may be nullstemUuid- the stem UUID, may be null- Returns:
- true if the stem is in the readwrite scope
-
isSubjectInReadwriteScope
Check if a subject ID or identifier is within the readwrite scope restriction. First checks the provided value directly. If no match is found, resolves the member record to get all identifiers (subjectId, subjectIdentifier0, subjectIdentifier1, subjectIdentifier2) and checks those as well. This allows the scope list to contain any form of subject identifier and still match regardless of which form the API caller uses.- Parameters:
subjectIdOrIdentifier- the subject ID or identifier to check- Returns:
- true if the subject is in the readwrite scope
-
isSubjectInReadwriteScope
Check if any of the given subject identifiers (subjectId, subjectIdentifier0, subjectIdentifier1, subjectIdentifier2, etc.) are within the readwrite scope restriction. This allows the scope list to contain any form of subject identifier (ID, identifier0, identifier1, identifier2) and still match regardless of which form the API caller uses. If no subject restrictions are set: when consentReadwriteScopeRestricted is false all subjects are in scope; when true, subjects are in scope only if at least one other dimension has values (meaning this dimension is simply unscoped, not blocked).- Parameters:
subjectIdsAndIdentifiers- all known IDs and identifiers for the subject- Returns:
- true if any of the identifiers matches the readwrite scope
-
getJwtIssuedAt
when the JWT was issued (from the "iat" claim), or null if not OAuth authenticated- Returns:
- the issued-at date
-
setJwtIssuedAt
set when the JWT was issued- Parameters:
jwtIssuedAt1-
-
buildReadwriteScopeDeniedError
build a scope denial error message that includes when the JWT was issued, so the user can tell if they need to re-authenticate to get updated scopes.- Parameters:
entityType- e.g. "group", "stem", "subject"entityName- the name of the entity that was denied- Returns:
- the error message string
-
hasGroupOrFolderReadwriteScope
public boolean hasGroupOrFolderReadwriteScope()check if the user has any group or folder values in the readwrite scope. when scope is restricted and there are no group or folder scope values, returns false, meaning tools like group_save, group_delete, folder_delete should not be available. when scope is not restricted, always returns true.- Returns:
- true if the user has group or folder scope or is not scope restricted
-
hasSubjectReadwriteScope
public boolean hasSubjectReadwriteScope()check if the user has any subject values in the readwrite scope. when scope is restricted and there are no subject scope values, returns false, meaning subject-owner operations in attribute_assignment_save should be denied. when scope is not restricted, always returns true.- Returns:
- true if the user has subject scope or is not scope restricted
-