1

slight changes to package structure + naming

This commit is contained in:
Christoph
2020-03-06 20:10:23 +01:00
parent 64f54ada27
commit 0e1e79d51a
28 changed files with 229 additions and 231 deletions

View 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;
}
}

View 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());
}
}

View File

@ -0,0 +1,10 @@
package mops.gruppen2.service;
import org.springframework.stereotype.Service;
/**
* Übersetzt und baut
*/
@Service
public class SerializationService {
}