bindingSecurityBindingMembers.put(method, method.invoke(bindingAnnotation));
}
}
catch (InvocationTargetException ex)
{
throw new SecurityDefinitionException("Error reading security binding members", ex);
}
catch (IllegalAccessException ex)
{
throw new SecurityDefinitionException("Error reading security binding members", ex);
}
for (AnnotatedParameter<?> annotatedParameter : boundAuthorizerMethod.getParameters())
{
Set<Annotation> securityParameterBindings = null;
Class<?> securedReturnType = null;
for (Annotation annotation : annotatedParameter.getAnnotations())
{
if (SecurityUtils.isMetaAnnotatedWithSecurityParameterBinding(annotation))
{
if (securityParameterBindings == null)
{
securityParameterBindings = new HashSet<Annotation>();
}
securityParameterBindings.add(annotation);
}
if (annotation.annotationType().equals(SecuredReturn.class))
{
securedReturnType
= boundAuthorizerMethod.getJavaMember().getParameterTypes()[annotatedParameter.getPosition()];
}
}
if (securityParameterBindings != null && securedReturnType != null)
{
StringBuilder errorMessage = new StringBuilder();
errorMessage.append("@SecurityParameterBinding annotations must not occure ");
errorMessage.append("at the same parameter with @Result annotation, but parameter ");
errorMessage.append(annotatedParameter.getPosition()).append(" of method ");
errorMessage.append(boundAuthorizerMethod.getJavaMember()).append(" is annotated with @Result and ");
boolean first = true;
for (Annotation securityParameterBinding : securityParameterBindings)
{
if (first)
{
first = false;
}
else
{
errorMessage.append(" and ");
}
errorMessage.append(securityParameterBinding);
}
if (securityParameterBindings.size() == 1)
{
errorMessage.append(", which is a @SecurityParameterBinding annotation");
}
else
{
errorMessage.append(", which are @SecurityParameterBinding annotations");
}
throw new SecurityDefinitionException(errorMessage.toString());
}
else if (securityParameterBindings != null)
{
AuthorizationParameter authorizationParameter
= new AuthorizationParameter(annotatedParameter.getBaseType(), securityParameterBindings);
authorizationParameters.add(authorizationParameter);
}
else if (securedReturnType != null)
{
if (this.securedReturnType != null
&& !this.securedReturnType.equals(securedReturnType))
{
throw new SecurityDefinitionException("More than one parameter of "
+ boundAuthorizerMethod.getJavaMember()
+ " is annotated with @Result");
}
this.securedReturnType = securedReturnType;
}