gluu
公開メンバ関数 | 関数 | 非公開メンバ関数 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.xdi.oxauth.model.error.ErrorResponseFactory クラス
org.xdi.oxauth.model.error.ErrorResponseFactory の継承関係図
Inheritance graph
org.xdi.oxauth.model.error.ErrorResponseFactory 連携図
Collaboration graph

公開メンバ関数

 ErrorResponseFactory ()
 
 ErrorResponseFactory (ErrorMessages messages)
 
ErrorMessages getMessages ()
 
void setMessages (ErrorMessages p_messages)
 
String getErrorAsJson (IErrorType p_type)
 
String errorAsJson (IErrorType p_type, String reason)
 
void throwUnauthorizedException (IErrorType type) throws WebApplicationException
 
void throwBadRequestException (IErrorType type) throws WebApplicationException
 
void throwWebApplicationException (Response.Status status, IErrorType type) throws WebApplicationException
 
void throwUmaNotFoundException () throws WebApplicationException
 
void throwUmaInternalErrorException () throws WebApplicationException
 
String getErrorAsJson (IErrorType p_type, String p_state)
 
String getErrorAsQueryString (IErrorType p_type, String p_state)
 
DefaultErrorResponse getErrorResponse (IErrorType type, String p_state)
 
DefaultErrorResponse getErrorResponse (IErrorType type)
 
UmaErrorResponse getUmaErrorResponse (IErrorType type)
 
String getUmaJsonErrorResponse (IErrorType type)
 
String getJsonErrorResponse (IErrorType type)
 

関数

public< T > T throwUmaWebApplicationException (Response.Status status, IErrorType type) throws WebApplicationException
 

非公開メンバ関数

ErrorMessage getError (List< ErrorMessage > p_list, IErrorType type)
 

非公開変数類

ErrorMessages messages
 

静的非公開変数類

static Logger log = LoggerFactory.getLogger(ErrorResponseFactory.class)
 

詳解

Provides an easy way to get Error responses based in an error response type

著者
Yuriy Zabrovarnyy
Javier Rojas Blum
Yuriy Movchan
バージョン
April 26, 2017

構築子と解体子

◆ ErrorResponseFactory() [1/2]

org.xdi.oxauth.model.error.ErrorResponseFactory.ErrorResponseFactory ( )
inline
48  {
49  }

◆ ErrorResponseFactory() [2/2]

org.xdi.oxauth.model.error.ErrorResponseFactory.ErrorResponseFactory ( ErrorMessages  messages)
inline
51  {
52  this.messages = messages;
53  }
ErrorMessages messages
Definition: ErrorResponseFactory.java:46

関数詳解

◆ errorAsJson()

String org.xdi.oxauth.model.error.ErrorResponseFactory.errorAsJson ( IErrorType  p_type,
String  reason 
)
inline
90  {
91  final DefaultErrorResponse error = getErrorResponse(p_type);
92  error.setReason(reason);
93  return error.toJSonString();
94  }
DefaultErrorResponse getErrorResponse(IErrorType type, String p_state)
Definition: ErrorResponseFactory.java:130

◆ getError()

ErrorMessage org.xdi.oxauth.model.error.ErrorResponseFactory.getError ( List< ErrorMessage p_list,
IErrorType  type 
)
inlineprivate

Looks for an error message.

引数
p_listerror list
typeThe type of the error.
戻り値
Error message or null if not found.
70  {
71  log.debug("Looking for the error with id: {}", type);
72 
73  if (p_list != null) {
74  for (ErrorMessage error : p_list) {
75  if (error.getId().equals(type.getParameter())) {
76  log.debug("Found error, id: {}", type);
77  return error;
78  }
79  }
80  }
81 
82  log.debug("Error not found, id: {}", type);
83  return null;
84  }
static Logger log
Definition: ErrorResponseFactory.java:44

◆ getErrorAsJson() [1/2]

String org.xdi.oxauth.model.error.ErrorResponseFactory.getErrorAsJson ( IErrorType  p_type)
inline
86  {
87  return getErrorResponse(p_type).toJSonString();
88  }
DefaultErrorResponse getErrorResponse(IErrorType type, String p_state)
Definition: ErrorResponseFactory.java:130
String toJSonString()
Definition: ErrorResponse.java:142

◆ getErrorAsJson() [2/2]

String org.xdi.oxauth.model.error.ErrorResponseFactory.getErrorAsJson ( IErrorType  p_type,
String  p_state 
)
inline
122  {
123  return getErrorResponse(p_type, p_state).toJSonString();
124  }
DefaultErrorResponse getErrorResponse(IErrorType type, String p_state)
Definition: ErrorResponseFactory.java:130
String toJSonString()
Definition: ErrorResponse.java:142

