Package com.infoclinika.mssharing.model.internal.entity

Examples of com.infoclinika.mssharing.model.internal.entity.RestToken


        this.passwordEncoder = passwordEncoder;
    }

    @Override
    public void updateToken(Token token) {
        RestToken restToken = restTokenRepository.findOne(token.id);
        restToken.setExpirationDate(new Date(new Date().getTime() + RestHelper.TOKEN_EXPIRATION_TIME));
        restTokenRepository.save(restToken);
    }
View Full Code Here


        restTokenRepository.save(restToken);
    }

    @Override
    public void invalidateToken(Token token) {
        RestToken restToken = restTokenRepository.findOne(token.id);
        restToken.setExpirationDate(null);
        restTokenRepository.save(restToken);
    }
View Full Code Here

    public UserDetails getUserDetailsByEmail(String email) {
        User user = userRepository.findByEmail(email);
        if (user == null) {
            return null;
        }
        RestToken restToken = user.getRestToken();
        return new UserDetails(
                user.getId(),
                user.getEmail(),
                user.getPasswordHash(),
                restToken != null ?
                        new Token(restToken.getId(),
                                restToken.getToken(),
                                restToken.getExpirationDate())
                        : null,
                user.isEmailVerified(),
                user.getLabs().size() > 0
        );
    }
View Full Code Here

        );
    }

    @Override
    public UserDetails checkToken(String token) {
        RestToken restToken = restTokenRepository.findByToken(token);
        if(restToken == null || restToken.getExpirationDate().compareTo(new Date()) <= 0){
            return null;
        }
        User user = userRepository.findOne(restToken.getId());
        if(user == null){
            return null;
        }
        return new UserDetails(
                user.getId(),
                user.getEmail(),
                user.getPasswordHash(),
                new Token(restToken.getId(),
                        restToken.getToken(),
                        restToken.getExpirationDate()),
                user.isEmailVerified(),
                user.getLabs().size() > 0
        );
    }
View Full Code Here

    @Override
    public Token generateToken(UserDetails userDetails) {
        String rawString = userDetails.email + new Date().toString() + userDetails.passwordHash + userDetails.id;
        String token = passwordEncoder.encode(rawString);
        Date expirationDate = new Date(new Date().getTime() + RestHelper.TOKEN_EXPIRATION_TIME);
        RestToken restToken =
                new RestToken(userDetails.id, token, expirationDate);
        restTokenRepository.save(restToken);
        return new Token(restToken.getId(), restToken.getToken(), restToken.getExpirationDate());
    }
View Full Code Here

        return new Token(restToken.getId(), restToken.getToken(), restToken.getExpirationDate());
    }

    @Override
    public UserDetails getUserDetailsByToken(String token) {
        RestToken restToken = restTokenRepository.findByToken(token);
        if (restToken == null) {
            return null;
        }
        User user = userRepository.findOne(restToken.getId());
        if (user == null) {
            return null;
        }
        return new UserDetails(
                user.getId(),
                user.getEmail(),
                user.getPasswordHash(),
                new Token(restToken.getId(),
                        restToken.getToken(),
                        restToken.getExpirationDate()),
                user.isEmailVerified(),
                user.getLabs().size() > 0
        );
    }
View Full Code Here

TOP

Related Classes of com.infoclinika.mssharing.model.internal.entity.RestToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.