This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit 6209ebda authored by Michael Breu's avatar Michael Breu 💬
Browse files

Very raw skeleton of Plugin Interface

parent ad197e0a
1 merge request!17Initial Merge to Prepare Release 1.0.0
......@@ -130,6 +130,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
.csrf()
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
.ignoringAntMatchers("/api/search/**") // Allowing search even without CSRF Token
.ignoringAntMatchers("/api/pluginIF/**") // Allowing plugin Access. security is checked by token
.and()
.authenticationProvider(customJWTauthenticationProvider())
.addFilterBefore(corsFilter, CsrfFilter.class)
......@@ -156,6 +157,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
.authorizeRequests()
.antMatchers("/oauth2/**").permitAll()
.antMatchers("/api/search/**").permitAll() // search is always allowed, may return more data, if authenticated
.antMatchers("/api/pluginIF/**").permitAll() // plugins calls are always allowed, security by tokens
.antMatchers("/api/authenticate").permitAll()
.antMatchers("/api/refreshToken").permitAll()
.antMatchers("/api/register").denyAll()
......
package at.ac.uibk.gitsearch.service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
/**
* Service for exercise/course search results
* <p>
*/
@Service
public class ShoppingBasketService {
public static class ShoppingBasket {
private UserInfo userInfo;
private ExerciseInfo[] exerciseInfo;
public ShoppingBasket(UserInfo userInfo, ExerciseInfo[] exerciseInfo) {
super();
this.userInfo = userInfo;
this.exerciseInfo = exerciseInfo;
}
/**
* @return the userInfo
*/
public UserInfo getUserInfo() {
return userInfo;
}
/**
* @param userInfo the userInfo to set
*/
public void setUserInfo(UserInfo userInfo) {
this.userInfo = userInfo;
}
/**
* @return the exerciseInfo
*/
public ExerciseInfo[] getExerciseInfo() {
return exerciseInfo;
}
/**
* @param exerciseInfo the exerciseInfo to set
*/
public void setExerciseInfo(ExerciseInfo[] exerciseInfo) {
this.exerciseInfo = exerciseInfo;
}
}
public static class UserInfo {
String email;
public UserInfo(String email) {
super();
this.email = email;
}
/**
* @return the email
*/
public String getEmail() {
return email;
}
/**
* @param email the email to set
*/
public void setEmail(String email) {
this.email = email;
}
}
public static class ExerciseInfo {
private String gitLabURI;
private int gitLabProjectId;
private String title;
public ExerciseInfo(String title, int gitLabProjectId, String gitLabURI) {
super();
this.title = title;
this.setGitLabProjectId(gitLabProjectId);
this.gitLabURI = gitLabURI;
}
/**
* @return the title
*/
public String getTitle() {
return title;
}
/**
* @param title the title to set
*/
public void setTitle(String title) {
this.title = title;
}
/**
* @return the gitLabURI
*/
public String getGitLabURI() {
return gitLabURI;
}
/**
* @param gitLabURI the gitLabURI to set
*/
public void setGitLabURI(String gitLabURI) {
this.gitLabURI = gitLabURI;
}
public int getGitLabProjectId() {
return gitLabProjectId;
}
public void setGitLabProjectId(int gitLabProjectId) {
this.gitLabProjectId = gitLabProjectId;
}
}
private final Logger log = LoggerFactory.getLogger(ShoppingBasketService.class);
public ShoppingBasketService() {
}
public ShoppingBasket getBasket(String basketToken) {
final UserInfo userInfo = new UserInfo("Michael.Breu@uibk.ac.at");
final ExerciseInfo exerciseInfo = new ExerciseInfo("JUnit Quality Tests Exercise", 3, "https://sharing.codeability-austria.uibk.ac.at/sharing/university-innsbruck/java/general/junit-quality-tests-exercise.git");
final ShoppingBasket shoppingBasket = new ShoppingBasket(userInfo, new ExerciseInfo[] {exerciseInfo});
return shoppingBasket;
}
}
package at.ac.uibk.gitsearch.web.rest;
import java.io.IOException;
import javax.websocket.server.PathParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import at.ac.uibk.gitsearch.es.model.DocumentInfo;
import at.ac.uibk.gitsearch.service.ShoppingBasketService;
import at.ac.uibk.gitsearch.service.ShoppingBasketService.ShoppingBasket;
/**
* REST controller for managing {@link DocumentInfo}.
*/
@RestController
@RequestMapping("/api")
@Transactional
public class PluginInterfaceResource {
private final Logger log = LoggerFactory.getLogger(PluginInterfaceResource.class);
@Autowired
private ShoppingBasketService basketService;
/**
* {@code SEARCH /search/page-details} : search for the searchResults corresponding
* to the query.
*
* @param query the query of the searchResult search.
* @return the result of the search.
*/
@GetMapping("/pluginIF/getBasket/{basketToken}")
public ShoppingBasket
searchPageDetails(@PathParam("basketToken") String basketToken) throws IOException {
log.debug("REST request for basket {}", basketToken);
return basketService.getBasket(basketToken);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment