// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package org.apache.oltu.oauth2.client.validator; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.oltu.oauth2.client.response.OAuthClientResponse; import org.apache.oltu.oauth2.common.exception.OAuthProblemException; import org.apache.oltu.oauth2.common.utils.OAuthUtils; public abstract class OAuthClientValidator { protected List notAllowedParams; protected Map requiredParams; public OAuthClientValidator() { requiredParams = new HashMap(); notAllowedParams = new ArrayList(); } public void validate(OAuthClientResponse oauthclientresponse) throws OAuthProblemException { validateErrorResponse(oauthclientresponse); validateParameters(oauthclientresponse); } public void validateErrorResponse(OAuthClientResponse oauthclientresponse) throws OAuthProblemException { String s = oauthclientresponse.getParam("error"); if (!OAuthUtils.isEmpty(s)) { String s1 = oauthclientresponse.getParam("error_description"); String s2 = oauthclientresponse.getParam("error_uri"); oauthclientresponse = oauthclientresponse.getParam("state"); throw OAuthProblemException.error(s).description(s1).uri(s2).state(oauthclientresponse); } else { return; } } public void validateNotAllowedParameters(OAuthClientResponse oauthclientresponse) throws OAuthProblemException { ArrayList arraylist = new ArrayList(); Iterator iterator = notAllowedParams.iterator(); do { if (!iterator.hasNext()) { break; } String s = (String)iterator.next(); if (!OAuthUtils.isEmpty(oauthclientresponse.getParam(s))) { arraylist.add(s); } } while (true); if (!arraylist.isEmpty()) { throw OAuthUtils.handleNotAllowedParametersOAuthException(arraylist); } else { return; } } public void validateParameters(OAuthClientResponse oauthclientresponse) throws OAuthProblemException { validateRequiredParameters(oauthclientresponse); validateNotAllowedParameters(oauthclientresponse); } public void validateRequiredParameters(OAuthClientResponse oauthclientresponse) throws OAuthProblemException { HashSet hashset = new HashSet(); Iterator iterator = requiredParams.entrySet().iterator(); do { if (!iterator.hasNext()) { break; } java.util.Map.Entry entry = (java.util.Map.Entry)iterator.next(); String s = (String)entry.getKey(); if (OAuthUtils.isEmpty(oauthclientresponse.getParam(s))) { hashset.add(s); } else { String as[] = (String[])entry.getValue(); if (!OAuthUtils.hasEmptyValues(as)) { int j = as.length; int i = 0; while (i < j) { String s1 = as[i]; if (OAuthUtils.isEmpty(oauthclientresponse.getParam(s1))) { hashset.add(s1); } i++; } } } } while (true); if (!hashset.isEmpty()) { throw OAuthUtils.handleMissingParameters(hashset); } else { return; } } }