protected void validateBasicAuthentication(OAuth2Message message, OAuth2Accessor accessor)
    throws IOException,OAuth2Exception {
        String authz = message.getHeader("Authorization");
        if (authz != null) {
            if(authz.substring(0,5).equals("Basic")){
                String userPass = new String(Base64.decodeBase64(authz.substring(6).getBytes()), "UTF-8");

                int loc = userPass.indexOf(":");
                if (loc == -1) {
                    OAuth2ProblemException problem = new OAuth2ProblemException(OAuth2.ErrorCode.INVALID_CLIENT);
                    throw problem;
                }

                String userPassedIn = userPass.substring(0, loc);
                String user = userPassedIn;
                String pass = userPass.substring(loc + 1);
                if(user!=null && pass!=null){
                    if (!user.equals(accessor.client.clientId)) {
                        OAuth2ProblemException problem = new OAuth2ProblemException(OAuth2.ErrorCode.INVALID_CLIENT);
                        throw problem;
                    }else{
                        if(!pass.equals(accessor.client.clientSecret)){
                            OAuth2ProblemException problem = new OAuth2ProblemException(OAuth2.ErrorCode.INVALID_CLIENT);
                            throw problem;
                        }

                        return;
                    }
                }

            }
        }
    }