`
oywl2008
  • 浏览: 1000884 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Two piece of code

 
阅读更多
                if ( updateRequest.getAddConfigs().get(TokenConfigEnum.CLAIMS.getValue().toLowerCase()) != null && IAPConstants.SQUAREBRACKETS.equals(updateRequest.getRemoveConfigs().toString()) || Objects.nonNull(updateRequest.getRemoveConfigs()) && !updateRequest.getRemoveConfigs().isEmpty() && !updateRequest.getRemoveConfigs().contains(TokenConfigEnum.CLAIMS.getValue().toLowerCase()) ) {
                            identityTokenVO.getTokenConfigs()
                                    .stream()
                                    .forEach(config -> {
                                        if (TokenConfigEnum.CLAIMS.getValue().toLowerCase().equals(config.getKey().toLowerCase()) && config.getValue() != null ) {
                                            updateRequest.getAddConfigs().get(TokenConfigEnum.CLAIMS.getValue().toLowerCase()).addAll(config.getValue());
                                        }
                                    });
                }
                if ( updateRequest.getAddConfigs().get(TokenConfigEnum.CLAIMS.getValue().toUpperCase()) != null && IAPConstants.SQUAREBRACKETS.equals(updateRequest.getRemoveConfigs().toString()) ||  Objects.nonNull(updateRequest.getRemoveConfigs()) && !updateRequest.getRemoveConfigs().isEmpty() && !updateRequest.getRemoveConfigs().contains(TokenConfigEnum.CLAIMS.getValue().toLowerCase())){ 
                            identityTokenVO.getTokenConfigs()
                                    .stream()
                                    .forEach(config -> {
                                        if (TokenConfigEnum.CLAIMS.getValue().toUpperCase().equals(config.getKey().toUpperCase()) && config.getValue() != null ) {
                                            updateRequest.getAddConfigs().get(TokenConfigEnum.CLAIMS.getValue().toUpperCase()).addAll(config.getValue());
                                        }
                                    });
                }
                if ( updateRequest.getAddConfigs().get(TokenConfigEnum.DEVICE_AUTHENTICATION_KEYS.getValue().toLowerCase()) != null  && IAPConstants.SQUAREBRACKETS.equals(updateRequest.getRemoveConfigs().toString())  ||  Objects.nonNull(updateRequest.getRemoveConfigs()) && !updateRequest.getRemoveConfigs().isEmpty() && !updateRequest.getRemoveConfigs().contains(TokenConfigEnum.DEVICE_AUTHENTICATION_KEYS.getValue().toLowerCase())) {
                            identityTokenVO.getTokenConfigs()
                                    .stream()
                                    .forEach(config -> {
                                        if (TokenConfigEnum.DEVICE_AUTHENTICATION_KEYS.getValue().toLowerCase().equals(config.getKey().toLowerCase()) && config.getValue() != null ) {
                                            updateRequest.getAddConfigs().get(TokenConfigEnum.DEVICE_AUTHENTICATION_KEYS.getValue().toLowerCase()).addAll(config.getValue());
                                        }
                                    });
                }
                if ( updateRequest.getAddConfigs().get(TokenConfigEnum.DEVICE_AUTHENTICATION_KEYS.getValue().toUpperCase()) != null  &&  IAPConstants.SQUAREBRACKETS.equals(updateRequest.getRemoveConfigs().toString())  || Objects.nonNull(updateRequest.getRemoveConfigs()) && !updateRequest.getRemoveConfigs().isEmpty() && !updateRequest.getRemoveConfigs().contains(TokenConfigEnum.DEVICE_AUTHENTICATION_KEYS.getValue().toUpperCase())) {
                            identityTokenVO.getTokenConfigs()
                                    .stream()
                                    .forEach(config -> {
                                        if (TokenConfigEnum.DEVICE_AUTHENTICATION_KEYS.getValue().toUpperCase().equals(config.getKey().toUpperCase()) && config.getValue() != null ) {
                                            updateRequest.getAddConfigs().get(TokenConfigEnum.DEVICE_AUTHENTICATION_KEYS.getValue().toUpperCase()).addAll(config.getValue());
                                        }
                                    });
                }

 

private String toUpOrLowerCase( String str, String caseFlag ){
        if (IAPConstants.UPPERCASE.equals(caseFlag)) {
            return str.toUpperCase();
        } else if (IAPConstants.LOWERCASE.equals(caseFlag)) {
            return str.toLowerCase();
        } else { 
            return str;
        }
    }
    private void setTokenUpdateRequest(IdentityTokenVO identityTokenVO,TokenUpdateRequest updateRequest,String key , String caseFlag){
        identityTokenVO.getTokenConfigs()
        .stream()
        .forEach(config -> {
            if (key.equals(toUpOrLowerCase(config.getKey(),caseFlag)) && config.getValue() != null ) {
                updateRequest.getAddConfigs().get(key).addAll(config.getValue());
            }
        });
    }
    private boolean checkRemoveKey(TokenUpdateRequest updateRequest,String key,String caseFlag ){
        if (updateRequest.getRemoveConfigs() != null  && IAPConstants.SQUAREBRACKETS.equals(updateRequest.getRemoveConfigs().toString()) || Objects.nonNull(updateRequest.getRemoveConfigs()) && !updateRequest.getRemoveConfigs().isEmpty() && !updateRequest.getRemoveConfigs().contains(toUpOrLowerCase(key,caseFlag))){
            return true;
        } else { 
            return false;
        } 
    }

    private void setTokenClaimAndDeviceAuthenticationKey(IdentityTokenVO identityTokenVO,TokenUpdateRequest updateRequest){
        String claims = TokenConfigEnum.CLAIMS.getValue();
        String deviceAuthKey = TokenConfigEnum.DEVICE_AUTHENTICATION_KEYS.getValue();
        if ( updateRequest.getAddConfigs().get(claims.toLowerCase()) != null && checkRemoveKey(updateRequest,claims,IAPConstants.LOWERCASE) ) {
            setTokenUpdateRequest(identityTokenVO,updateRequest,claims.toLowerCase(),IAPConstants.LOWERCASE);
        }
        if ( updateRequest.getAddConfigs().get(claims.toUpperCase()) != null && checkRemoveKey(updateRequest,claims,IAPConstants.UPPERCASE) ){ 
            setTokenUpdateRequest(identityTokenVO,updateRequest,claims.toUpperCase(),IAPConstants.UPPERCASE);
        }
        if ( updateRequest.getAddConfigs().get(deviceAuthKey.toLowerCase()) != null && checkRemoveKey(updateRequest,deviceAuthKey,IAPConstants.LOWERCASE) ) {
            setTokenUpdateRequest(identityTokenVO,updateRequest,deviceAuthKey.toLowerCase(),IAPConstants.LOWERCASE);
        }
        if ( updateRequest.getAddConfigs().get(deviceAuthKey.toUpperCase()) != null && checkRemoveKey(updateRequest,deviceAuthKey,IAPConstants.UPPERCASE) ){ 
            setTokenUpdateRequest(identityTokenVO,updateRequest,deviceAuthKey.toUpperCase(),IAPConstants.UPPERCASE);
        }
    }
    

 

 

 

 

 

 

 

 

  • 大小: 223.9 KB
  • 大小: 263 KB
  • 大小: 214.8 KB
分享到:
评论

相关推荐

    Computer System Structures

    On most computer systems, a small piece of code known as the bootstrap program or bootstrap loader locates the kernel, loads it into main memory, and starts its execution. Some computer systems, such...

    Making Software - What Really Works, and Why We Believe It

    Making Software - What Really Works, and Why We Believe It. Does the MMR vaccine cause autism... Is it possible to predict the likely number of bugs in a piece of code before it’s released? If so, how?

    Smart Mobile Studio Enterprise v2.0 Build 723 Cracked

    This means that a traditional HTML5 project which, under native javascript would involve thousands of lines of code, is a piece of cake under Smart. As a language object pascal is easy on the eyes, ...

    a project model for the FreeBSD Project.7z

    Examples of outcomes are a piece of software, a decision made or a report written. 2.5. FreeBSD When saying “FreeBSD” we will mean the BSD derivative UNIX-like operating system FreeBSD, whereas ...

    stanford tagger

    A Part-Of-Speech Tagger (POS Tagger) is a piece of software that reads text in some language and assigns parts of speech to each word (and other token), such as noun, verb, adjective, etc., although ...

    Learning Angular, 2nd Edition-Packt Publishing(2017).epub

    Chapter 11, Angular Material, takes you through Angular Material, which not only offers a beautiful interface but also comes with a bunch of components that will make it a piece of cake to quickly ...

    Deep Learning, Vol. 1: From Basics to Practice

    You don’t need to choose a particular programming language, or library, or piece of hardware, because our approach is largely independent of those things. Our focus is on the principles and ...

    Deep Learning, Vol. 2: From Basics to Practice

    You don’t need to choose a particular programming language, or library, or piece of hardware, because our approach is largely independent of those things. Our focus is on the principles and ...

    Ruby Cookbook, 2nd Edition

    This is a book of recipes: solutions to common problems, copy-and-paste code snip‐ pets, explanations, examples, and short tutorials. This book is meant to save you time. Time, as they say, is money,...

    VB编程资源大全(英文源码 网络)

    dauntless.zip This is an exceptionally good piece of code. One program runs on a machine somewhere, and the other on your machine. You can then send commands to the other machine, take screen ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    The goal of this guide is to manage this complexity by describing in detail the dos and don'ts of writing C++ code. These rules exist to keep the code base manageable while still allowing coders to ...

    Python_Real-World+Data+Science_A+Course+in+Four+Modules-2016.pdf

    If you write a piece of software that allows people to buy clothes online, you will have to represent real people, real clothes, real brands, sizes, and so on and so forth, within the boundaries of ...

    Packt.Swift.Developing.iOS.Applications.2016

    The third and the last module of our course will take an example-based approach where each concept covered is supported by example code to not only give you a good understanding of the concept, but ...

    BobBuilder_app

    Two mode of operation Flush immediate and Deferred ( the latter being faster at the expense of the risk of non-clean shutdown data loss). Enumerate the index is supported. Enumerate the Storage file ...

    Making Games with Python & PyGame.pdf(with code)

    T ABLE OF C ONTENTS Who is this book for? ........................................................................................................................ i About This Book ......................

    LCTF软件备份VariSpec™ Liquid Crystal Tunable Filters

    c) Place a copy of vsdrvr.dll in either the folder that includes the executable code for the program being developed; or, preferably, in the windows system folder. Failures in step a) will lead to ...

    C# Game Programming Cookbook for Unity 3D - 2014

    Acknowledgments xiii Introduction xv 1. Making Games the Modular Way 1 1.1 Important Programming Concepts.....................................2 1.1.1 Manager and Controller Scripts.......................

    ASP.NET Core 1.1 For Beginners: How to Build a MVC Website

    The goal is to get you familiar with ASP.NET Core 1.1 by adding middleware and services one piece at a time, building a basic application. Then you will build a second MVC application using a ...

Global site tag (gtag.js) - Google Analytics