Search in sources :

Example 1 with UserProfileDTO

use of com.wso2telco.core.userprofile.dto.UserProfileDTO in project core-util by WSO2Telco.

the class JSessionAuthenticationFilter method isAuthenticated.

@Override
public boolean isAuthenticated(ContainerRequestContext requestContext, Method method, String header) {
    boolean isExpired = false;
    try {
        UserProfileCachable cachable = CacheFactory.getInstance(CacheType.LOCAL).getService();
        String sessionId = header.replace(AuthFilterParam.JSESSION_ID.getTObject(), "");
        isExpired = cachable.isExpired(sessionId);
        if (isExpired) {
            requestContext.abortWith(accessDenied);
            return false;
        }
        UserProfileDTO userProfileDTO = cachable.get(sessionId);
        userName = userProfileDTO.getUserName();
        log.debug("username : " + userName);
    } catch (BusinessException e) {
        requestContext.abortWith(accessDenied);
        return false;
    }
    return true;
}
Also used : BusinessException(com.wso2telco.core.dbutils.exception.BusinessException) UserProfileCachable(com.wso2telco.core.userprofile.cache.UserProfileCachable) UserProfileDTO(com.wso2telco.core.userprofile.dto.UserProfileDTO)

Example 2 with UserProfileDTO

use of com.wso2telco.core.userprofile.dto.UserProfileDTO in project core-util by WSO2Telco.

the class UserProfileRetriever method fillUserProfileDTO.

private UserProfileDTO fillUserProfileDTO(String userName, UserRoleDTO userRoleDTO, Map<String, Object> uiPermissionTree, UserClaimDTO userClaimDTO) {
    UserProfileDTO userProfileDTO = new UserProfileDTO();
    userProfileDTO.setUserName(userName);
    if (userRoleDTO.getUserRoles() != null) {
        userProfileDTO.setUserRoles(userRoleDTO.getUserRoles());
    }
    if (uiPermissionTree != null) {
        userProfileDTO.setUiPermissions(uiPermissionTree);
    }
    if (userClaimDTO != null) {
        userProfileDTO.setFirstName(userClaimDTO.getFirstName());
        userProfileDTO.setLastName(userClaimDTO.getLastName());
        userProfileDTO.setEmailAddress(userClaimDTO.getEmailAddress());
        userProfileDTO.setOrganization(userClaimDTO.getOrganization());
        userProfileDTO.setDepartment(userClaimDTO.getDepartment());
    }
    return userProfileDTO;
}
Also used : UserProfileDTO(com.wso2telco.core.userprofile.dto.UserProfileDTO)

Aggregations

UserProfileDTO (com.wso2telco.core.userprofile.dto.UserProfileDTO)2 BusinessException (com.wso2telco.core.dbutils.exception.BusinessException)1 UserProfileCachable (com.wso2telco.core.userprofile.cache.UserProfileCachable)1