Changeset 5014
- Timestamp:
- 04/17/14 17:52:56 (10 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend
- Files:
-
- 3 added
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/pom.xml
r4985 r5014 26 26 <version>2.5</version> 27 27 <scope>provided</scope> 28 </dependency> 28 </dependency> 29 <!-- <dependency> 30 <groupId>com.sun.jersey</groupId> 31 <artifactId>jersey-server-linking</artifactId> 32 <version>1.9.1</version> 33 </dependency> --> 29 34 <dependency> 30 35 <groupId>com.sun.jersey</groupId> -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/PrincipalResource.java
r4995 r5014 32 32 import javax.ws.rs.Consumes; 33 33 import javax.ws.rs.DELETE; 34 import javax.ws.rs.FormParam; 34 35 import javax.ws.rs.GET; 35 36 import javax.ws.rs.POST; … … 54 55 public class PrincipalResource extends ResourceResource { 55 56 57 int shaStrength = 512; 58 56 59 public void setHttpRequest(HttpServletRequest request) { 57 60 this.httpServletRequest = request; … … 96 99 @GET 97 100 @Produces(MediaType.TEXT_XML) 98 @Path(" /info")101 @Path("info") 99 102 @Transactional(readOnly = true) 100 103 public JAXBElement<Principal> getPrincipalByInfo(@QueryParam("email") String email) throws IOException { … … 141 144 @Path("create/{remoteId}/{password}") 142 145 public String createSpringAuthenticationRecord(@PathParam("remoteId") String remoteId, @PathParam("password") String password) throws IOException { 143 int result = dbIntegrityService.addSpringUser(remoteId, password, 512, remoteId); 144 return result+ " record(s) has been added. Must be 2: 1 record for the principal, another for the authorities table."; 146 Number remotePrincipalID = this.getPrincipalID(); 147 if (remotePrincipalID == null) { 148 return "Logged in principal is null or anonymous."; 149 } 150 151 if (dbIntegrityService.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) { 152 int result = dbIntegrityService.addSpringUser(remoteId, password, shaStrength, remoteId); 153 return result + " record(s) has been added. Must be 2: 1 record for the principal, another for the authorities table."; 154 } else { 155 verboseOutput.ADMIN_RIGHTS_EXPECTED(); 156 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN); 157 return "Nothing is added."; 158 } 159 145 160 } 146 161 … … 175 190 return new ObjectFactory().createPrincipal(new Principal()); 176 191 } 192 193 } 194 195 @POST 196 @Consumes(MediaType.APPLICATION_FORM_URLENCODED) 197 @Produces(MediaType.APPLICATION_XML) 198 @Path("register/nonshibboleth") 199 public JAXBElement<Principal> registerNonShibbolizedPrincipal(@FormParam("name") String name, 200 @FormParam("remoteId") String remoteId, @FormParam("password") String passowrd, @FormParam("email") String email) 201 throws IOException { 202 dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString()); 203 Principal newPrincipal = new Principal(); 204 newPrincipal.setDisplayName(name); 205 newPrincipal.setEMail(email); 206 try { 207 try { 208 final int updatedSpringTables = dbIntegrityService.addSpringUser(remoteId, passowrd, shaStrength, remoteId); 209 final Number principalID = dbIntegrityService.addPrincipal(newPrincipal, remoteId); 210 final Principal addedPrincipal = dbIntegrityService.getPrincipal(principalID); 211 return new ObjectFactory().createPrincipal(addedPrincipal); 212 } catch (NotInDataBaseException e1) { 213 loggerServer.debug(e1.toString()); 214 httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e1.toString()); 215 return new ObjectFactory().createPrincipal(new Principal()); 216 } 217 } catch (PrincipalExists e) { 218 loggerServer.debug(e.toString()); 219 httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString()); 220 return new ObjectFactory().createPrincipal(new Principal()); 221 } 222 223 } 224 225 @POST 226 @Consumes(MediaType.APPLICATION_FORM_URLENCODED) 227 @Produces(MediaType.APPLICATION_XML) 228 @Path("register/shibboleth") 229 public JAXBElement<Principal> registerShibbolizedPrincipal(@FormParam("name") String name, 230 @FormParam("remoteId") String remoteId, @FormParam("email") String email) 231 throws IOException { 232 dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString()); 233 Principal newPrincipal = new Principal(); 234 newPrincipal.setDisplayName(name); 235 newPrincipal.setEMail(email); 236 try { 237 try { 238 final Number principalID = dbIntegrityService.addPrincipal(newPrincipal, remoteId); 239 final Principal addedPrincipal = dbIntegrityService.getPrincipal(principalID); 240 return new ObjectFactory().createPrincipal(addedPrincipal); 241 } catch (NotInDataBaseException e1) { 242 loggerServer.debug(e1.toString()); 243 httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e1.toString()); 244 return new ObjectFactory().createPrincipal(new Principal()); 245 } 246 } catch (PrincipalExists e) { 247 loggerServer.debug(e.toString()); 248 httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString()); 249 return new ObjectFactory().createPrincipal(new Principal()); 250 } 251 } 252 253 @POST 254 @Consumes(MediaType.APPLICATION_FORM_URLENCODED) 255 @Produces(MediaType.TEXT_PLAIN) 256 @Path("register/shibbolethasnonshibboleth") 257 public String registerShibbolizedPrincipalAsNonShibb(@FormParam("remoteId") String remoteId, @FormParam("password") String password) 258 throws IOException { 259 int result = dbIntegrityService.addSpringUser(remoteId, password, shaStrength, remoteId); 260 return result + " record(s) has been added. Must be 2: 1 record for the principal, another for the authorities table."; 177 261 178 262 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/error.jsp
r4997 r5014 25 25 <body> 26 26 Authentication error. Check username and password. <br> 27 <a href=" index.jsp"> To DWAN's test jsp page.</a><br>28 <a href=" loginform.jsp"> To DWAN's login jsp page.</a>27 <a href="api/.."> To DWAN's test jsp page.</a><br> 28 <a href="api/authentication/login"> To DWAN's login.</a> 29 29 </body> 30 30 </html> -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/index.jsp
r4997 r5014 24 24 <p><a href="https://trac.clarin.eu/wiki/DASISH/SpecificationDocument#RESTAPI">https://trac.clarin.eu/wiki/DASISH/SpecificationDocument#RESTAPI</a></p> 25 25 26 <!-- <br> 27 <a href="createprincipal.jsp"> create principal record</a> <br> 28 <br> --> 26 <br> 27 <a href="registerNonShibbolethPrincipal.html"> Register a non-shibboleth user</a> <br> 28 <br> 29 <a href="registerShibbolethPrincipal.html"> Register a shibboleth user</a> <br> 30 <br> 31 <a href="registerShibbolethAlsoAsNonShibboleth.html"> Register an existing shibboleth user as a non-shibboleth as well.</a> <br> 32 <br> 33 <br> 29 34 <a href="api/authentication/login"> login </a> <br> 30 35 <br> … … 33 38 34 39 <b>Test URI-s</b><br> 40 <br> 35 41 <b>All output xml-s are valid w.r.t. the schema</b><br> 36 42 GET <a href="api/authentication/principal">api/authentication/principal</a> <br> -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/loginform.jsp
r4997 r5014 33 33 <table> 34 34 <tr> 35 <td> User:</td>35 <td>Login:</td> 36 36 <td><input type='text' name='username' value=''></td> 37 37 </tr> -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/logout.jsp
r4997 r5014 25 25 <body> 26 26 You are logged out.<br> 27 <a href=" index.jsp"> To DWAN's test jsppage.</a>27 <a href="api/.."> To DWAN's main test page.</a> 28 28 </body> 29 29 </html>
Note: See TracChangeset
for help on using the changeset viewer.