- Timestamp:
- 11/24/14 20:38:26 (9 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/UPDATE.txt
r5840 r5850 1 Placing tarball: take the tar-ball of the new version 1.6.1-basic-authentication, and follow the 2 standard MPI deployment procedure. The "current-nonshib" should link to this package. 1 3 2 Placing tarball: take the tar-ball of the new version 1.6.1-shibboleth, and follow the 3 standard MPI deployment procedure.4 No changings are to be done in context.xml and in the data-base because they are the same as 5 for the sibboleth version, abd it works. 4 6 5 Update the dasish annotation database with: 6 INSERT INTO access(access_mode) VALUES ('all'); 7 8 A new feature: an "all" access mode is added. The user with this permission have 9 the same rights as the owner, that it he can update permissions on the annotation 10 and delete it at all. 7 The splitting between logging of shibboleth and basic versions will be implemented in 8 next deployments 11 9 12 10 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/pom.xml
r5840 r5850 5 5 <groupId>eu.dasish.annotation</groupId> 6 6 <artifactId>annotator-backend</artifactId> 7 <version>1.6.1- shibboleth</version>7 <version>1.6.1-basic-authentication</version> 8 8 <packaging>war</packaging> 9 9 <name>annotator-backend Jersey Webapp</name> -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/DBDispatcher.java
r5836 r5850 18 18 package eu.dasish.annotation.backend.dao; 19 19 20 import eu.dasish.annotation.backend.ForbiddenException; 20 21 import eu.dasish.annotation.backend.MatchMode; 21 22 import eu.dasish.annotation.backend.NotInDataBaseException; … … 31 32 import eu.dasish.annotation.schema.NotebookInfoList; 32 33 import eu.dasish.annotation.schema.Access; 33 import eu.dasish.annotation.schema.Action;34 34 import eu.dasish.annotation.schema.PermissionList; 35 35 import eu.dasish.annotation.schema.ReferenceList; … … 226 226 * @return 1 of the annotation if it is updated 227 227 */ 228 int updateAnnotation(Annotation annotation, String remoteUser) throws NotInDataBaseException ;228 int updateAnnotation(Annotation annotation, String remoteUser) throws NotInDataBaseException, ForbiddenException; 229 229 230 230 /** … … 256 256 * annotations_principals_accesss 257 257 */ 258 int update Permissions(Number annotationID, PermissionList permissionList) throws NotInDataBaseException ;258 int updateOrAddPermissions(Number annotationID, PermissionList permissionList) throws NotInDataBaseException ; 259 259 260 260 int updatePublicAttribute(Number annotationID, Access publicAttribute); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/ILambda.java
r5053 r5850 18 18 package eu.dasish.annotation.backend.dao; 19 19 20 import eu.dasish.annotation.backend.ForbiddenException; 20 21 import eu.dasish.annotation.backend.NotInDataBaseException; 21 22 … … 26 27 public interface ILambda<Map, R> { 27 28 28 public R apply(Map params) throws NotInDataBaseException ;29 public R apply(Map params) throws NotInDataBaseException, ForbiddenException; 29 30 30 31 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBDispatcherImlp.java
r5838 r5850 18 18 package eu.dasish.annotation.backend.dao.impl; 19 19 20 import eu.dasish.annotation.backend.ForbiddenException; 20 21 import eu.dasish.annotation.backend.NotInDataBaseException; 21 22 import eu.dasish.annotation.backend.Resource; … … 152 153 153 154 /////////////////////////////////////////////////// 154 155 155 private void fillInPermissionList(List<Permission> listPermissions, Number resourceID, Resource resource) { 156 156 List<Map<Number, String>> principalsAccesss = this.getDao(resource).getPermissions(resourceID); … … 164 164 } 165 165 } 166 166 167 167 @Override 168 168 public PermissionList getPermissions(Number resourceID, Resource resource) { … … 704 704 705 705 @Override 706 public int update Permissions(Number annotationID, PermissionList permissionList) throws NotInDataBaseException {706 public int updateOrAddPermissions(Number annotationID, PermissionList permissionList) throws NotInDataBaseException { 707 707 annotationDao.updatePublicAccess(annotationID, permissionList.getPublic()); 708 708 List<Permission> permissions = permissionList.getPermission(); … … 720 720 return result; 721 721 } 722 722 723 // TODO: optimize (not chnanged targets should not be deleted) 723 // TODO: unit test 724 725 @Override 726 public int updateAnnotation(Annotation annotation, String remoteUser) throws NotInDataBaseException { 724 @Override 725 public int updateAnnotation(Annotation annotation, String remoteUser) throws NotInDataBaseException, ForbiddenException { 726 727 727 Number annotationID = annotationDao.getInternalID(UUID.fromString(annotation.getId())); 728 728 Number ownerID = principalDao.getInternalIDFromHref(annotation.getOwnerHref()); 729 Number remoteUserID = principalDao.getPrincipalInternalIDFromRemoteID(remoteUser); 730 731 boolean isOwner = ownerID.equals(remoteUserID); 732 boolean hasAllAccess = annotationDao.getAccess(annotationID, remoteUserID).equals(Access.ALL); 733 boolean isAdmin = remoteUserID.equals(principalDao.getDBAdminID()); 734 boolean weakPrincipal = (!isOwner && !hasAllAccess && !isAdmin); 735 736 if (weakPrincipal) { // we need to check if permissions are intact 737 if (!(annotation.getPermissions().getPublic()).equals(annotationDao.getPublicAttribute(annotationID))) { 738 throw new ForbiddenException("The inlogged user does not have rights to update 'public' attribute in this annotation."); 739 } 740 List<Map<Number, String>> permissionsDB = annotationDao.getPermissions(annotationID); 741 if (!this.permissionsIntact(annotation.getPermissions().getPermission(), permissionsDB)) { 742 throw new ForbiddenException("The inlogged user does not have rights to update permissions in this annotation."); 743 } 744 } 745 746 729 747 int updatedAnnotations = annotationDao.updateAnnotation(annotation, annotationID, ownerID); 730 748 int deletedTargets = annotationDao.deleteAllAnnotationTarget(annotationID); 731 749 int addedTargets = this.addTargets(annotation, annotationID); 732 733 Number remoteUserID = principalDao.getPrincipalInternalIDFromRemoteID(remoteUser); 734 735 if (ownerID.equals(remoteUserID) || (annotationDao.getAccess(annotationID, remoteUserID).equals(Access.ALL))) { 736 int deletedPrinsipalsAccesss = annotationDao.deletePermissions(annotationID); 737 int addedPrincipalsAccesss = this.addPermissions(annotation.getPermissions().getPermission(), annotationID); 738 739 }; 750 if (!weakPrincipal) { // if weak permissions reach this point then permissions are the same 751 int changedPermissions = this.updateOrAddPermissions(annotationID, annotation.getPermissions()); 752 } 740 753 return updatedAnnotations; 741 754 } 742 755 743 // TODO: unit test 756 private boolean permissionsIntact(List<Permission> permissionsInput, List<Map<Number, String>> permissionsDB) throws NotInDataBaseException{ 757 if (permissionsInput == null || permissionsInput.isEmpty()) { 758 return true; 759 } 760 761 if (permissionsDB == null || permissionsDB.isEmpty()) { 762 return false; 763 } 764 765 for(Permission permission:permissionsInput) { 766 Number principalID = principalDao.getInternalIDFromHref(permission.getPrincipalHref()); 767 String accessLevel = permission.getLevel().value(); 768 Map current = new HashMap<Number, String>(); 769 current.put(principalID, accessLevel); 770 int index = permissionsDB.indexOf(current); 771 if (index>-1) { 772 if (!accessLevel.equals(permissionsDB.get(index).get(principalID))) { 773 return false; 774 } 775 } else { 776 if (!accessLevel.equals(Access.NONE.value())) { 777 return false; 778 } 779 } 780 } 781 return true; 782 } 783 744 784 @Override 745 785 public int updateAnnotationBody(Number internalID, AnnotationBody annotationBody) { -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java
r5836 r5850 314 314 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage()); 315 315 return (new ObjectFactory()).createResponseBody(new ResponseBody()); 316 } catch (ForbiddenException e2) { 317 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, e2.getMessage()); 318 return (new ObjectFactory()).createResponseBody(new ResponseBody()); 316 319 } 317 320 } … … 365 368 private class UpdateAnnotation implements ILambda<Map, ResponseBody> { 366 369 367 @Override 368 public ResponseBody apply(Map params) throws NotInDataBaseException {370 @Override 371 public ResponseBody apply(Map params) throws NotInDataBaseException, ForbiddenException { 369 372 Annotation annotation = (Annotation) params.get("annotation"); 370 373 Number annotationID = (Number) params.get("internalID"); … … 644 647 Number annotationID = (Number) params.get("internalID"); 645 648 PermissionList permissions = (PermissionList) params.get("permissions"); 646 int updatedRows = dbDispatcher.update Permissions(annotationID, permissions);649 int updatedRows = dbDispatcher.updateOrAddPermissions(annotationID, permissions); 647 650 return dbDispatcher.makeAccessResponseEnvelope(annotationID, Resource.ANNOTATION); 648 651 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/PrincipalResource.java
r5684 r5850 83 83 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage()); 84 84 return new ObjectFactory().createPrincipal(new Principal()); 85 } catch (ForbiddenException e2) { 86 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, e2.getMessage()); 87 return new ObjectFactory().createPrincipal(new Principal()); 85 88 } 86 89 } … … 122 125 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage()); 123 126 return new ObjectFactory().createPrincipal(new Principal()); 127 } catch (ForbiddenException e2) { 128 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, e2.getMessage()); 129 return new ObjectFactory().createPrincipal(new Principal()); 124 130 } 125 131 } … … 146 152 } catch (NotInDataBaseException e) { 147 153 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage()); 154 return new ObjectFactory().createCurrentPrincipalInfo(new CurrentPrincipalInfo()); 155 } catch (ForbiddenException e2) { 156 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, e2.getMessage()); 148 157 return new ObjectFactory().createCurrentPrincipalInfo(new CurrentPrincipalInfo()); 149 158 } … … 330 339 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage()); 331 340 return new ObjectFactory().createPrincipal(new Principal()); 341 } catch (ForbiddenException e2) { 342 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, e2.getMessage()); 343 return new ObjectFactory().createPrincipal(new Principal()); 332 344 } 333 345 } else { … … 358 370 Map params = new HashMap<String, Object>(); 359 371 params.put("newPrincipal", newPrincipal); 360 Principal result = (Principal) (new RequestWrappers(this)).wrapRequestResource(params, new UpdatePrincipal()); 361 return (result != null) ? (new ObjectFactory().createPrincipal(result)) : (new ObjectFactory().createPrincipal(new Principal())); 372 try { 373 Principal result = (Principal) (new RequestWrappers(this)).wrapRequestResource(params, new UpdatePrincipal()); 374 return (result != null) ? (new ObjectFactory().createPrincipal(result)) : (new ObjectFactory().createPrincipal(new Principal())); 375 } catch (ForbiddenException e2) { 376 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, e2.getMessage()); 377 return new ObjectFactory().createPrincipal(new Principal()); 378 } 362 379 } 363 380 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/RequestWrappers.java
r5840 r5850 52 52 } 53 53 54 public T wrapRequestResource(Map params, ILambda<Map, T> dbRequestor) throws IOException, NotInDataBaseException {54 public T wrapRequestResource(Map params, ILambda<Map, T> dbRequestor) throws IOException, NotInDataBaseException, ForbiddenException { 55 55 Number remotePrincipalID = resourceResource.getPrincipalID(); 56 56 if (remotePrincipalID == null) { -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/WEB-INF/shhaa.xml
r5840 r5850 38 38 <username>anonymous</username> 39 39 </fallback> 40 <sso action="lI">https://lux1 6.mpi.nl/Shibboleth.sso/Login</sso>41 <slo action="lO">https://lux1 6.mpi.nl/Shibboleth.sso/Logout</slo>40 <sso action="lI">https://lux17.mpi.nl/Shibboleth.sso/Login</sso> 41 <slo action="lO">https://lux17.mpi.nl/Shibboleth.sso/Logout</slo> 42 42 </authentication> 43 43 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/WEB-INF/web.xml
r5840 r5850 40 40 <context-param> 41 41 <param-name>eu.dasish.annotation.backend.isShibbolethSession</param-name> 42 <param-value> true</param-value>42 <param-value>false</param-value> 43 43 </context-param> 44 44 <context-param> … … 48 48 <context-param> 49 49 <param-name>eu.dasish.annotation.backend.logout.shibboleth</param-name> 50 <param-value>https://lux1 6.mpi.nl/Shibboleth.sso/Logout</param-value>50 <param-value>https://lux17.mpi.nl/Shibboleth.sso/Logout</param-value> 51 51 </context-param> 52 52 … … 111 111 112 112 <!-- Spring security --> 113 < !-- <filter>113 <filter> 114 114 <filter-name>springSecurityFilterChain</filter-name> 115 115 <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> … … 118 118 <filter-name>springSecurityFilterChain</filter-name> 119 119 <url-pattern>/*</url-pattern> 120 </filter-mapping> -->120 </filter-mapping> 121 121 122 122 <!-- Shibboleth filter --> 123 < filter>123 <!-- <filter> 124 124 <filter-name>AAIFilter</filter-name> 125 125 <filter-class>de.mpg.aai.shhaa.AuthFilter</filter-class> … … 128 128 <filter-name>AAIFilter</filter-name> 129 129 <url-pattern>/*</url-pattern> 130 </filter-mapping> 130 </filter-mapping> --> 131 131 132 132 </web-app> -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/DBDispatcherTest.java
r5838 r5850 18 18 package eu.dasish.annotation.backend.dao.impl; 19 19 20 import eu.dasish.annotation.backend.ForbiddenException; 20 21 import eu.dasish.annotation.backend.Helpers; 21 22 import eu.dasish.annotation.backend.MatchMode; … … 2089 2090 // } 2090 2091 @Test 2091 public void testUpdateAnnotation() throws NotInDataBaseException {2092 public void testUpdateAnnotation() throws NotInDataBaseException, ForbiddenException { 2092 2093 2093 2094 System.out.println("test updateAnnotation"); … … 2107 2108 oneOf(principalDao).getInternalIDFromHref(annotation.getOwnerHref()); 2108 2109 will(returnValue(1)); 2109 2110 2111 oneOf(annotationDao).getAccess(1,1); 2112 will(returnValue(Access.NONE)); 2113 2114 oneOf(principalDao).getDBAdminID(); 2115 will(returnValue(3)); 2116 2110 2117 oneOf(annotationDao).updateAnnotation(annotation, 1, 1); 2111 2118 will(returnValue(1)); … … 2113 2120 oneOf(annotationDao).deleteAllAnnotationTarget(1); 2114 2121 will(returnValue(1)); 2115 2116 oneOf(annotationDao).deletePermissions(1);2117 will(returnValue(3));2118 2119 2122 2120 2123 /// adding the first target, not found in the DB … … 2145 2148 2146 2149 ///// 2150 2151 oneOf(annotationDao).updatePublicAccess(1, Access.WRITE); 2152 will(returnValue(1)); 2153 2147 2154 oneOf(principalDao).getInternalIDFromHref(permissions.getPermission().get(0).getPrincipalHref()); 2148 2155 will(returnValue(2)); 2149 2150 oneOf(annotationDao).addPermission(1, 2, Access.WRITE); 2156 2157 oneOf(annotationDao).hasExplicitAccess(1, 2); 2158 will(returnValue(true)); 2159 2160 oneOf(annotationDao).updatePermission(1, 2, Access.WRITE); 2151 2161 will(returnValue(1)); 2152 2162 2153 2163 oneOf(principalDao).getInternalIDFromHref(permissions.getPermission().get(1).getPrincipalHref()); 2154 2164 will(returnValue(3)); 2155 2156 oneOf(annotationDao).addPermission(1, 3, Access.READ); 2165 2166 oneOf(annotationDao).hasExplicitAccess(1, 3); 2167 will(returnValue(true)); 2168 2169 oneOf(annotationDao).updatePermission(1, 3, Access.READ); 2157 2170 will(returnValue(1)); 2158 2171 … … 2284 2297 }); 2285 2298 2286 assertEquals(3, dbDispatcher.update Permissions(1, permissions));2299 assertEquals(3, dbDispatcher.updateOrAddPermissions(1, permissions)); 2287 2300 2288 2301 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java
r5836 r5850 18 18 package eu.dasish.annotation.backend.rest; 19 19 20 import eu.dasish.annotation.backend.ForbiddenException; 20 21 import eu.dasish.annotation.backend.Helpers; 21 22 import eu.dasish.annotation.backend.NotInDataBaseException; … … 231 232 232 233 @Test 233 public void testUpdateAnnotation() throws NotInDataBaseException, IOException {234 public void testUpdateAnnotation() throws NotInDataBaseException, IOException, ForbiddenException{ 234 235 System.out.println("test updateAnnotation"); 235 236 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationsTest.java
r5838 r5850 255 255 assertEquals("updated annotation 1", entityA.getHeadline()); 256 256 assertEquals(3, entityA.getPermissions().getPermission().size()); 257 // assertEquals(Access.READ, entityA.getPermissions().getPublic()); 257 assertEquals(Access.READ, entityA.getPermissions().getPublic()); 258 assertEquals(Access.WRITE, entityA.getPermissions().getPermission().get(0).getLevel()); 259 assertEquals(Access.WRITE, entityA.getPermissions().getPermission().get(1).getLevel()); 260 assertEquals(Access.READ, entityA.getPermissions().getPermission().get(2).getLevel()); 258 261 // assertEquals(_relativePath + "/principals/00000000-0000-0000-0000-000000000111", entityA.getOwnerHref()); 259 262 // assertEquals("http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia#de_Opdracht", entityA.getTargets().getTargetInfo().get(0).getLink()); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/resources/test-data/InsertTestData.sql
r5838 r5850 105 105 106 106 107 ---- ACCESS S--------------------------------------------------------------------------------------------107 ---- ACCESS-------------------------------------------------------------------------------------------- 108 108 109 109
Note: See TracChangeset
for help on using the changeset viewer.