Java Code Examples for org.alfresco.service.cmr.security.AuthenticationService#guestUserAuthenticationAllowed()
The following examples show how to use
org.alfresco.service.cmr.security.AuthenticationService#guestUserAuthenticationAllowed() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ public boolean guestUserAuthenticationAllowed() { for (AuthenticationService authService : getUsableAuthenticationServices()) { if (authService.guestUserAuthenticationAllowed()) { return true; } } // it isn't allowed in any of the authentication components return false; }
Example 2
Source File: AuthenticationAdvice.java From alfresco-mvc with Apache License 2.0 | 4 votes |
public Object invoke(final MethodInvocation invocation) throws Throwable { Class<?> targetClass = invocation.getThis() != null ? invocation.getThis().getClass() : null; Method specificMethod = ClassUtils.getMostSpecificMethod(invocation.getMethod(), targetClass); // If we are dealing with method with generic parameters, find the original // method. specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod); AlfrescoAuthentication alfrescoAuthentication = parseAnnotation(specificMethod); if (alfrescoAuthentication != null) { AuthenticationType authenticationType = alfrescoAuthentication.value(); if (authenticationType != null && !AuthenticationType.NONE.equals(authenticationType)) { AuthenticationService authenticationService = serviceRegistry.getAuthenticationService(); AuthorityService authorityService = serviceRegistry.getAuthorityService(); String ticket = authenticationService.getCurrentTicket(); if (StringUtils.hasText(ticket)) { if (AuthenticationType.USER.equals(authenticationType) && authorityService.hasGuestAuthority()) { throw new AuthenticationException( "User has guest authority where at least a user authentication is required."); } else if (AuthenticationType.ADMIN.equals(authenticationType) && !authorityService.hasAdminAuthority()) { throw new AuthenticationException( "User does not have admin authority where at least named admin authentication is required ."); } } else if (AuthenticationType.GUEST.equals(authenticationType) && authenticationService.guestUserAuthenticationAllowed()) { authenticationService.authenticateAsGuest(); } else { throw new AuthenticationException("\nUnable to authenticate due to one of the following reasons:\n" + "Credentials are not provided in HTTP request where at least named user or admin authentication is required.\n" + "Guest user authentication is not allowed where at least guest authentication is required.\n"); } } } return invocation.proceed(); }