New ticket registry cipher executor cipher executor.

@param registry         the registry
@param forceIfBlankKeys the force if blank keys
@param registryName     the registry name
@return the cipher executor
168465
public static CipherExecutor newTicketRegistryCipherExecutor(final EncryptionRandomizedSigningJwtCryptographyProperties registry,
                                                                 final boolean forceIfBlankKeys,
                                                                 final String registryName) {

        val enabled = FunctionUtils.doIf(
            !registry.isEnabled() && StringUtils.isNotBlank(registry.getEncryption().getKey()) && StringUtils.isNotBlank(registry.getSigning().getKey()),
            () -> {
                LOGGER.warn("Ticket registry encryption/signing for [{}] is not enabled explicitly in the configuration, yet signing/encryption keys "
                    + "are defined for ticket operations. CAS will proceed to enable the ticket registry encryption/signing functionality. "
                    + "If you intend to turn off this behavior, consider removing/disabling the signing/encryption keys defined in settings", registryName);
                return Boolean.TRUE;
            },
            registry::isEnabled
        ).get();


        if (enabled || forceIfBlankKeys) {
            LOGGER.debug("Ticket registry encryption/signing is enabled for [{}]", registryName);
            return new DefaultTicketCipherExecutor(
                registry.getEncryption().getKey(),
                registry.getSigning().getKey(),
                registry.getAlg(),
                registry.getSigning().getKeySize(),
                registry.getEncryption().getKeySize(),
                registryName);
        }
        LOGGER.info("Ticket registry encryption/signing is turned off. This MAY NOT be safe in a clustered production environment. "
            + "Consider using other choices to handle encryption, signing and verification of "
            + "ticket registry tickets, and verify the chosen ticket registry does support this behavior.");
        return CipherExecutor.noOp();
    }
10616
public static Cipher getCipher(final @NotNull Key key, int mode) {
        try {
            Cipher cipher = Cipher.getInstance(key.getAlgorithm());
            cipher.init(mode, key);
            return cipher;
        } catch (NoSuchAlgorithmException | InvalidKeyException | NoSuchPaddingException e) {
            throw new RuntimeException(e);
        }
    }
545489
public static synchronized Registry getRegistry(RegistryConfig registryConfig) {
        if (ALL_REGISTRIES.size() > 3) { // 超过3次 是不是配错了？
            if (LOGGER.isWarnEnabled()) {
                LOGGER.warn("Size of registry is greater than 3, Please check it!");
            }
        }
        try {
            // 注意：RegistryConfig重写了equals方法，如果多个RegistryConfig属性一样，则认为是一个对象
            Registry registry = ALL_REGISTRIES.get(registryConfig);
            if (registry == null) {
                ExtensionClass<Registry> ext = ExtensionLoaderFactory.getExtensionLoader(Registry.class)
                    .getExtensionClass(registryConfig.getProtocol());
                if (ext == null) {
                    throw ExceptionUtils.buildRuntime("registry.protocol", registryConfig.getProtocol(),
                        "Unsupported protocol of registry config !");
                }
                registry = ext.getExtInstance(new Class[] { RegistryConfig.class }, new Object[] { registryConfig });
                ALL_REGISTRIES.put(registryConfig, registry);
            }
            return registry;
        } catch (SofaRpcRuntimeException e) {
            throw e;
        } catch (Throwable e) {
            throw new SofaRpcRuntimeException(e.getMessage(), e);
        }
    }
1251942
public static SparkNameFunction fromConfig(Config config, String key, Registry registry) {
    return fromPatternList(config.getConfigList(key), registry);
  }
547272
public JwtTicketCipherExecutor getTokenTicketCipherExecutorForService(final RegisteredService registeredService) {
        val encryptionKey = getEncryptionKey(registeredService).orElse(StringUtils.EMPTY);
        val signingKey = getSigningKey(registeredService).orElse(StringUtils.EMPTY);
        return new JwtTicketCipherExecutor(encryptionKey, signingKey,
            StringUtils.isNotBlank(encryptionKey), StringUtils.isNotBlank(signingKey), 0, 0);
    }
395725
public static ClassInclusion classInIncludes(final String registryKey,final String classSimpleName){
		return new ClassInclusion(){
			@Override
			public Class<?>[] propose(){
				LinkedList<Class<?>>resultList = new LinkedList<Class<?>>();
				for(Class<?>clazz:ParserRegistry.getClassesIn(registryKey)){
					if(clazz.isAssignableFrom(ThirdPartyParseable.class)
							&& clazz.getSimpleName().contentEquals(classSimpleName)
							&&Modifier.isAbstract(clazz.getModifiers()))resultList.add(clazz);
					}//end for(...)
				return resultList.toArray(new Class[]{});
				}//end propose()
			};
		}
