Changeset 4671
- Timestamp:
- 03/12/14 15:56:47 (10 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend
- Files:
-
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/pom.xml
r4670 r4671 129 129 <groupId>de.mpg.mpgaai</groupId> 130 130 <artifactId>mpgaai-shhaa</artifactId> 131 <version> 1.0.3</version>131 <version>${shibboleth.version}</version> 132 132 <exclusions> 133 133 <exclusion> … … 328 328 <plugin.license.copyrightYear>2013</plugin.license.copyrightYear> 329 329 <project.version>1.3</project.version> 330 <shibboleth.version>1.0.4</shibboleth.version> 330 331 </properties> 331 332 333 <repositories> 334 <repository> 335 <id>MPI</id> 336 <name>MPI LAT Repository/</name> 337 <url>http://lux15.mpi.nl/nexus/content/groups/public</url> 338 </repository> 339 <repository> 340 <id>MPI-Snapshot</id> 341 <name>MPI LAT Repository/</name> 342 <url>http://lux15.mpi.nl/nexus/content/repositories/MPI-Snapshots</url> 343 </repository> 344 </repositories> 345 332 346 333 347 </project> -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AutheticationResource.java
r4670 r4671 23 23 import java.sql.SQLException; 24 24 import javax.servlet.ServletException; 25 import javax.servlet.http.HttpServletRequestWrapper;26 25 import javax.ws.rs.GET; 27 26 import javax.ws.rs.Path; 28 27 import javax.ws.rs.Produces; 28 import javax.ws.rs.core.Context; 29 29 import javax.ws.rs.core.MediaType; 30 30 import javax.xml.bind.JAXBElement; … … 41 41 @Transactional(rollbackFor = {Exception.class, SQLException.class, IOException.class, ParserConfigurationException.class}) 42 42 public class AutheticationResource extends ResourceResource { 43 43 44 44 45 @GET 45 46 @Produces(MediaType.TEXT_XML) … … 62 63 @Transactional(readOnly = true) 63 64 public JAXBElement<User> loginAndGet() throws IOException { 65 dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString()); 64 66 String remoteUser = httpServletRequest.getRemoteUser(); 65 67 verboseOutput = new VerboseOutput(httpServletResponse, loggerServer); 66 68 if (remoteUser != null) { 67 if (!remoteUser.equals("anonymous")) { 68 dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString()); 69 if (!remoteUser.equals("anonymous")) { 69 70 final Number remoteUserID = dbIntegrityService.getUserInternalIDFromRemoteID(remoteUser); 70 71 if (remoteUserID != null) { … … 85 86 @Transactional(readOnly = true) 86 87 public void logout() throws IOException, ServletException { 87 httpServletResponse.sendRedirect( "eu.dasish.annotation.backend.logout");88 httpServletResponse.sendRedirect(context.getInitParameter("eu.dasish.annotation.backend.logout")); 88 89 } 89 90 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/CachedRepresentationResource.java
r4615 r4671 20 20 import eu.dasish.annotation.backend.BackendConstants; 21 21 import eu.dasish.annotation.backend.Resource; 22 import eu.dasish.annotation.backend.dao.DBIntegrityService;23 22 import eu.dasish.annotation.schema.CachedRepresentationInfo; 24 23 import eu.dasish.annotation.schema.ObjectFactory; … … 30 29 import javax.imageio.ImageIO; 31 30 import javax.servlet.http.HttpServletRequest; 32 import javax.servlet.http.HttpServletResponse;33 31 import javax.ws.rs.GET; 34 32 import javax.ws.rs.Path; 35 33 import javax.ws.rs.PathParam; 36 34 import javax.ws.rs.Produces; 37 import javax.ws.rs.core.Context;38 35 import javax.ws.rs.core.MediaType; 39 import javax.ws.rs.core.UriInfo;40 36 import javax.xml.bind.JAXBElement; 41 37 import javax.xml.parsers.ParserConfigurationException; 42 import org.slf4j.Logger;43 import org.slf4j.LoggerFactory;44 import org.springframework.beans.factory.annotation.Autowired;45 38 import org.springframework.stereotype.Component; 46 39 import org.springframework.transaction.annotation.Transactional; … … 94 87 if (cachedID != null) { 95 88 InputStream dbRespond = dbIntegrityService.getCachedRepresentationBlob(cachedID); 96 ImageIO.setUseCache(false); 97 BufferedImage result = ImageIO.read(dbRespond); 98 return result; 89 if (dbRespond != null) { 90 ImageIO.setUseCache(false); 91 BufferedImage result = ImageIO.read(dbRespond); 92 return result; 93 } else { 94 verboseOutput.CACHED_REPRESENTATION_IS_NULL(); 95 } 99 96 } else { 100 97 verboseOutput.CACHED_REPRESENTATION_NOT_FOUND(externalId); … … 103 100 verboseOutput.ILLEGAL_UUID(externalId); 104 101 } 105 } 106 return n ull;102 } 103 return new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB); 107 104 } 108 105 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/JaxbMarshallerFactory.java
r4603 r4671 32 32 private JAXBContext context; 33 33 private Marshaller marshaller; 34 // overwritten by the context.xml's 34 // overwritten by the web.xml's 35 // why?? 35 36 private String schemaLocation = "http://www.dasish.eu/ns/addit file:/Users/olhsha/repositories/DASISH/t5.6/schema/trunk/annotator-schema/src/main/target/DASISH-schema.xsd"; 36 37 … … 48 49 49 50 public Marshaller createMarshaller(Class<?> type) throws JAXBException{ 50 context = JAXBContext.newInstance(type); 51 context = JAXBContext.newInstance(type); 51 52 marshaller = context.createMarshaller(); 52 53 marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, schemaLocation); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/ResourceResource.java
r4670 r4671 52 52 protected String admin = "admin"; 53 53 protected String anonym = "anonymous"; 54 54 55 55 public Number getUserID() throws IOException { 56 dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString()); 56 57 verboseOutput = new VerboseOutput(httpServletResponse, loggerServer); 57 String remoteUser = httpServletRequest.getRemoteUser(); 58 String remoteUser = httpServletRequest.getRemoteUser(); 58 59 if (remoteUser != null) { 59 60 if (!remoteUser.equals(anonym)) { … … 61 62 if (userID != null) { 62 63 return userID; 63 } 64 verboseOutput.REMOTE_PRINCIPAL_NOT_FOUND(remoteUser, dbIntegrityService.getDataBaseAdmin().getDisplayName(), dbIntegrityService.getDataBaseAdmin().getEMail());64 } 65 verboseOutput.REMOTE_PRINCIPAL_NOT_FOUND(remoteUser, dbIntegrityService.getDataBaseAdmin().getDisplayName(), dbIntegrityService.getDataBaseAdmin().getEMail()); 65 66 return null; 66 67 } … … 71 72 72 73 } 73 74 75 74 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/VerboseOutput.java
r4670 r4671 48 48 49 49 private MessageStatus _NOT_LOGGED_IN(String adminName, String adminEmail) { 50 return new MessageStatus(" The user is not logged-in or its remote login is corrupted by setting to null. In the latter case contact the admin " +adminName+" via the e-mail "+adminEmail, HttpServletResponse.SC_UNAUTHORIZED);50 return new MessageStatus(" The user is not logged-in or its remote login is corrupted by setting to null. In the latter case contact the admin " + adminName + " via the e-mail " + adminEmail, HttpServletResponse.SC_UNAUTHORIZED); 51 51 } 52 52 53 53 private MessageStatus _FORBIDDEN_RESOURCE_ACTION(String identifier, String resource, String action, String ownerName, String ownerEMail) { 54 return new MessageStatus(" The logged-in principal cannot "+action+" the "+resource+" with the identifier " + identifier+ ". Contact the resource's owner "+ownerName+" via the e-mail "+ownerEMail, HttpServletResponse.SC_FORBIDDEN); 55 } 56 54 return new MessageStatus(" The logged-in principal cannot " + action + " the " + resource + " with the identifier " + identifier + ". Contact the resource's owner " + ownerName + " via the e-mail " + ownerEMail, HttpServletResponse.SC_FORBIDDEN); 55 } 57 56 58 57 private MessageStatus _ILLEGAL_UUID(String identifier) { … … 61 60 62 61 private MessageStatus _REMOTE_PRINCIPAL_NOT_FOUND(String remoteID, String adminName, String adminEmail) { 63 return new MessageStatus("The logged in principal with the remote ID " + remoteID + " is not found in the database or his/her internal DB identifier is corrupted by setting to null. Contact the database admin " +adminName+" by the e-mail "+adminEmail, HttpServletResponse.SC_NOT_FOUND);62 return new MessageStatus("The logged in principal with the remote ID " + remoteID + " is not found in the database or his/her internal DB identifier is corrupted by setting to null. Contact the database admin " + adminName + " by the e-mail " + adminEmail, HttpServletResponse.SC_NOT_FOUND); 64 63 } 65 64 … … 68 67 } 69 68 70 71 69 private MessageStatus _PRINCIPAL_NOT_FOUND(String externalIdentifier) { 72 70 return resourceNotFound(externalIdentifier, "principal"); … … 89 87 } 90 88 89 private MessageStatus _CACHED_REPRESENTATION_IS_NULL() { 90 return new MessageStatus("The cached representation with the give ID exist in the DB, however its BLOB is null.", HttpServletResponse.SC_NO_CONTENT); 91 92 } 93 91 94 private MessageStatus _INVALID_PERMISSION_MODE(String permissionMode) { 92 95 return new MessageStatus(permissionMode + " is an invalid permission value, which must be either owner, or reader, or writer.", HttpServletResponse.SC_BAD_REQUEST); … … 98 101 99 102 private MessageStatus _ADMIN_RIGHTS_EXPECTED(String adminName, String adminEmail) { 100 return new MessageStatus("The request can be performed only by the principal with the admin rights. Contact the admin " +adminName+" via e-mail "+adminEmail, HttpServletResponse.SC_FORBIDDEN);103 return new MessageStatus("The request can be performed only by the principal with the admin rights. Contact the admin " + adminName + " via e-mail " + adminEmail, HttpServletResponse.SC_FORBIDDEN); 101 104 } 102 105 … … 116 119 return new MessageStatus("The account is not updated", HttpServletResponse.SC_INTERNAL_SERVER_ERROR); 117 120 } 118 121 119 122 private MessageStatus _LOGOUT() { 120 123 return new MessageStatus("You are logged out.", HttpServletResponse.SC_UNAUTHORIZED); 121 124 } 122 125 123 126 private MessageStatus _ANONYMOUS_PRINCIPAL() { 124 127 return new MessageStatus("Shibboleth fall-back. Logged in as 'anonymous' with no rights.", HttpServletResponse.SC_UNAUTHORIZED); … … 140 143 141 144 public void FORBIDDEN_NOTEBOOK_WRITING(String identifier, String ownerName, String ownerEMail) throws IOException { 142 145 this.sendMessage(this._FORBIDDEN_RESOURCE_ACTION(identifier, "notebook", "write", ownerName, ownerEMail)); 143 146 } 144 147 145 148 public void FORBIDDEN_ANNOTATION_READING(String identifier, String ownerName, String ownerEMail) throws IOException { 146 149 this.sendMessage(this._FORBIDDEN_RESOURCE_ACTION(identifier, "annotation", "read", ownerName, ownerEMail));; 147 150 } 148 151 149 152 public void FORBIDDEN_ANNOTATION_WRITING(String identifier, String ownerName, String ownerEMail) throws IOException { 150 153 this.sendMessage(this._FORBIDDEN_RESOURCE_ACTION(identifier, "annotation", "write", ownerName, ownerEMail)); 151 154 } 152 155 153 156 public void FORBIDDEN_PERMISSION_CHANGING(String identifier, String ownerName, String ownerEMail) throws IOException { 154 this.sendMessage(this._FORBIDDEN_RESOURCE_ACTION(identifier, "resource","change", ownerName, ownerEMail));157 this.sendMessage(this._FORBIDDEN_RESOURCE_ACTION(identifier, "resource", "change", ownerName, ownerEMail)); 155 158 } 156 159 … … 183 186 } 184 187 188 public void CACHED_REPRESENTATION_IS_NULL() throws IOException { 189 this.sendMessage(this._CACHED_REPRESENTATION_IS_NULL()); 190 } 191 185 192 public void INVALID_PERMISSION_MODE(String permissionMode) throws IOException { 186 193 this.sendMessage(this._INVALID_PERMISSION_MODE(permissionMode)); … … 210 217 this.sendMessage(this._ACCOUNT_IS_NOT_UPDATED()); 211 218 } 212 219 213 220 public void LOGOUT() throws IOException { 214 221 this.sendMessage(this._LOGOUT()); 215 222 } 216 223 217 224 public void ANONYMOUS_PRINCIPAL() throws IOException { 218 225 this.sendMessage(this._ANONYMOUS_PRINCIPAL()); 219 226 } 220 221 227 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/WEB-INF/shhaa.xml
r4670 r4671 21 21 <ROOT> 22 22 <shhaa> 23 24 <!-- <webapp>25 <host>http://localhost:8080</host>26 <context>/annotator-backend</context>27 </webapp>-->28 29 23 <authentication> 30 24 <shibheader> … … 45 39 </fallback> 46 40 <sso action="lI">https://lux16.mpi.nl/Shibboleth.sso/Login</sso> 47 <slo action="lO"> eu.dasish.annotation.backend.logout</slo>41 <slo action="lO">https://lux16.mpi.nl/Shibboleth.sso/Logout</slo> 48 42 </authentication> 49 43 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/WEB-INF/web.xml
r4670 r4671 81 81 </servlet-mapping> 82 82 83 <!--<security-constraint>83 <security-constraint> 84 84 <display-name>Protected backend localhost</display-name> 85 85 <web-resource-collection> … … 104 104 <role-name>tomcat</role-name> 105 105 </security-role> 106 -->107 < filter>106 107 <!-- <filter> 108 108 <filter-name>AAIFilter</filter-name> 109 109 <filter-class>de.mpg.aai.shhaa.AuthFilter</filter-class> … … 112 112 <filter-name>AAIFilter</filter-name> 113 113 <url-pattern>/*</url-pattern> 114 </filter-mapping> 114 </filter-mapping> --> 115 115 116 116 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java
r4670 r4671 77 77 public AnnotationResourceTest() { 78 78 mockRequest = new MockHttpServletRequest(); 79 80 79 } 81 80 81 82 // public Number getUserID() throws IOException { 83 // dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString()); 84 // verboseOutput = new VerboseOutput(httpServletResponse, loggerServer); 85 // String remoteUser = httpServletRequest.getRemoteUser(); 86 // if (remoteUser != null) { 87 // if (!remoteUser.equals(anonym)) { 88 // final Number userID = dbIntegrityService.getUserInternalIDFromRemoteID(remoteUser); 89 // if (userID != null) { 90 // return userID; 91 // } 92 // verboseOutput.REMOTE_PRINCIPAL_NOT_FOUND(remoteUser, dbIntegrityService.getDataBaseAdmin().getDisplayName(), dbIntegrityService.getDataBaseAdmin().getEMail()); 93 // return null; 94 // } 95 // } 96 // 97 // verboseOutput.NOT_LOGGED_IN(dbIntegrityService.getDataBaseAdmin().getDisplayName(), dbIntegrityService.getDataBaseAdmin().getEMail()); 98 // return null; 99 // 100 // } 82 101 83 102 @Test … … 89 108 annotationResource.setUriInfo(mockUriInfo); 90 109 mockRequest.setRemoteUser("olhsha@mpi.nl"); 110 111 final URI baseUri = URI.create(TestBackendConstants._TEST_SERVLET_URI); 91 112 92 113 mockeryRest.checking(new Expectations() { 93 114 { 94 115 oneOf(mockUriInfo).getBaseUri(); 116 will(returnValue(baseUri)); 117 118 oneOf(mockDbIntegrityService).setServiceURI(baseUri.toString()); 119 95 120 oneOf(mockDbIntegrityService).getUserInternalIDFromRemoteID("olhsha@mpi.nl"); 96 121 will(returnValue(3)); … … 130 155 mockRequest.setRemoteUser("olhsha@mpi.nl"); 131 156 157 final URI baseUri = URI.create(TestBackendConstants._TEST_SERVLET_URI); 158 132 159 133 160 mockeryRest.checking(new Expectations() { 134 161 { 135 162 oneOf(mockUriInfo).getBaseUri(); 163 will(returnValue(baseUri)); 164 165 oneOf(mockDbIntegrityService).setServiceURI(baseUri.toString()); 166 136 167 oneOf(mockDbIntegrityService).getUserInternalIDFromRemoteID("olhsha@mpi.nl"); 137 168 will(returnValue(3)); … … 203 234 annotationResource.setUriInfo(mockUriInfo); 204 235 mockRequest.setRemoteUser("olhsha@mpi.nl"); 205 236 final URI baseUri = URI.create(TestBackendConstants._TEST_SERVLET_URI); 237 206 238 207 239 mockeryRest.checking(new Expectations() { 208 240 { 209 241 oneOf(mockUriInfo).getBaseUri(); 242 will(returnValue(baseUri)); 243 244 oneOf(mockDbIntegrityService).setServiceURI(baseUri.toString()); 245 210 246 oneOf(mockDbIntegrityService).getUserInternalIDFromRemoteID("olhsha@mpi.nl"); 211 247 will(returnValue(3)); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationsTest.java
r4670 r4671 111 111 */ 112 112 @Test 113 @Ignore114 113 public void testGetAnnotation() throws SQLException, DatatypeConfigurationException { 115 114 … … 155 154 */ 156 155 @Test 157 @Ignore158 156 public void testDeleteAnnotation() throws SQLException { 159 157 … … 181 179 */ 182 180 @Test 183 @Ignore184 181 public void testCreateAnnotation() throws SQLException, InstantiationException, IllegalAccessException, DatatypeConfigurationException, Exception { 185 182
Note: See TracChangeset
for help on using the changeset viewer.