public void setProperty(String name, String value) { if(false == isUpdateable(name)) { throw new IllegalStateException("Illegal write to property \"" + name + "\""); } super.setProperty(name, value); }
public void setProperty(String name, String value) { if(false == isUpdateable(name)) { throw new IllegalStateException("Illegal write to property \"" + name + "\""); } super.setProperty(name, value); }
childApplicationContextFactory.setProperty("external.authentication.proxyUserName", "CN=alfresco-system"); childApplicationContextFactory.setProperty("external.authentication.proxyHeader", "X-Alfresco-Remote-User");
@AfterClass public static void stopOOoSubsystems() throws Exception { // Put the OOoJodconverter subsystem back to its install settings (disabled). if (log.isDebugEnabled()) { log.debug("Disabling OOoJodconverter"); } oooJodcSubsystem.stop(); oooJodcSubsystem.setProperty("jodconverter.enabled", "false"); oooJodcSubsystem.start(); oooJodcSubsystem.stop(); } }
public void testProxiedHeader() throws Exception { // Set the proxy user name childApplicationContextFactory.stop(); childApplicationContextFactory.setProperty("external.authentication.proxyUserName", "bob"); // Mock a request with both a user and a header HttpServletRequest mockRequest = mock(HttpServletRequest.class); when(mockRequest.getScheme()).thenReturn("http"); when(mockRequest.getRemoteUser()).thenReturn("bob"); when(mockRequest.getHeader("X-Alfresco-Remote-User")).thenReturn("AdMiN"); assertEquals("admin", ((RemoteUserMapper) childApplicationContextFactory.getApplicationContext().getBean( "remoteUserMapper")).getRemoteUser(mockRequest)); // Now try header pattern matching childApplicationContextFactory.stop(); childApplicationContextFactory.setProperty("external.authentication.userIdPattern", "abc-(.*)-999"); when(mockRequest.getHeader("X-Alfresco-Remote-User")).thenReturn("abc-AdMiN-999"); assertEquals("admin", ((RemoteUserMapper) childApplicationContextFactory.getApplicationContext().getBean( "remoteUserMapper")).getRemoteUser(mockRequest)); // Try a request with an invalid match when(mockRequest.getHeader("X-Alfresco-Remote-User")).thenReturn("abc-AdMiN-998"); assertNull(((RemoteUserMapper) childApplicationContextFactory.getApplicationContext().getBean( "remoteUserMapper")).getRemoteUser(mockRequest)); // Try a request without the remote user when(mockRequest.getRemoteUser()).thenReturn(null); assertNull(((RemoteUserMapper) childApplicationContextFactory.getApplicationContext().getBean( "remoteUserMapper")).getRemoteUser(mockRequest)); }
public void testUnproxiedHeader() throws Exception { // Clear the proxy user name childApplicationContextFactory.stop(); childApplicationContextFactory.setProperty("external.authentication.proxyUserName", ""); // Mock a request with a username in the header HttpServletRequest mockRequest = mock(HttpServletRequest.class); when(mockRequest.getHeader("X-Alfresco-Remote-User")).thenReturn("AdMiN"); assertEquals("admin", ((RemoteUserMapper) childApplicationContextFactory.getApplicationContext().getBean( "remoteUserMapper")).getRemoteUser(mockRequest)); // Mock an unauthenticated request when(mockRequest.getHeader("X-Alfresco-Remote-User")).thenReturn(null); assertNull(((RemoteUserMapper) childApplicationContextFactory.getApplicationContext().getBean( "remoteUserMapper")).getRemoteUser(mockRequest)); // Mock a remote user request when(mockRequest.getRemoteUser()).thenReturn("ADMIN"); assertEquals("admin", ((RemoteUserMapper) childApplicationContextFactory.getApplicationContext().getBean( "remoteUserMapper")).getRemoteUser(mockRequest)); }
public void testWrongPublicKeyWithError() throws Exception { // generate and apply an incorrect public key childApplicationContextFactory.stop(); childApplicationContextFactory.setProperty(CONFIG_SILENT_ERRORS, "false"); applyHardcodedPublicKey(KeyPairGenerator.getInstance("RSA").generateKeyPair().getPublic()); // create token String jwt = generateToken(false); // create mock request object HttpServletRequest mockRequest = createMockTokenRequest(jwt); // ensure user mapper falls through instead of throwing an exception String user = ((RemoteUserMapper)childApplicationContextFactory.getApplicationContext().getBean( REMOTE_USER_MAPPER_BEAN_NAME)).getRemoteUser(mockRequest); assertEquals("Returned user should be null when wrong public key is used.", null, user); }
@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(); }
oooJodcSubsystem.setProperty("jodconverter.enabled", "true"); oooJodcSubsystem.setProperty("jodconverter.portNumbers", "2022, 2023, 2024"); oooJodcSubsystem.start();
public void testExpiredTokenWithError() throws Exception { // turn on validation failure reporting childApplicationContextFactory.stop(); childApplicationContextFactory.setProperty(CONFIG_SILENT_ERRORS, "false"); applyHardcodedPublicKey(this.keyPair.getPublic()); // create token String jwt = generateToken(true); // create mock request object HttpServletRequest mockRequest = createMockTokenRequest(jwt); // ensure an exception is thrown with correct description String user = ((RemoteUserMapper)childApplicationContextFactory.getApplicationContext().getBean( REMOTE_USER_MAPPER_BEAN_NAME)).getRemoteUser(mockRequest); assertEquals("Returned user should be null when the token is expired.", null, user); }
sysAdminSubsystem.setProperty(sitePublicGroupPropName, prefixedNewGroupName); sysAdminSubsystem.start(); sysAdminSubsystem.setProperty(sitePublicGroupPropName, originalSitePublicGroup); sysAdminSubsystem.start();