1290470
public List<String> readStringSubKeys(HKey hk, String key) throws RegistryException {
		return readStringSubKeys(hk, key, null);
	}
905298
public static void initUBL21 (@Nonnull final ValidationExecutorSetRegistry aRegistry)
  {
    ValueEnforcer.notNull (aRegistry, "Registry");

    // For better error messages
    LocationBeautifierSPI.addMappings (UBL21NamespaceContext.getInstance ());

    final boolean bNotDeprecated = false;
    for (final EUBL21DocumentType e : EUBL21DocumentType.values ())
    {
      final String sName = e.getLocalName ();
      final VESID aVESID = new VESID (GROUP_ID, sName.toLowerCase (Locale.US), VERSION_21);

      // No Schematrons here
      aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (aVESID,
                                                                             "UBL " + sName + " " + VERSION_21,
                                                                             bNotDeprecated,
                                                                             ValidationExecutorXSD.create (e)));
    }
  }
825698
public static void installDefaultRegistry(@NonNull final DefaultResolverRegistry registry) {
            /*
             * register built-in cards & mCells
             */
        MVHelper mvHelper = new MVHelper(new MVResolver());
        registry.setMVHelper(mvHelper);

        // built-in mCells
        registry.registerCell(TYPE_EXTENDED_VIEW_COMPACT, Card.PlaceholderCell.class,
            SimpleEmptyView.class);
        registry.registerCell(TYPE_EMPTY_VIEW_COMPACT, BaseCell.class, SimpleEmptyView.class);
        //registry.registerCell(TYPE_SIMPLE_IMAGE_COMPACT, Cell.class, SimpleImgView.class);
        registry.registerCell(TYPE_CAROUSEL_CELL_COMPACT, BannerView.class);
        registry.registerCell(TYPE_CONTAINER_BANNER, BannerView.class);
        registry.registerCell(TYPE_LINEAR_SCROLL_CELL_COMPACT, LinearScrollView.class);
        registry.registerCell(TYPE_CONTAINER_SCROLL, LinearScrollView.class);

        // built-in cards
        registry.registerCard(TYPE_CAROUSEL_COMPACT, BannerCard.class);
        registry.registerCard(TYPE_CONTAINER_BANNER, BannerCard.class);
        registry.registerCard(TYPE_SINGLE_COLUMN_COMPACT, SingleColumnCard.class);
        registry.registerCard(TYPE_CONTAINER_1C_FLOW, SingleColumnCard.class);
        registry.registerCard(TYPE_DOUBLE_COLUMN_COMPACT, DoubleColumnCard.class);
        registry.registerCard(TYPE_CONTAINER_2C_FLOW, DoubleColumnCard.class);
        registry.registerCard(TYPE_TRIPLE_COLUMN_COMPACT, TripleColumnCard.class);
        registry.registerCard(TYPE_CONTAINER_3C_FLOW, TripleColumnCard.class);
        registry.registerCard(TYPE_FOUR_COLUMN_COMPACT, FourColumnCard.class);
        registry.registerCard(TYPE_CONTAINER_4C_FLOW, FourColumnCard.class);
        registry.registerCard(TYPE_ONE_PLUS_N_COMPACT, OnePlusNCard.class);
        registry.registerCard(TYPE_CONTAINER_ON_PLUSN, OnePlusNCard.class);
        registry.registerCard(TYPE_FLOAT_COMPACT, FloatCard.class);
        registry.registerCard(TYPE_CONTAINER_FLOAT, FloatCard.class);
        registry.registerCard(TYPE_PIN_BOTTOM_COMPACT, PinBottomCard.class);
        registry.registerCard(TYPE_FIVE_COLUMN_COMPACT, FiveColumnCard.class);
        registry.registerCard(TYPE_CONTAINER_5C_FLOW, FiveColumnCard.class);
        registry.registerCard(TYPE_STICKY_COMPACT, StickyCard.class);
        registry.registerCard(TYPE_CONTAINER_STICKY, StickyCard.class);
        registry.registerCard(TYPE_STICKY_START_COMPACT, StickyCard.class);
        registry.registerCard(TYPE_STICKY_END_COMPACT, StickyEndCard.class);
        registry.registerCard(TYPE_PIN_TOP_COMPACT, PinTopCard.class);
        registry.registerCard(TYPE_CONTAINER_FIX, FixCard.class);
        registry.registerCard(TYPE_STAGGER_COMPACT, StaggeredCard.class);
        registry.registerCard(TYPE_CONTAINER_WATERFALL, StaggeredCard.class);

        registry.registerCard(TYPE_FUSION_TABS_COMPACT, FusionCard.class);
        registry.registerCard(TYPE_FLOW_COMPACT, FlowCard.class);
        registry.registerCard(TYPE_CONTAINER_FLOW, FlowCard.class);
        registry.registerCard(TYPE_SCROLL_FIX_COMPACT, ScrollFixCard.class);
        registry.registerCard(TYPE_CONTAINER_SCROLL_FIX, ScrollFixCard.class);

        registry.registerCard(TYPE_LINEAR_SCROLL_COMPACT, LinearScrollCard.class);
        registry.registerCard(TYPE_CONTAINER_SCROLL, LinearScrollCard.class);
        registry.registerCard(TYPE_SCROLL_FIX_BANNER_COMPACT, FixLinearScrollCard.class);
        registry.registerCard(TYPE_CONTAINER_SCROLL_FIX_BANNER, FixLinearScrollCard.class);

        // extend cards
        registry.registerCard(TYPE_FIX_COMPACT, FixCard.class);
        registry.registerCard(TYPE_GRID_COMPACT, GridCard.class);
        registry.registerCard(TYPE_LINEAR_COMPACT, LinearCard.class);
        registry.registerCard(TYPE_X_COLUMN_COMPACT, ColumnCard.class);
    }
