@Test public void testAttachSession() throws Exception { assertNull( request.getDavSession() ); sessionProvider.attachSession( request ); assertNotNull( request.getDavSession() ); }
@Override public boolean attachSession( WebdavRequest request ) throws DavException { final String repositoryId = RepositoryPathUtil.getRepositoryName( removeContextPath( request ) ); try { AuthenticationResult result = httpAuth.getAuthenticationResult( request, null ); request.setDavSession( new ArchivaDavSession() ); return servletAuth.isAuthenticated( request, result ); } catch ( AuthenticationException e ) { String guest = UserManager.GUEST_USERNAME; try { if ( servletAuth.isAuthorized( guest, ( (ArchivaDavResourceLocator) request.getRequestLocator() ).getRepositoryId(), WebdavMethodUtil.getMethodPermission( request.getMethod() ) ) ) { request.setDavSession( new ArchivaDavSession() ); return true; } } catch ( UnauthorizedException ae ) { throw new UnauthorizedDavException( repositoryId, "You are not authenticated and authorized to access any repository." ); } throw new UnauthorizedDavException( repositoryId, "You are not authenticated." ); } catch ( MustChangePasswordException e ) { throw new UnauthorizedDavException( repositoryId, "You must change your password." ); } catch ( AccountLockedException e ) { throw new UnauthorizedDavException( repositoryId, "User account is locked." ); } }
ArchivaDavSessionProvider implements DavSessionProvider { @Override public boolean attachSession( WebdavRequest request ) throws DavException { final String repositoryId = RepositoryPathUtil.getRepositoryName( removeContextPath( request ) ); try { AuthenticationResult result = httpAuth.getAuthenticationResult( request, null ); request.setDavSession( new ArchivaDavSession() ); return servletAuth.isAuthenticated( request, result ); } catch ( AuthenticationException e ) { String guest = UserManager.GUEST_USERNAME; try { if ( servletAuth.isAuthorized( guest, ( (ArchivaDavResourceLocator) request.getRequestLocator() ).getRepositoryId(), WebdavMethodUtil.getMethodPermission( request.getMethod() ) ) ) { request.setDavSession( new ArchivaDavSession() ); return true; } } catch ( UnauthorizedException ae ) { throw new UnauthorizedDavException( repositoryId, "You are not authenticated and authorized to access any repository." ); } throw new UnauthorizedDavException( repositoryId, "You are not authenticated." ); } catch ( MustChangePasswordException e ) { throw new UnauthorizedDavException( repositoryId, "You must change your password." ); } catch ( AccountLockedException e ) { throw new UnauthorizedDavException( repositoryId, "User account is locked." ); } } }
ArchivaDavSessionProvider implements DavSessionProvider { @Override public boolean attachSession( WebdavRequest request ) throws DavException { final String repositoryId = RepositoryPathUtil.getRepositoryName( removeContextPath( request ) ); try { AuthenticationResult result = httpAuth.getAuthenticationResult( request, null ); request.setDavSession( new ArchivaDavSession() ); return servletAuth.isAuthenticated( request, result ); } catch ( AuthenticationException e ) { String guest = UserManager.GUEST_USERNAME; try { if ( servletAuth.isAuthorized( guest, ( (ArchivaDavResourceLocator) request.getRequestLocator() ).getRepositoryId(), WebdavMethodUtil.getMethodPermission( request.getMethod() ) ) ) { request.setDavSession( new ArchivaDavSession() ); return true; } } catch ( UnauthorizedException ae ) { throw new UnauthorizedDavException( repositoryId, "You are not authenticated and authorized to access any repository." ); } throw new UnauthorizedDavException( repositoryId, "You are not authenticated." ); } catch ( MustChangePasswordException e ) { throw new UnauthorizedDavException( repositoryId, "You must change your password." ); } catch ( AccountLockedException e ) { throw new UnauthorizedDavException( repositoryId, "User account is locked." ); } } ArchivaDavSessionProvider( ServletAuthenticator servletAuth, HttpAuthenticator httpAuth ); }
ArchivaDavSessionProvider implements DavSessionProvider { @Override public boolean attachSession( WebdavRequest request ) throws DavException { final String repositoryId = RepositoryPathUtil.getRepositoryName( removeContextPath( request ) ); try { AuthenticationResult result = httpAuth.getAuthenticationResult( request, null ); request.setDavSession( new ArchivaDavSession() ); return servletAuth.isAuthenticated( request, result ); } catch ( AuthenticationException e ) { String guest = UserManager.GUEST_USERNAME; try { if ( servletAuth.isAuthorized( guest, ( (ArchivaDavResourceLocator) request.getRequestLocator() ).getRepositoryId(), WebdavMethodUtil.getMethodPermission( request.getMethod() ) ) ) { request.setDavSession( new ArchivaDavSession() ); return true; } } catch ( UnauthorizedException ae ) { throw new UnauthorizedDavException( repositoryId, "You are not authenticated and authorized to access any repository." ); } throw new UnauthorizedDavException( repositoryId, "You are not authenticated." ); } catch ( MustChangePasswordException e ) { throw new UnauthorizedDavException( repositoryId, "You must change your password." ); } catch ( AccountLockedException e ) { throw new UnauthorizedDavException( repositoryId, "User account is locked." ); } } ArchivaDavSessionProvider( ServletAuthenticator servletAuth, HttpAuthenticator httpAuth ); @Override boolean attachSession( WebdavRequest request ); @Override void releaseSession( WebdavRequest request ); }
ArchivaDavSessionProvider implements DavSessionProvider { @Override public boolean attachSession( WebdavRequest request ) throws DavException { final String repositoryId = RepositoryPathUtil.getRepositoryName( removeContextPath( request ) ); try { AuthenticationResult result = httpAuth.getAuthenticationResult( request, null ); request.setDavSession( new ArchivaDavSession() ); return servletAuth.isAuthenticated( request, result ); } catch ( AuthenticationException e ) { String guest = UserManager.GUEST_USERNAME; try { if ( servletAuth.isAuthorized( guest, ( (ArchivaDavResourceLocator) request.getRequestLocator() ).getRepositoryId(), WebdavMethodUtil.getMethodPermission( request.getMethod() ) ) ) { request.setDavSession( new ArchivaDavSession() ); return true; } } catch ( UnauthorizedException ae ) { throw new UnauthorizedDavException( repositoryId, "You are not authenticated and authorized to access any repository." ); } throw new UnauthorizedDavException( repositoryId, "You are not authenticated." ); } catch ( MustChangePasswordException e ) { throw new UnauthorizedDavException( repositoryId, "You must change your password." ); } catch ( AccountLockedException e ) { throw new UnauthorizedDavException( repositoryId, "User account is locked." ); } } ArchivaDavSessionProvider( ServletAuthenticator servletAuth, HttpAuthenticator httpAuth ); @Override boolean attachSession( WebdavRequest request ); @Override void releaseSession( WebdavRequest request );  }