◆ getErrorAsQueryString()

String org.xdi.oxauth.model.error.ErrorResponseFactory.getErrorAsQueryString ( IErrorType  p_type,
String  p_state 
)
inline
126  {
127  return getErrorResponse(p_type, p_state).toQueryString();
128  }
DefaultErrorResponse getErrorResponse(IErrorType type, String p_state)
Definition: ErrorResponseFactory.java:130
String toQueryString()
Definition: ErrorResponse.java:106

◆ getErrorResponse() [1/2]

DefaultErrorResponse org.xdi.oxauth.model.error.ErrorResponseFactory.getErrorResponse ( IErrorType  type,
String  p_state 
)
inline
130  {
131  final DefaultErrorResponse response = getErrorResponse(type);
132  response.setState(p_state);
133  return response;
134  }
DefaultErrorResponse getErrorResponse(IErrorType type, String p_state)
Definition: ErrorResponseFactory.java:130

◆ getErrorResponse() [2/2]

DefaultErrorResponse org.xdi.oxauth.model.error.ErrorResponseFactory.getErrorResponse ( IErrorType  type)
inline
136  {
137  final DefaultErrorResponse response = new DefaultErrorResponse();
138  response.setType(type);
139 
140  if (type != null && messages != null) {
141  List<ErrorMessage> list = null;
142  if (type instanceof AuthorizeErrorResponseType) {
143  list = messages.getAuthorize();
144  } else if (type instanceof ClientInfoErrorResponseType) {
145  list = messages.getClientInfo();
146  } else if (type instanceof EndSessionErrorResponseType) {
147  list = messages.getEndSession();
148  } else if (type instanceof RegisterErrorResponseType) {
149  list = messages.getRegister();
150  } else if (type instanceof TokenErrorResponseType) {
151  list = messages.getToken();
152  } else if (type instanceof UmaErrorResponseType) {
153  list = messages.getUma();
154  } else if (type instanceof UserInfoErrorResponseType) {
155  list = messages.getUserInfo();
156  } else if (type instanceof U2fErrorResponseType) {
157  list = messages.getFido();
158  }
159 
160  if (list != null) {
161  final ErrorMessage m = getError(list, type);
162  response.setErrorDescription(m.getDescription());
163  response.setErrorUri(m.getUri());
164  }
165  }
166 
167  return response;
168  }
List< ErrorMessage > getAuthorize()
Definition: ErrorMessages.java:55
List< ErrorMessage > getEndSession()
Definition: ErrorMessages.java:71
List< ErrorMessage > getClientInfo()
Definition: ErrorMessages.java:63
List< ErrorMessage > getToken()
Definition: ErrorMessages.java:87
ErrorMessages messages
Definition: ErrorResponseFactory.java:46
List< ErrorMessage > getUma()
Definition: ErrorMessages.java:95
List< ErrorMessage > getRegister()
Definition: ErrorMessages.java:79
ErrorMessage getError(List< ErrorMessage > p_list, IErrorType type)
Definition: ErrorResponseFactory.java:70
List< ErrorMessage > getFido()
Definition: ErrorMessages.java:111
List< ErrorMessage > getUserInfo()
Definition: ErrorMessages.java:103

◆ getJsonErrorResponse()

String org.xdi.oxauth.model.error.ErrorResponseFactory.getJsonErrorResponse ( IErrorType  type)
inline
210  {
211  final DefaultErrorResponse response = getErrorResponse(type);
212 
213  JsonErrorResponse jsonErrorResponse = new JsonErrorResponse(response);
214 
215  try {
216  return ServerUtil.asJson(jsonErrorResponse);
217  } catch (IOException ex) {
218  log.error("Failed to generate error response", ex);
219  return null;
220  }
221  }
static Logger log
Definition: ErrorResponseFactory.java:44
DefaultErrorResponse getErrorResponse(IErrorType type, String p_state)
Definition: ErrorResponseFactory.java:130

◆ getMessages()

ErrorMessages org.xdi.oxauth.model.error.ErrorResponseFactory.getMessages ( )
inline
55  {
56  return messages;
57  }
ErrorMessages messages
Definition: ErrorResponseFactory.java:46

◆ getUmaErrorResponse()

UmaErrorResponse org.xdi.oxauth.model.error.ErrorResponseFactory.getUmaErrorResponse ( IErrorType  type)
inline
170  {
171  final UmaErrorResponse response = new UmaErrorResponse();
172 
173  final ErrorMessage errorMessage = getError(messages.getUma(), type);
174  response.setError(errorMessage.getId());
175  response.setErrorDescription(errorMessage.getDescription());
176  response.setErrorUri(errorMessage.getUri());
177 
178  return response;
179  }
ErrorMessages messages
Definition: ErrorResponseFactory.java:46
List< ErrorMessage > getUma()
Definition: ErrorMessages.java:95
ErrorMessage getError(List< ErrorMessage > p_list, IErrorType type)
Definition: ErrorResponseFactory.java:70