508642
protected void registerMultifactorTrustedAuthentication(final FlowDefinitionRegistry flowDefinitionRegistry) {
        validateFlowDefinitionConfiguration(flowDefinitionRegistry);

        LOGGER.debug("Flow definitions found in the registry are [{}]", (Object[]) flowDefinitionRegistry.getFlowDefinitionIds());
        val flowId = Arrays.stream(flowDefinitionRegistry.getFlowDefinitionIds()).findFirst().get();
        LOGGER.debug("Processing flow definition [{}]", flowId);

        val flow = (Flow) flowDefinitionRegistry.getFlowDefinition(flowId);

        val state = getState(flow, CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM, ActionState.class);
        val transition = (Transition) state.getTransition(CasWebflowConstants.TRANSITION_ID_SUCCESS);
        val targetStateId = transition.getTargetStateId();
        transition.setTargetStateResolver(new DefaultTargetStateResolver(CasWebflowConstants.STATE_ID_VERIFY_TRUSTED_DEVICE));
        val verifyAction = createActionState(flow,
            CasWebflowConstants.STATE_ID_VERIFY_TRUSTED_DEVICE,
            createEvaluateAction(MFA_VERIFY_TRUST_ACTION_BEAN_ID));

        if (enableDeviceRegistration) {
            createTransitionForState(verifyAction, CasWebflowConstants.TRANSITION_ID_YES, CasWebflowConstants.STATE_ID_FINISH_MFA_TRUSTED_AUTH);
        } else {
            createTransitionForState(verifyAction, CasWebflowConstants.TRANSITION_ID_YES, CasWebflowConstants.STATE_ID_REAL_SUBMIT);
        }
        createTransitionForState(verifyAction, CasWebflowConstants.TRANSITION_ID_NO, targetStateId);

        createDecisionState(flow, CasWebflowConstants.DECISION_STATE_REQUIRE_REGISTRATION,
            isDeviceRegistrationRequired(),
            CasWebflowConstants.VIEW_ID_REGISTER_DEVICE, CasWebflowConstants.STATE_ID_REAL_SUBMIT);

        val submit = getState(flow, CasWebflowConstants.STATE_ID_REAL_SUBMIT, ActionState.class);
        val success = (Transition) submit.getTransition(CasWebflowConstants.TRANSITION_ID_SUCCESS);
        if (enableDeviceRegistration) {
            success.setTargetStateResolver(new DefaultTargetStateResolver(CasWebflowConstants.VIEW_ID_REGISTER_DEVICE));
        } else {
            success.setTargetStateResolver(new DefaultTargetStateResolver(CasWebflowConstants.STATE_ID_REGISTER_TRUSTED_DEVICE));
        }
        val viewRegister = createViewState(flow, CasWebflowConstants.VIEW_ID_REGISTER_DEVICE, "casMfaRegisterDeviceView");
        val viewRegisterTransition = createTransition(CasWebflowConstants.TRANSITION_ID_SUBMIT,
            CasWebflowConstants.STATE_ID_REGISTER_TRUSTED_DEVICE);
        viewRegister.getTransitionSet().add(viewRegisterTransition);

        val registerAction = createActionState(flow,
            CasWebflowConstants.STATE_ID_REGISTER_TRUSTED_DEVICE, createEvaluateAction(MFA_SET_TRUST_ACTION_BEAN_ID));
        createStateDefaultTransition(registerAction, CasWebflowConstants.STATE_ID_SUCCESS);

        if (submit.getActionList().size() == 0) {
            throw new IllegalArgumentException("There are no actions defined for the final submission event of " + flowId);
        }
        val act = submit.getActionList().iterator().next();
        val finishMfaTrustedAuth = createActionState(flow, CasWebflowConstants.STATE_ID_FINISH_MFA_TRUSTED_AUTH, act);
        val finishedTransition = createTransition(CasWebflowConstants.TRANSITION_ID_SUCCESS, CasWebflowConstants.STATE_ID_SUCCESS);
        finishMfaTrustedAuth.getTransitionSet().add(finishedTransition);
        createStateDefaultTransition(finishMfaTrustedAuth, CasWebflowConstants.STATE_ID_SUCCESS);
    }
