Managed to return to application with following. But still working on
sending a response with this.

I added this parameter to authenticator

public boolean isMaxRetriesExceeded = false;

Then I override the retryAuthenticationEnabled as follows.

@Override
protected boolean retryAuthenticationEnabled() {

    return !isMaxRetriesExceeded;
}

When authentication failed I called following code.

isMaxRetriesExceeded = AuthenticatorUtils.isMaxRetryNoExceeded(context);


public static boolean isMaxRetryNoExceeded(AuthenticationContext context) {

    Map<String, Object> parameters = new HashMap();

    if (context.getProperties() != null) {
        parameters.putAll(context.getProperties());
    }
    Object retryCountString = parameters.get("RetryCount");
    int retryCount = 1;
    if (retryCountString != null) {
        retryCount = Integer.parseInt(String.valueOf(retryCountString));
    }
    if (retryCount >= 3) {
        return true;
    }
    retryCount++;
    parameters.remove("RetryCount");
    parameters.put("RetryCount", String.valueOf(retryCount));
    context.setProperties(parameters);
    return false;

}

Please let me know if there are concerns.

Thanks & Regards
Danushka Fernando
Senior Software Engineer
WSO2 inc. http://wso2.com/
Mobile : +94716332729

On Tue, Mar 14, 2017 at 11:34 AM, Danushka Fernando <[email protected]>
wrote:

> Hi Harsha
> What I wants to achieve is to return a failed response to application side
> with some failure details after no of failed attempts.
>
> Thanks & Regards
> Danushka Fernando
> Senior Software Engineer
> WSO2 inc. http://wso2.com/
> Mobile : +94716332729 <+94%2071%20633%202729>
>
> On Tue, Mar 14, 2017 at 11:31 AM, Harsha Thirimanna <[email protected]>
> wrote:
>
>>
>> On Tue, Mar 14, 2017 at 11:07 AM, Danushka Fernando <[email protected]>
>> wrote:
>>
>>> Hi All
>>>
>>> I am trying to work on $subject. While looking in to $subject I found a
>>> status in AuthenticatorFlowStatus class named FAIL_COMPLETED but we
>>> haven't used it in the code. So even from the authenticator I set that
>>> value it won't take an effect. I guess we should have use that state and
>>> since we are using same framework
>>>
>>
>> ​No We are not using same framework for IS .6.0.0.
>> ​
>>
>>> for IS 6 shall we do that for IS 6?
>>>
>>
>> ​IS 6, we have  wrapper classes to return status and response object
>> instead of Enum as in first class. And around the top level handlers in
>> gateway, we have different status to handle like, CONTINUE, REDIRECT. But
>> in authentication layer, we have INCOMPLETE, AUTHENTICATE​D like that. So
>> we have two different return types in IS 6.0.0. And yes, we are using these
>> status to control the flow in IS 6.0.0.
>>
>>
>>
>>>
>>> Meanwhile have anybody tried to achieve this in IS 5.x and succeeded?
>>> Any ideas are appreciated.
>>>
>> ​What  do you exactly want to do with this framework ?​
>>
>>>
>>> Thanks & Regards
>>> Danushka Fernando
>>> Senior Software Engineer
>>> WSO2 inc. http://wso2.com/
>>> Mobile : +94716332729 <+94%2071%20633%202729>
>>>
>>
>>
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to