◆ getUmaJsonErrorResponse()

String org.xdi.oxauth.model.error.ErrorResponseFactory.getUmaJsonErrorResponse ( IErrorType  type)
inline
181  {
182  final UmaErrorResponse response = getUmaErrorResponse(type);
183 
184  JSONObject jsonObj = new JSONObject();
185 
186  try {
187  jsonObj.put("error", response.getError());
188 
189  if (StringHelper.isNotEmpty(response.getStatus())) {
190  jsonObj.put("status", response.getStatus());
191  }
192 
193  if (StringHelper.isNotEmpty(response.getErrorDescription())) {
194  jsonObj.put("error_description", response.getErrorDescription());
195  }
196 
197 
198  if (StringHelper.isNotEmpty(response.getErrorUri())) {
199  jsonObj.put("error_uri", response.getErrorUri());
200  }
201  } catch (JSONException ex) {
202  log.error("Failed to generate error response", ex);
203  return null;
204  }
205 
206  return jsonObj.toString();
207  }
static Logger log
Definition: ErrorResponseFactory.java:44
UmaErrorResponse getUmaErrorResponse(IErrorType type)
Definition: ErrorResponseFactory.java:170

◆ setMessages()

void org.xdi.oxauth.model.error.ErrorResponseFactory.setMessages ( ErrorMessages  p_messages)
inline
59  {
60  messages = p_messages;
61  }
ErrorMessages messages
Definition: ErrorResponseFactory.java:46

◆ throwBadRequestException()

void org.xdi.oxauth.model.error.ErrorResponseFactory.throwBadRequestException ( IErrorType  type) throws WebApplicationException
inline
100  {
101  throwWebApplicationException(Response.Status.BAD_REQUEST, type);
102  }
void throwWebApplicationException(Response.Status status, IErrorType type)
Definition: ErrorResponseFactory.java:104

◆ throwUmaInternalErrorException()

void org.xdi.oxauth.model.error.ErrorResponseFactory.throwUmaInternalErrorException ( ) throws WebApplicationException
inline
113  {
114  throwUmaWebApplicationException(Response.Status.INTERNAL_SERVER_ERROR, UmaErrorResponseType.SERVER_ERROR);
115  }
public< T > T throwUmaWebApplicationException(Response.Status status, IErrorType type)
Definition: ErrorResponseFactory.java:117

◆ throwUmaNotFoundException()

void org.xdi.oxauth.model.error.ErrorResponseFactory.throwUmaNotFoundException ( ) throws WebApplicationException
inline
109  {
110  throwUmaWebApplicationException(Response.Status.NOT_FOUND, UmaErrorResponseType.NOT_FOUND);
111  }
public< T > T throwUmaWebApplicationException(Response.Status status, IErrorType type)
Definition: ErrorResponseFactory.java:117

◆ throwUmaWebApplicationException()

public<T> T org.xdi.oxauth.model.error.ErrorResponseFactory.throwUmaWebApplicationException ( Response.Status  status,
IErrorType  type 
) throws WebApplicationException
inlinepackage
117  {
118  final Response response = Response.status(status).entity(getUmaJsonErrorResponse(type)).build();
119  throw new WebApplicationException(response);
120  }
String getUmaJsonErrorResponse(IErrorType type)
Definition: ErrorResponseFactory.java:181

◆ throwUnauthorizedException()

void org.xdi.oxauth.model.error.ErrorResponseFactory.throwUnauthorizedException ( IErrorType  type) throws WebApplicationException
inline
96  {
97  throwWebApplicationException(Response.Status.UNAUTHORIZED, type);
98  }
void throwWebApplicationException(Response.Status status, IErrorType type)
Definition: ErrorResponseFactory.java:104

◆ throwWebApplicationException()

void org.xdi.oxauth.model.error.ErrorResponseFactory.throwWebApplicationException ( Response.Status  status,
IErrorType  type 
) throws WebApplicationException
inline
104  {
105  final Response response = Response.status(status).entity(getErrorAsJson(type)).build();
106  throw new WebApplicationException(response);
107  }
String getErrorAsJson(IErrorType p_type)
Definition: ErrorResponseFactory.java:86

メンバ詳解

◆ log

Logger org.xdi.oxauth.model.error.ErrorResponseFactory.log = LoggerFactory.getLogger(ErrorResponseFactory.class)
staticprivate

◆ messages

ErrorMessages org.xdi.oxauth.model.error.ErrorResponseFactory.messages
private

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