141610
Cipher forMode(int ciphermode, SecretKey key, AlgorithmParameterSpec params) {
		final Cipher cipher = threadLocal.get();
		try {
			cipher.init(ciphermode, key, params);
			return cipher;
		} catch (InvalidKeyException e) {
			throw new IllegalArgumentException("Invalid key.", e);
		} catch (InvalidAlgorithmParameterException e) {
			throw new IllegalArgumentException("Algorithm parameter not appropriate for " + cipher.getAlgorithm() + ".", e);
		}
	}
168346
public ICommonsSet <TriggerKey> getTriggerKeys (final GroupMatcher <TriggerKey> matcher) throws SchedulerException
  {
    return m_aSched.getTriggerKeys (matcher);
  }
1282875
public RegistryCenter load(final RegistryCenterConfiguration regCenterConfig) {
        Preconditions.checkNotNull(regCenterConfig, "Registry center configuration cannot be null.");
        RegistryCenter result = newService(regCenterConfig.getType(), regCenterConfig.getProperties());
        result.init(regCenterConfig);
        return result;
    }
1324459
public static SecretKey generateKey(String cipherAlgorithm) throws NoSuchAlgorithmException {
        KeyGenerator keyGenerator = KeyGenerator.getInstance(cipherAlgorithm);
        keyGenerator.init(secureRandom);

        return keyGenerator.generateKey();
    }
651461
def __get_registry_key(self, key):
        
        import winreg

        root = winreg.OpenKey(
            winreg.HKEY_CURRENT_USER, r'SOFTWARE\GSettings\org\gnucash\general', 0, winreg.KEY_READ)
        [pathname, regtype] = (winreg.QueryValueEx(root, key))
        winreg.CloseKey(root)
        return pathname
933795
public final static void getBlowfishSignature(byte[] array, int offset, int keyid) {
        BlowfishEngine bf = new BlowfishEngine();
        // need to use little endian
        bf.init(true, new KeyParameter(BLOWFISH_KEYS[keyid]));
        byte[] output = new byte[8];
        bf.processBlock(array, offset, output, 0);
        System.arraycopy(output, 0, array, offset, 8);
    }
