gluu
公開メンバ関数 | 非公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.gluu.oxtrust.service.uma.annotations.UmaSecureInterceptor クラス
org.gluu.oxtrust.service.uma.annotations.UmaSecureInterceptor 連携図
Collaboration graph

公開メンバ関数

Object invoke (InvocationContext ctx) throws Exception
 

非公開メンバ関数

Map< String, Object > computeParameterValues (InvocationContext ctx)
 

非公開変数類

Logger log
 
SecurityExtension securityExtension
 
ExpressionEvaluator expressionEvaluator
 

詳解

Provides service to protect Rest service endpoints with UMA scope.

著者
Dmitry Ognyannikov

関数詳解

◆ computeParameterValues()

Map<String, Object> org.gluu.oxtrust.service.uma.annotations.UmaSecureInterceptor.computeParameterValues ( InvocationContext  ctx)
inlineprivate
92  {
93  Annotation[][] parametersAnnotations = ctx.getMethod().getParameterAnnotations();
94  Map<String, Object> secureVariables = new HashMap<String, Object>();
95  for (int i = 0; i < parametersAnnotations.length; i++) {
96  Annotation[] parameterAnnotations = parametersAnnotations[i];
97  for (Annotation parameterAnnotation : parameterAnnotations) {
98  if (SecureVariable.class.isAssignableFrom(parameterAnnotation.annotationType())) {
99  SecureVariable secureVariable = (SecureVariable) parameterAnnotation;
100  Object paramValue = ctx.getParameters()[i];
101  secureVariables.put(secureVariable.value(), paramValue);
102  }
103  }
104  }
105 
106  return secureVariables;
107  }

◆ invoke()

Object org.gluu.oxtrust.service.uma.annotations.UmaSecureInterceptor.invoke ( InvocationContext  ctx) throws Exception
inline
48  {
49  HttpServletResponse response = null;
50  Object[] parameters = ctx.getParameters();
51 
52  log.trace("REST method call security check. " + ctx.getMethod().getName() + "()");
53 
54  for (Object parameter : parameters) {
55  if (parameter instanceof HttpServletResponse)
56  response = (HttpServletResponse)parameter;
57  }
58 
59  InterceptSecure is = securityExtension.getInterceptSecure(ctx.getMethod());
60 
61  // SecurityChecking restrictions
62  Secure[] constraints = (is == null) ? new Secure[0] : is.value();
63 
64  // Getting the parameter values
65  Map<String, Object> secureVars = computeParameterValues(ctx);
66 
67  for (Secure constraint : constraints) {
68  Boolean expressionValue = expressionEvaluator.evaluateValueExpression(constraint.value(), Boolean.class, secureVars);
69 
70  if ((expressionValue == null) || !expressionValue) {
71  log.debug("Method: '{}' constrain '{}' evaluation is null or false!", ctx.getMethod(), constraint);
72  throw new SecurityEvaluationException();
73  }
74  }
75 
76  try {
77  // the method call
78  return ctx.proceed();
79  } catch (Exception e) {
80  log.error("Error calling ctx.proceed in UmaSecureInterceptor");
81  // REST call error report
82  if (response != null) {
83  try { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "INTERNAL SERVER ERROR"); } catch (Exception ex) {}
84  } else if (Response.class.isAssignableFrom(ctx.getMethod().getReturnType())) {
85  return Response.serverError().entity("INTERNAL SERVER ERROR").build();
86  }
87 
88  return null;
89  }
90  }
Logger log
Definition: UmaSecureInterceptor.java:39
Map< String, Object > computeParameterValues(InvocationContext ctx)
Definition: UmaSecureInterceptor.java:92
SecurityExtension securityExtension
Definition: UmaSecureInterceptor.java:42
ExpressionEvaluator expressionEvaluator
Definition: UmaSecureInterceptor.java:45

メンバ詳解

◆ expressionEvaluator

ExpressionEvaluator org.gluu.oxtrust.service.uma.annotations.UmaSecureInterceptor.expressionEvaluator
private

◆ log

Logger org.gluu.oxtrust.service.uma.annotations.UmaSecureInterceptor.log
private

◆ securityExtension

SecurityExtension org.gluu.oxtrust.service.uma.annotations.UmaSecureInterceptor.securityExtension
private

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