gluu
静的公開メンバ関数 | 非公開メンバ関数 | 静的非公開変数類 | 全メンバ一覧
org.xdi.oxauth.util.ServerUtil クラス
org.xdi.oxauth.util.ServerUtil 連携図
Collaboration graph

静的公開メンバ関数

static String asJsonSilently (Object p_object)
 
static boolean isTrue (Boolean booleanObject)
 
static boolean isFalse (Boolean booleanObject)
 
static String asPrettyJson (Object p_object) throws IOException
 
static String asJson (Object p_object) throws IOException
 
static CacheControl cacheControl (boolean p_noStore)
 
static CacheControl cacheControl (boolean p_noStore, boolean p_noTransform)
 
static ObjectMapper createJsonMapper ()
 
static ObjectMapper jsonMapperWithWrapRoot ()
 
static ObjectMapper jsonMapperWithUnwrapRoot ()
 
static PersistenceEntryManager getLdapManager ()
 
static CustomAttribute getAttributeByName (List< CustomAttribute > p_list, String p_attributeName)
 
static String getAttributeValueByName (List< CustomAttribute > p_list, String p_attributeName)
 
static String urlDecode (String p_str)
 
static ScheduledExecutorService createExecutor ()
 
static org.xdi.oxauth.model.uma.UmaPermission convert (UmaPermission permission, UmaScopeService umaScopeService)
 
static String getFirstValue (Map< String, String[]> map, String key)
 
static String getIpAddress (HttpServletRequest httpRequest)
 
static HttpServletRequest getRequestOrNull ()
 
static boolean isSameRequestPath (String url1, String url2) throws MalformedURLException
 
static Integer dateToSeconds (Date date)
 

非公開メンバ関数

 ServerUtil ()
 

静的非公開変数類

static final Logger log = LoggerFactory.getLogger(ServerUtil.class)
 

詳解

著者
Yuriy Zabrovarnyy
Yuriy Movchan
バージョン
0.9, 26/12/2012

構築子と解体子

◆ ServerUtil()

org.xdi.oxauth.util.ServerUtil.ServerUtil ( )
inlineprivate
54  {
55  }

関数詳解

◆ asJson()

static String org.xdi.oxauth.util.ServerUtil.asJson ( Object  p_object) throws IOException
inlinestatic
79  {
80  final ObjectMapper mapper = ServerUtil.createJsonMapper().configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, false);
81  return mapper.writeValueAsString(p_object);
82  }
ServerUtil()
Definition: ServerUtil.java:54

◆ asJsonSilently()

static String org.xdi.oxauth.util.ServerUtil.asJsonSilently ( Object  p_object)
inlinestatic
57  {
58  try {
59  return asJson(p_object);
60  } catch (IOException e) {
61  log.trace(e.getMessage(), e);
62  return "";
63  }
64  }
static String asJson(Object p_object)
Definition: ServerUtil.java:79
static final Logger log
Definition: ServerUtil.java:52

◆ asPrettyJson()

static String org.xdi.oxauth.util.ServerUtil.asPrettyJson ( Object  p_object) throws IOException
inlinestatic
74  {
75  final ObjectMapper mapper = ServerUtil.createJsonMapper().configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, false);
76  return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(p_object);
77  }
ServerUtil()
Definition: ServerUtil.java:54

◆ cacheControl() [1/2]

static CacheControl org.xdi.oxauth.util.ServerUtil.cacheControl ( boolean  p_noStore)
inlinestatic
84  {
85  final CacheControl cacheControl = new CacheControl();
86  cacheControl.setNoStore(p_noStore);
87  return cacheControl;
88  }
static CacheControl cacheControl(boolean p_noStore)
Definition: ServerUtil.java:84

◆ cacheControl() [2/2]

static CacheControl org.xdi.oxauth.util.ServerUtil.cacheControl ( boolean  p_noStore,
boolean  p_noTransform 
)
inlinestatic
90  {
91  final CacheControl cacheControl = new CacheControl();
92  cacheControl.setNoStore(p_noStore);
93  cacheControl.setNoTransform(p_noTransform);
94  return cacheControl;
95  }
static CacheControl cacheControl(boolean p_noStore)
Definition: ServerUtil.java:84

