slight changes to package structure + naming
This commit is contained in:
16
src/main/java/mops/gruppen2/service/GroupService.java
Normal file
16
src/main/java/mops/gruppen2/service/GroupService.java
Normal file
@ -0,0 +1,16 @@
|
||||
package mops.gruppen2.service;
|
||||
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.event.Event;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class GroupService {
|
||||
|
||||
Group buildGroup(List<Event> eventList){
|
||||
Group newGroup = new Group();
|
||||
eventList.forEach(newGroup::applyEvent);
|
||||
return newGroup;
|
||||
}
|
||||
}
|
||||
27
src/main/java/mops/gruppen2/service/KeyCloakService.java
Normal file
27
src/main/java/mops/gruppen2/service/KeyCloakService.java
Normal file
@ -0,0 +1,27 @@
|
||||
package mops.gruppen2.service;
|
||||
|
||||
import mops.gruppen2.security.Account;
|
||||
import org.keycloak.KeycloakPrincipal;
|
||||
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class KeyCloakService {
|
||||
|
||||
/**
|
||||
* Creates an Account.
|
||||
*
|
||||
* @param token Ein toller token
|
||||
* @return Account with current userdata
|
||||
*/
|
||||
public Account createAccountFromPrincipal(KeycloakAuthenticationToken token) {
|
||||
KeycloakPrincipal principal = (KeycloakPrincipal) token.getPrincipal();
|
||||
return new Account(
|
||||
principal.getName(),
|
||||
principal.getKeycloakSecurityContext().getIdToken().getEmail(),
|
||||
null,
|
||||
principal.getKeycloakSecurityContext().getIdToken().getGivenName(),
|
||||
principal.getKeycloakSecurityContext().getIdToken().getFamilyName(),
|
||||
token.getAccount().getRoles());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package mops.gruppen2.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Übersetzt und baut
|
||||
*/
|
||||
@Service
|
||||
public class SerializationService {
|
||||
}
|
||||
Reference in New Issue
Block a user