1 package org.kuali.student.common.util.security;
2
3 import org.kuali.student.r2.common.dto.ContextInfo;
4 import org.kuali.student.r2.common.dto.LocaleInfo;
5
6 import java.util.Date;
7 import java.util.Locale;
8
9
10
11
12
13
14
15
16 public class ContextUtils {
17
18
19
20
21
22
23
24 @Deprecated
25 public static ContextInfo getContextInfo(){
26 return createDefaultContextInfo();
27 }
28
29
30
31
32
33 public static ContextInfo createDefaultContextInfo(){
34 String currentUserId = SecurityUtils.getCurrentUserId();
35
36 LocaleInfo localeInfo = new LocaleInfo();
37 localeInfo.setLocaleLanguage(Locale.getDefault().getLanguage());
38 localeInfo.setLocaleRegion(Locale.getDefault().getCountry());
39
40 ContextInfo contextInfo = new ContextInfo();
41 contextInfo.setAuthenticatedPrincipalId(currentUserId);
42 contextInfo.setPrincipalId(currentUserId);
43 contextInfo.setCurrentDate(new Date());
44 contextInfo.setLocale(localeInfo);
45
46 return contextInfo;
47 }
48 }