◆ convert()

static org.xdi.oxauth.model.uma.UmaPermission org.xdi.oxauth.util.ServerUtil.convert ( UmaPermission  permission,
UmaScopeService  umaScopeService 
)
inlinestatic
161  {
162  if (permission != null) {
164  result.setResourceId(permission.getResourceId());
165  result.setScopes(umaScopeService.getScopeIdsByDns(permission.getScopeDns()));
166  result.setExpiresAt(dateToSeconds(permission.getExpirationDate()));
167  return result;
168  }
169  return null;
170  }
Definition: ClaimTokenFormatType.java:1
Definition: UmaPermission.java:37
static Integer dateToSeconds(Date date)
Definition: ServerUtil.java:241
void setResourceId(String resourceId)
Definition: UmaPermission.java:63

◆ createExecutor()

static ScheduledExecutorService org.xdi.oxauth.util.ServerUtil.createExecutor ( )
inlinestatic
151  {
152  return Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
153  public Thread newThread(Runnable p_r) {
154  Thread thread = new Thread(p_r);
155  thread.setDaemon(true);
156  return thread;
157  }
158  });
159  }

◆ createJsonMapper()

static ObjectMapper org.xdi.oxauth.util.ServerUtil.createJsonMapper ( )
inlinestatic
97  {
98  final AnnotationIntrospector jaxb = new JaxbAnnotationIntrospector();
99  final AnnotationIntrospector jackson = new JacksonAnnotationIntrospector();
100 
101  final AnnotationIntrospector pair = new AnnotationIntrospector.Pair(jackson, jaxb);
102 
103  final ObjectMapper mapper = new ObjectMapper();
104  mapper.getDeserializationConfig().withAnnotationIntrospector(pair);
105  mapper.getSerializationConfig().withAnnotationIntrospector(pair);
106  return mapper;
107  }

◆ dateToSeconds()

static Integer org.xdi.oxauth.util.ServerUtil.dateToSeconds ( Date  date)
inlinestatic
241  {
242  return date != null ? (int) (date.getTime() / 1000) : null;
243  }

◆ getAttributeByName()

static CustomAttribute org.xdi.oxauth.util.ServerUtil.getAttributeByName ( List< CustomAttribute >  p_list,
String  p_attributeName 
)
inlinestatic
121  {
122  if (p_list != null && !p_list.isEmpty() && StringUtils.isNotEmpty(p_attributeName)) {
123  for (CustomAttribute attr : p_list) {
124  if (p_attributeName.equals(attr.getName())) {
125  return attr;
126  }
127  }
128  }
129  return null;
130  }

◆ getAttributeValueByName()

static String org.xdi.oxauth.util.ServerUtil.getAttributeValueByName ( List< CustomAttribute >  p_list,
String  p_attributeName 
)
inlinestatic
132  {
133  final CustomAttribute attr = getAttributeByName(p_list, p_attributeName);
134  if (attr != null) {
135  return attr.getValue();
136  }
137  return "";
138  }
static CustomAttribute getAttributeByName(List< CustomAttribute > p_list, String p_attributeName)
Definition: ServerUtil.java:121

◆ getFirstValue()

static String org.xdi.oxauth.util.ServerUtil.getFirstValue ( Map< String, String[]>  map,
String  key 
)
inlinestatic
172  {
173  if (map.containsKey(key)) {
174  String[] values = map.get(key);
175  if (ArrayHelper.isNotEmpty(values)) {
176  return values[0];
177  }
178  }
179 
180  return null;
181  }

◆ getIpAddress()

