org.alfresco.service.cmr.security.AuthenticationService Java Examples
The following examples show how to use
org.alfresco.service.cmr.security.AuthenticationService.
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: ChainingAuthenticationServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void testServiceOne_GuestDenied() { ChainingAuthenticationServiceImpl as = new ChainingAuthenticationServiceImpl(); ArrayList<AuthenticationService> ases = new ArrayList<AuthenticationService>(); ases.add(service1); as.setAuthenticationServices(ases); try { as.authenticateAsGuest(); fail(); } catch (AuthenticationException e) { } }
Example #2
Source File: AbstractChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * {@inheritDoc} */ public void validate(String ticket) throws AuthenticationException { for (AuthenticationService authService : getUsableAuthenticationServices()) { try { authService.validate(ticket); return; } catch (AuthenticationException e) { // Ignore and chain if (logger.isTraceEnabled()) { logger.trace("Not that important: Exception validating the ticket. Message: " + e.getMessage(), e); } } } throw new AuthenticationException("Unable to validate ticket"); }
Example #3
Source File: AbstractChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * {@inheritDoc} */ public void invalidateTicket(String ticket) throws AuthenticationException { for (AuthenticationService authService : getUsableAuthenticationServices()) { try { authService.invalidateTicket(ticket); return; } catch (AuthenticationException e) { // Ignore and chain if (logger.isTraceEnabled()) { logger.trace("Not that important: Exception invalidating the ticket. Message: " + e.getMessage(), e); } } } throw new AuthenticationException("Unable to invalidate ticket"); }
Example #4
Source File: AbstractChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * {@inheritDoc} */ public void invalidateUserSession(String userName) throws AuthenticationException { for (AuthenticationService authService : getUsableAuthenticationServices()) { try { authService.invalidateUserSession(userName); return; } catch (AuthenticationException e) { // Ignore and chain if (logger.isTraceEnabled()) { logger.trace("Not that important: Exception invalidating the user session. Message: " + e.getMessage(), e); } } } throw new AuthenticationException("Unable to invalidate user session"); }
Example #5
Source File: AbstractChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * {@inheritDoc} */ public String getCurrentUserName() throws AuthenticationException { for (AuthenticationService authService : getUsableAuthenticationServices()) { try { return authService.getCurrentUserName(); } catch (AuthenticationException e) { // Ignore and chain if (logger.isTraceEnabled()) { logger.trace("Not that important: Exception getting the current username. Message: " + e.getMessage(), e); } } } return null; }
Example #6
Source File: AbstractChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * {@inheritDoc} */ public String getCurrentTicket() { for (AuthenticationService authService : getUsableAuthenticationServices()) { try { return authService.getCurrentTicket(); } catch (AuthenticationException e) { // Ignore and chain if (logger.isTraceEnabled()) { logger.trace("Not that important: Exception getting the current ticket. Message: " + e.getMessage(), e); } } } throw new AuthenticationException("Unable to issue ticket"); }
Example #7
Source File: ChainingAuthenticationServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void testService_GuestAllowed() { ChainingAuthenticationServiceImpl as = new ChainingAuthenticationServiceImpl(); ArrayList<AuthenticationService> ases = new ArrayList<AuthenticationService>(); ases.add(service1); ases.add(service2); ases.add(service3); ases.add(service4); ases.add(service5); ases.add(service6); as.setAuthenticationServices(ases); as.authenticateAsGuest(); assertEquals(as.getCurrentUserName(), AuthenticationUtil.getGuestUserName()); as.clearCurrentSecurityContext(); assertNull(as.getCurrentUserName()); }
Example #8
Source File: AbstractChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * {@inheritDoc} */ public void authenticateAsGuest() throws AuthenticationException { String defaultGuestName = AuthenticationUtil.getGuestUserName(); if (defaultGuestName != null && defaultGuestName.length() > 0) { preAuthenticationCheck(defaultGuestName); } for (AuthenticationService authService : getUsableAuthenticationServices()) { try { authService.authenticateAsGuest(); return; } catch (AuthenticationException e) { // Ignore and chain if (logger.isTraceEnabled()) { logger.trace("Not that important: Exception in chaining the authenticate as guest. Message: " + e.getMessage(), e); } } } throw new AuthenticationException(GUEST_AUTHENTICATION_NOT_SUPPORTED); }
Example #9
Source File: AbstractChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * {@inheritDoc} */ public void clearCurrentSecurityContext() { for (AuthenticationService authService : getUsableAuthenticationServices()) { try { authService.clearCurrentSecurityContext(); return; } catch (AuthenticationException e) { // Ignore and chain if (logger.isTraceEnabled()) { logger.trace("Not that important: Exception clearing the current security context. Message: " + e.getMessage(), e); } } } throw new AuthenticationException("Failed to clear security context"); }
Example #10
Source File: AbstractChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * {@inheritDoc} */ public boolean isCurrentUserTheSystemUser() { for (AuthenticationService authService : getUsableAuthenticationServices()) { try { return authService.isCurrentUserTheSystemUser(); } catch (AuthenticationException e) { // Ignore and chain } } return false; }
Example #11
Source File: ChainingAuthenticationServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void testService_GuestDenied() { ChainingAuthenticationServiceImpl as = new ChainingAuthenticationServiceImpl(); ArrayList<AuthenticationService> ases = new ArrayList<AuthenticationService>(); ases.add(service1); ases.add(service3); ases.add(service4); ases.add(service5); ases.add(service6); as.setAuthenticationServices(ases); try { as.authenticateAsGuest(); fail(); } catch (AuthenticationException e) { } }
Example #12
Source File: ChainingAuthenticationServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected List<AuthenticationService> getUsableAuthenticationServices() { if (this.mutableAuthenticationService == null) { return this.authenticationServices; } else { ArrayList<AuthenticationService> services = new ArrayList<AuthenticationService>( this.authenticationServices == null ? 1 : this.authenticationServices.size() + 1); services.add(this.mutableAuthenticationService); if (this.authenticationServices != null) { services.addAll(this.authenticationServices); } return services; } }
Example #13
Source File: HttpAlfrescoContentReader.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public HttpAlfrescoContentReader( TransactionService transactionService, AuthenticationService authenticationService, String baseHttpUrl, String contentUrl) { super(contentUrl); this.transactionService = transactionService; this.authenticationService = authenticationService; this.baseHttpUrl = baseHttpUrl; // Helpers this.httpClient = new HttpClient(); this.ticketCallback = new PropagateTicketCallback(); // A trip to the remote server has not been made cachedExists = false; cachedSize = 0L; cachedLastModified = 0L; }
Example #14
Source File: SubsystemChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected String getId(AuthenticationService authService) { this.lock.readLock().lock(); try { for (String instance : this.instanceIds) { if (authService.equals(this.sourceBeans.get(instance))) { return instance; } } } finally { this.lock.readLock().unlock(); } return super.getId(authService); }
Example #15
Source File: TaskFormPersister.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public TaskFormPersister(ContentModelItemData<WorkflowTask> itemData, NamespaceService namespaceService, DictionaryService dictionaryService, WorkflowService workflowService, NodeService nodeService, AuthenticationService authenticationService, BehaviourFilter behaviourFilter, Log logger) { super(itemData, namespaceService, dictionaryService, logger); WorkflowTask item = itemData.getItem(); // make sure that the task is not already completed if (item.getState().equals(WorkflowTaskState.COMPLETED)) { throw new AlfrescoRuntimeException("workflowtask.already.done.error"); } // make sure the current user is able to edit the task if (!workflowService.isTaskEditable(item, authenticationService.getCurrentUserName())) { throw new AccessDeniedException("Failed to update task with id '" + item.getId() + "'."); } this.updater = new TaskUpdater(item.getId(), workflowService, nodeService, behaviourFilter); }
Example #16
Source File: LocalAuthenticationServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void before() { childApplicationContextManager = (DefaultChildApplicationContextManager) ctx.getBean("Authentication"); personService = (PersonService) ctx.getBean("PersonService"); childApplicationContextManager.stop(); childApplicationContextManager.setProperty("chain", "external1:external"); ChildApplicationContextFactory childApplicationContextFactory = childApplicationContextManager.getChildApplicationContextFactory("external1"); // Clear the proxy user name childApplicationContextFactory.stop(); childApplicationContextFactory.setProperty("external.authentication.proxyUserName", ""); localAuthenticationService = (AuthenticationService) childApplicationContextFactory.getApplicationContext() .getBean("localAuthenticationService"); AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); }
Example #17
Source File: TestWithUserUtils.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Get the current user node reference * * @param authenticationService the authentication service * @return the currenlty authenticated user's node reference */ public static String getCurrentUser(AuthenticationService authenticationService) { String un = authenticationService.getCurrentUserName(); if (un != null) { return un; } else { throw new RuntimeException("The current user could not be retrieved."); } }
Example #18
Source File: Tool.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Login to Repository */ private void login() { // TODO: Replace with call to ServiceRegistry AuthenticationService auth = (AuthenticationService) serviceRegistry.getAuthenticationService(); auth.authenticate(toolContext.getUsername(), toolContext.getPassword().toCharArray()); logInfo("Connected as " + toolContext.getUsername()); }
Example #19
Source File: AbstractChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ public boolean authenticationExists(String userName) { for (AuthenticationService authService : getUsableAuthenticationServices()) { if (authService.authenticationExists(userName)) { return true; } } // it doesn't exist in any of the authentication components return false; }
Example #20
Source File: ChainingAuthenticationServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public void testServiceOne_Auth() { ChainingAuthenticationServiceImpl as = new ChainingAuthenticationServiceImpl(); ArrayList<AuthenticationService> ases = new ArrayList<AuthenticationService>(); ases.add(service1); as.setAuthenticationServices(ases); as.authenticate("andy", "andy".toCharArray()); assertEquals(as.getCurrentUserName(), "andy"); }
Example #21
Source File: FFCLoadsOfFiles.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public static void main(String[] args) { // initialise app content ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); // get registry of services final ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); // authenticate AuthenticationService authenticationService = serviceRegistry.getAuthenticationService(); authenticationService.authenticate(AuthenticationUtil.getAdminUserName(), "admin".toCharArray()); // use TransactionWork to wrap service calls in a user transaction TransactionService transactionService = serviceRegistry.getTransactionService(); RetryingTransactionCallback<Object> exampleWork = new RetryingTransactionCallback<Object>() { public Object execute() throws Exception { doExample(serviceRegistry); return null; } }; currentDoc = 0; while (currentDoc < totalNumDocs) { transactionService.getRetryingTransactionHelper().doInTransaction(exampleWork); } System.exit(0); }
Example #22
Source File: AbstractChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ public Set<String> getDomains() { HashSet<String> domains = new HashSet<String>(); for (AuthenticationService authService : getUsableAuthenticationServices()) { domains.addAll(authService.getDomains()); } return domains; }
Example #23
Source File: AbstractChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override public Set<String> getUsersWithTickets(boolean nonExpiredOnly) { HashSet<String> users = new HashSet<String>(); for (AuthenticationService authService : getUsableAuthenticationServices()) { if (authService instanceof AbstractAuthenticationService) { users.addAll(((AbstractAuthenticationService) authService).getUsersWithTickets(nonExpiredOnly)); } } return users; }
Example #24
Source File: AbstractChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override public int invalidateTickets(boolean nonExpiredOnly) { int count = 0; for (AuthenticationService authService : getUsableAuthenticationServices()) { if (authService instanceof AbstractAuthenticationService) { count += ((AbstractAuthenticationService) authService).invalidateTickets(nonExpiredOnly); } } return count; }
Example #25
Source File: AbstractChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override public Set<TicketComponent> getTicketComponents() { Set<TicketComponent> tcs = new HashSet<TicketComponent>(); for (AuthenticationService authService : getUsableAuthenticationServices()) { if (authService instanceof AbstractAuthenticationService) { tcs.addAll(((AbstractAuthenticationService) authService).getTicketComponents()); } } return tcs; }
Example #26
Source File: AbstractChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ public Set<String> getDefaultAdministratorUserNames() { Set<String> defaultAdministratorUserNames = new TreeSet<String>(); for (AuthenticationService authService : getUsableAuthenticationServices()) { defaultAdministratorUserNames.addAll(authService.getDefaultAdministratorUserNames()); } return defaultAdministratorUserNames; }
Example #27
Source File: AbstractChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ public Set<String> getDefaultGuestUserNames() { Set<String> defaultGuestUserNames = new TreeSet<String>(); for (AuthenticationService authService : getUsableAuthenticationServices()) { defaultGuestUserNames.addAll(authService.getDefaultGuestUserNames()); } return defaultGuestUserNames; }
Example #28
Source File: SubsystemChainingAuthenticationService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public MutableAuthenticationService getMutableAuthenticationService() { this.lock.readLock().lock(); try { refreshBeans(); for (String instance : this.instanceIds) { AuthenticationService authenticationService = (AuthenticationService) this.sourceBeans.get(instance); // Only add active authentication services. E.g. we might have an ldap context that is only used for // synchronizing if (authenticationService instanceof MutableAuthenticationService && (!(authenticationService instanceof ActivateableBean) || ((ActivateableBean) authenticationService) .isActive())) { return (MutableAuthenticationService) authenticationService; } } return null; } finally { this.lock.readLock().unlock(); } }
Example #29
Source File: TaskFormProcessor.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public TaskFormProcessor(WorkflowService workflowService, NamespaceService namespaceService, DictionaryService dictionaryService, AuthenticationService authenticationService, PersonService personService, FieldProcessorRegistry fieldProcessorRegistry) { this.workflowService = workflowService; this.namespaceService = namespaceService; this.dictionaryService = dictionaryService; this.authenticationService = authenticationService; this.personService = personService; this.fieldProcessorRegistry = fieldProcessorRegistry; }
Example #30
Source File: ChainingAuthenticationServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public void testServiceTwo_GuestAllowed() { ChainingAuthenticationServiceImpl as = new ChainingAuthenticationServiceImpl(); ArrayList<AuthenticationService> ases = new ArrayList<AuthenticationService>(); ases.add(service2); as.setAuthenticationServices(ases); as.authenticateAsGuest(); assertEquals(as.getCurrentUserName(), AuthenticationUtil.getGuestUserName()); as.clearCurrentSecurityContext(); assertNull(as.getCurrentUserName()); }