1067301
public static void initEHF (@Nonnull final ValidationExecutorSetRegistry aRegistry)
  {
    ValueEnforcer.notNull (aRegistry, "Registry");

    // For better error messages
    LocationBeautifierSPI.addMappings (UBL21NamespaceContext.getInstance ());

    final boolean bNotDeprecated = false;
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_EHF_CATALOGUE_1_0,
                                                                           "EHF Catalogue " +
                                                                                                  VID_EHF_CATALOGUE_1_0.getVersion (),
                                                                           bNotDeprecated,
                                                                           ValidationExecutorXSD.create (EUBL21DocumentType.CATALOGUE),
                                                                           _createXSLT (PeppolValidation370.CATALOGUE_RULES),
                                                                           _createXSLT (EHF_COMMON_V1),
                                                                           _createXSLT (CATALOGUE_V1_EHF)));
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_EHF_CATALOGUE_RESPONSE_1_0,
                                                                           "EHF Catalogue Response " +
                                                                                                           VID_EHF_CATALOGUE_RESPONSE_1_0.getVersion (),
                                                                           bNotDeprecated,
                                                                           ValidationExecutorXSD.create (EUBL21DocumentType.APPLICATION_RESPONSE),
                                                                           _createXSLT (PeppolValidation370.CATALOGUE_RESPONSE_RULES),
                                                                           _createXSLT (EHF_COMMON_V1),
                                                                           _createXSLT (CATALOGUE_RESPONSE_V1_EHF)));
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_EHF_CREDITNOTE_2_0,
                                                                           "EHF Creditnote " +
                                                                                                   VID_EHF_CREDITNOTE_2_0.getVersion (),
                                                                           bNotDeprecated,
                                                                           ValidationExecutorXSD.create (EUBL21DocumentType.CREDIT_NOTE),
                                                                           _createXSLT (PeppolValidation370.CREDIT_NOTE_RULES),
                                                                           _createXSLT (EHF_COMMON_V1),
                                                                           _createXSLT (CREDITNOTE_V2_EHF)));
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_EHF_DESPATCH_ADVICE_1_0,
                                                                           "EHF Despatch Advice " +
                                                                                                        VID_EHF_DESPATCH_ADVICE_1_0.getVersion (),
                                                                           bNotDeprecated,
                                                                           ValidationExecutorXSD.create (EUBL21DocumentType.DESPATCH_ADVICE),
                                                                           _createXSLT (PeppolValidation370.DESPATCH_ADVICE_RULES),
                                                                           _createXSLT (EHF_COMMON_V1),
                                                                           _createXSLT (DESPATCH_ADVICE_V1_EHF)));
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_EHF_INVOICE_2_0,
                                                                           "EHF Invoice " +
                                                                                                VID_EHF_INVOICE_2_0.getVersion (),
                                                                           bNotDeprecated,
                                                                           ValidationExecutorXSD.create (EUBL21DocumentType.INVOICE),
                                                                           _createXSLT (PeppolValidation370.INVOICE_RULES),
                                                                           _createXSLT (EHF_COMMON_V1),
                                                                           _createXSLT (INVOICE_V2_EHF)));
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_EHF_ORDER_1_0,
                                                                           "EHF Ordering " +
                                                                                              VID_EHF_ORDER_1_0.getVersion (),
                                                                           bNotDeprecated,
                                                                           ValidationExecutorXSD.create (EUBL21DocumentType.ORDER),
                                                                           _createXSLT (PeppolValidation370.ORDER_RULES),
                                                                           _createXSLT (EHF_COMMON_V1),
                                                                           _createXSLT (ORDER_V1_EHF)));
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_EHF_ORDER_AGREEMENT_1_0,
                                                                           "EHF Order Agreement " +
                                                                                                        VID_EHF_ORDER_AGREEMENT_1_0.getVersion (),
                                                                           bNotDeprecated,
                                                                           ValidationExecutorXSD.create (EUBL21DocumentType.ORDER_RESPONSE),
                                                                           _createXSLT (PeppolValidation370.ORDER_AGREEMENT_RULES),
                                                                           _createXSLT (EHF_COMMON_V1),
                                                                           _createXSLT (ORDER_AGREEMENT_V1_EHF)));
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_EHF_ORDER_RESPONSE_1_0,
                                                                           "EHF Order Response " +
                                                                                                       VID_EHF_ORDER_RESPONSE_1_0.getVersion (),
                                                                           bNotDeprecated,
                                                                           ValidationExecutorXSD.create (EUBL21DocumentType.ORDER_RESPONSE),
                                                                           _createXSLT (PeppolValidation370.ORDER_RESPONSE_RULES),
                                                                           _createXSLT (EHF_COMMON_V1),
                                                                           _createXSLT (ORDER_RESPONSE_V1_EHF)));
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_EHF_PUNCH_OUT_1_0,
                                                                           "EHF Punch Out " +
                                                                                                  VID_EHF_PUNCH_OUT_1_0.getVersion (),
                                                                           bNotDeprecated,
                                                                           ValidationExecutorXSD.create (EUBL21DocumentType.CATALOGUE),
                                                                           _createXSLT (PeppolValidation370.PUNCH_OUT_RULES),
                                                                           _createXSLT (EHF_COMMON_V1),
                                                                           _createXSLT (PUNCH_OUT_V1_EHF)));

    // Reminder is NOT in PEPPOL
    aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_EHF_REMINDER_1_1,
                                                                           "EHF Reminder " +
                                                                                                 VID_EHF_REMINDER_1_1.getVersion (),
                                                                           bNotDeprecated,
                                                                           ValidationExecutorXSD.create (EUBL21DocumentType.REMINDER),
                                                                           _createXSLT (EHF_COMMON_V1),
                                                                           _createXSLT (REMINDER_V1_EHF)));
  }