static String org.xdi.oxauth.util.ServerUtil.getIpAddress ( HttpServletRequest  httpRequest)
inlinestatic
引数
httpRequestinterface to provide request information for HTTP servlets.
戻り値
IP address of client
参照
Getting IP address of client
188  {
189  final String[] HEADERS_TO_TRY = {
190  "X-Forwarded-For",
191  "Proxy-Client-IP",
192  "WL-Proxy-Client-IP",
193  "HTTP_X_FORWARDED_FOR",
194  "HTTP_X_FORWARDED",
195  "HTTP_X_CLUSTER_CLIENT_IP",
196  "HTTP_CLIENT_IP",
197  "HTTP_FORWARDED_FOR",
198  "HTTP_FORWARDED",
199  "HTTP_VIA",
200  "REMOTE_ADDR"
201  };
202  for (String header : HEADERS_TO_TRY) {
203  String ip = httpRequest.getHeader(header);
204  if (ip != null && ip.length() != 0 && !"unknown".equalsIgnoreCase(ip)) {
205  return ip;
206  }
207  }
208  return httpRequest.getRemoteAddr();
209  }

◆ getLdapManager()

static PersistenceEntryManager org.xdi.oxauth.util.ServerUtil.getLdapManager ( )
inlinestatic
117  {
118  return CdiUtil.bean(PersistenceEntryManager.class, ApplicationFactory.PERSISTENCE_ENTRY_MANAGER_NAME);
119  }

◆ getRequestOrNull()

static HttpServletRequest org.xdi.oxauth.util.ServerUtil.getRequestOrNull ( )
inlinestatic

Safe retrieves http request from FacesContext

戻り値
http
216  {
217  FacesContext facesContext = FacesContext.getCurrentInstance();
218  if (facesContext == null)
219  return null;
220 
221  ExternalContext externalContext = facesContext.getExternalContext();
222  if (externalContext == null)
223  return null;
224  Object request = externalContext.getRequest();
225  if (request == null || !(request instanceof HttpServletRequest))
226  return null;
227  return (HttpServletRequest) request;
228  }

◆ isFalse()

static boolean org.xdi.oxauth.util.ServerUtil.isFalse ( Boolean  booleanObject)
inlinestatic
70  {
71  return !isTrue(booleanObject);
72  }
static boolean isTrue(Boolean booleanObject)
Definition: ServerUtil.java:66

◆ isSameRequestPath()

static boolean org.xdi.oxauth.util.ServerUtil.isSameRequestPath ( String  url1,
String  url2 
) throws MalformedURLException
inlinestatic
230  {
231  if ((url1 == null) || (url2 == null)) {
232  return false;
233  }
234 
235  URL parsedUrl1 = new URL(url1);
236  URL parsedUrl2 = new URL(url2);
237 
238  return parsedUrl1.getPath().endsWith(parsedUrl2.getPath());
239  }

◆ isTrue()

static boolean org.xdi.oxauth.util.ServerUtil.isTrue ( Boolean  booleanObject)
inlinestatic
66  {
67  return booleanObject != null && booleanObject;
68  }

◆ jsonMapperWithUnwrapRoot()

static ObjectMapper org.xdi.oxauth.util.ServerUtil.jsonMapperWithUnwrapRoot ( )
inlinestatic
113  {
114  return createJsonMapper().configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true);
115  }
static ObjectMapper createJsonMapper()
Definition: ServerUtil.java:97

◆ jsonMapperWithWrapRoot()

static ObjectMapper org.xdi.oxauth.util.ServerUtil.jsonMapperWithWrapRoot ( )
inlinestatic
109  {
110  return createJsonMapper().configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, true);
111  }
static ObjectMapper createJsonMapper()
Definition: ServerUtil.java:97

◆ urlDecode()

static String org.xdi.oxauth.util.ServerUtil.urlDecode ( String  p_str)
inlinestatic
140  {
141  if (StringUtils.isNotBlank(p_str)) {
142  try {
143  return URLDecoder.decode(p_str, Util.UTF8);
144  } catch (UnsupportedEncodingException e) {
145  log.trace(e.getMessage(), e);
146  }
147  }
148  return p_str;
149  }
static final Logger log
Definition: ServerUtil.java:52

メンバ詳解

◆ log

final Logger org.xdi.oxauth.util.ServerUtil.log = LoggerFactory.getLogger(ServerUtil.class)
staticprivate

このクラス詳解は次のファイルから抽出されました: