use of com.icthh.xm.commons.security.XmAuthenticationContext in project xm-ms-entity by xm-online.
the class XmAuthContextHolderDefaultTestConfiguration method xmAuthenticationContextHolder.
@Bean
@Primary
public XmAuthenticationContextHolder xmAuthenticationContextHolder() {
XmAuthenticationContext context = mock(XmAuthenticationContext.class);
when(context.hasAuthentication()).thenReturn(true);
when(context.getLogin()).thenReturn(Optional.of("testLogin"));
when(context.getUserKey()).thenReturn(Optional.of("ACCOUNT.TEST"));
XmAuthenticationContextHolder holder = mock(XmAuthenticationContextHolder.class);
when(holder.getContext()).thenReturn(context);
return holder;
}
use of com.icthh.xm.commons.security.XmAuthenticationContext in project xm-ms-entity by xm-online.
the class ProfileResourceIntTest method xmAuthenticationContextHolder.
@Bean
@Primary
public XmAuthenticationContextHolder xmAuthenticationContextHolder() {
XmAuthenticationContext context = mock(XmAuthenticationContext.class);
when(context.hasAuthentication()).thenReturn(true);
when(context.isFullyAuthenticated()).thenReturn(true);
when(context.getUserKey()).thenReturn(Optional.of(DEFAULT_USER_KEY));
when(context.getRequiredUserKey()).thenReturn(DEFAULT_USER_KEY);
XmAuthenticationContextHolder holder = mock(XmAuthenticationContextHolder.class);
when(holder.getContext()).thenReturn(context);
return holder;
}
use of com.icthh.xm.commons.security.XmAuthenticationContext in project xm-ms-entity by xm-online.
the class CommentResourceIntTest method xmAuthenticationContextHolder.
@Bean
@Primary
public XmAuthenticationContextHolder xmAuthenticationContextHolder() {
XmAuthenticationContext context = mock(XmAuthenticationContext.class);
when(context.hasAuthentication()).thenReturn(true);
when(context.getLogin()).thenReturn(Optional.of("testLogin"));
when(context.getUserKey()).thenReturn(Optional.of(DEFAULT_USER_KEY));
XmAuthenticationContextHolder holder = mock(XmAuthenticationContextHolder.class);
when(holder.getContext()).thenReturn(context);
return holder;
}
use of com.icthh.xm.commons.security.XmAuthenticationContext in project xm-ms-entity by xm-online.
the class ProfileService method getSelfProfile.
@LogicExtensionPoint("GetSelfProfile")
@Transactional(readOnly = true)
public Profile getSelfProfile() {
XmAuthenticationContext context = authContextHolder.getContext();
if (!context.isFullyAuthenticated()) {
throw new EntityNotFoundException("Can't get profile for not fully authenticated user");
}
String userKey = context.getRequiredUserKey();
log.debug("Get profile for user key {}", userKey);
Profile profile = getProfile(userKey);
if (profile == null) {
throw new IllegalArgumentException("Profile not found for user key " + userKey);
}
return profile;
}
Aggregations