<p>
Encryption context to use when the data is reencrypted.
</p>

@param destinationEncryptionContext
Encryption context to use when the data is reencrypted.
763021
public void setDestinationEncryptionContext(java.util.Map<String, String> destinationEncryptionContext) {
        this.destinationEncryptionContext = destinationEncryptionContext == null ? null : new com.ibm.cloud.objectstorage.internal.SdkInternalMap<String, String>(
                destinationEncryptionContext);
    }
967681
public void encrypt(byte[] password) throws GeneralSecurityException {

        if (isEncrypted()) {
            return;
        }

        if (this.encAlg == null) {
            setEncryptionAlgorithm("DES-EDE3-CBC");
        }

        if (this.ivData == null) {
            generateIV();
        }

        Key key = getSecretKey(password, this.initializationVector.getIV());

        Cipher cipher = getCipher();
        cipher.init(Cipher.ENCRYPT_MODE, key, this.initializationVector);

        /* encrypt the raw PKCS11 */

        this.keyData = cipher.doFinal(getEncoded(this.intKey));
        this.isEncrypted = true;
        this.encodedKey = null;
    }
480655
@Override
    public synchronized void setCorrupt(boolean newCorrupt)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "setCorrupt", Boolean.valueOf(newCorrupt));

        boolean oldCorrupt = _isCorruptOrIndoubt;
        _isCorruptOrIndoubt = newCorrupt;

        // PK54812 We need to pass this through to the destination manager to
        // actually change the state of the destination.
        if (newCorrupt && !oldCorrupt)
        {
            destinationManager.corruptDestination(this);

            // Log a message with details of the destination that is corrupt
            SibTr.info(tc_cwsik, "DELIVERY_ERROR_SIRC_27",
                       new Object[] { getName() + " " + getUuid().toString() });
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "setCorrupt");
    }
1126582
public void startSecuritySettingsActivity(Context context) {
        if (!startDelegateActivity(context, delegate.getSecuritySettingsIntent(), null)) {
            startActivity(context, null, SecuritySettingsActivity.class);
        }
    }
1065328
private void send(Message message, String destinationName, TestContext context) {
        if (log.isDebugEnabled()) {
            log.debug("Sending JMS message to destination: '" + destinationName + "'");
        }

        endpointConfiguration.getJmsTemplate().send(destinationName, session -> {
            javax.jms.Message jmsMessage = endpointConfiguration.getMessageConverter().createJmsMessage(message, session, endpointConfiguration, context);
            endpointConfiguration.getMessageConverter().convertOutbound(jmsMessage, message, endpointConfiguration, context);
            return jmsMessage;
        });

        log.info("Message was sent to JMS destination: '" + destinationName + "'");
    }
1042349
public void notifyReceiveAllowed(DestinationHandler destinationHandler)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "notifyReceiveAllowed", new Object[] {destinationHandler});
      
    if(isPubSub())
    {
      // Notify consumers on this localization 
      SubscriptionTypeFilter filter = new SubscriptionTypeFilter();  
      filter.LOCAL = Boolean.TRUE;  
      SIMPIterator itr = getSubscriptionIndex().iterator(filter);  
      while(itr.hasNext())  
      {  
        ControllableSubscription subscription = (ControllableSubscription)itr.next(); 
        ConsumerDispatcher cd = (ConsumerDispatcher)subscription.getOutputHandler();
        if(cd != null) 
          cd.notifyReceiveAllowed(destinationHandler); 
      } 
      itr.finished(); 
    }
    else
    {
      //tell the local consumer dispatcher that this destinations receiveAllowed has changed
      ConsumerDispatcher cm = (ConsumerDispatcher)getLocalPtoPConsumerManager();
      if (cm != null)
      {
        cm.notifyReceiveAllowed(destinationHandler);
      }
    }

    //tell the any RME remote consumer dispatchers that this destinations receiveAllowed has changed
    notifyReceiveAllowedRCD(destinationHandler);
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "notifyReceiveAllowed");
  }
764554
@Override
	public byte[] encrypt(byte[] data, KeyType keyType) throws CryptoException {
		if (KeyType.PublicKey != keyType) {
			throw new IllegalArgumentException("Encrypt is only support by public key");
		}
		ckeckKey(keyType);

		lock.lock();
		final SM2Engine engine = getEngine();
		try {
			engine.init(true, new ParametersWithRandom(getCipherParameters(keyType)));
			return engine.processBlock(data, 0, data.length);
		} finally {
			lock.unlock();
		}
	}
102176
@Override
    public void init(Context context) {
        try {
            // get the cookie that contains session information:
            Cookie cookie = context.request().cookie(applicationCookiePrefix
                    + SESSION_SUFFIX);

            // check that the cookie is not empty:
            if (cookie != null && cookie.value() != null
                    && !"".equals(cookie.value().trim())
                    && cookie.value().contains("-")) {
                String value = cookie.value();
                // the first substring until "-" is the sign
                String sign = value.substring(0, value.indexOf('-'));

                // rest from "-" until the end is the payload of the cookie
                String payload = value.substring(value.indexOf('-') + 1);

                if (CookieDataCodec.safeEquals(sign,
                        crypto.sign(payload))) {
                    CookieDataCodec.decode(data, payload);
                } else {
                    LOGGER.warn("Invalid session cookie - signature check failed");
                }

                // Make sure session contains valid timestamp
                if (!data.containsKey(TIMESTAMP_KEY)) {
                    data.clear();
                } else {
                    if (Long.parseLong(data.get(TIMESTAMP_KEY))
                            + sessionExpireTimeInMs < System
                            .currentTimeMillis()) {
                        // Session expired
                        sessionDataHasBeenChanged = true;
                        data.clear();
                    }
                }

                // Everything's alright => prolong session
                data.put(TIMESTAMP_KEY, Long.toString(System.currentTimeMillis()));
            }

        } catch (UnsupportedEncodingException unsupportedEncodingException) {
            LOGGER.error("Encoding exception - this must not happen", unsupportedEncodingException);
        }
    }
1319886
public static void set(Headers headers, Object destination) {

    Field[] publicFields;
    Field[] privateFields;
    Field[] fields;

    Class<?> cls = destination.getClass();
    publicFields = cls.getFields();
    privateFields = cls.getDeclaredFields();
    fields = new Field[publicFields.length + privateFields.length];
    System.arraycopy(publicFields, 0, fields, 0, publicFields.length);
    System.arraycopy(privateFields, 0, fields, publicFields.length, privateFields.length);

    for (Field field : fields) {
      Annotation annotation = field.getAnnotation(Header.class);
      if (annotation == null) {
        continue;
      }

      Header httpHeader = (Header) annotation;
      String value = httpHeader.value();
      String setter = httpHeader.setter();
      if (setter.isEmpty()) {
        // assume setter name as 'setFieldName'
        String name = field.getName();
        setter = "set" + name.substring(0, 1).toUpperCase(Locale.US) + name.substring(1);
      }

      try {
        Method setterMethod = cls.getMethod(setter, new Class[]{String.class});
        String valueString = headers.get(value);
        if (valueString != null) {
          setterMethod.invoke(destination, valueString);
        }
      } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException
               | IllegalArgumentException e) {
        LOGGER.log(Level.SEVERE, "exception occured: ", e);
        LOGGER.log(Level.INFO, "setter: " + setter);
        LOGGER.log(Level.INFO, "annotation: " + value);
        LOGGER.log(Level.INFO, "value: " + headers.get(value));
      }
    }
  }
288518
@Deprecated
    private void checkConsumerAuthority(DestinationHandler destination,
                                        String destinationName,
                                        String discriminator,
                                        SecurityContext secContext,
                                        boolean system)

                    throws SIDiscriminatorSyntaxException, SINotAuthorizedException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(
                        tc,
                        "checkConsumerAuthority",
                        new Object[] { destination,
                                      destinationName,
                                      discriminator,
                                      secContext,
                                      Boolean.valueOf(system) });

        // Check authority to consume from a destination
        if (!destination.isTemporary() && !system)
        {
            boolean allowed = true;
            boolean failingOpisIdentityAdopter = false;
            // Perform the alternate user check first. If an alternateUser was set then we 
            // need to determine whether the connected subject has the authority to perform
            // alternate user checks.

            if (secContext.isAlternateUserBased())
            {
                if (!destination.checkDestinationAccess(secContext,
                                                        OperationType.IDENTITY_ADOPTER))
                {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                        SibTr.debug(tc, "checkConsumerAuthority", "not authorized to perform alternate user checks on this destination");

                    allowed = false;
                    failingOpisIdentityAdopter = true;
                }
            }

            if (allowed) // ok so far
            {
                // Check if its the default exc dest
                if (destinationName.startsWith(SIMPConstants.SYSTEM_DEFAULT_EXCEPTION_DESTINATION_PREFIX))
                {
                    //If its a def exc dest see if we have access to the prefix.
                    if (!_messageProcessor.
                                    getAccessChecker().
                                    checkDestinationAccess(secContext,
                                                           null, // home bus  
                                                           SIMPConstants.SYSTEM_DEFAULT_EXCEPTION_DESTINATION_PREFIX,
                                                           OperationType.RECEIVE))
                    {
                        allowed = false;
                    }
                }
                else
                {
                    if (!destination.checkDestinationAccess(secContext,
                                                            OperationType.RECEIVE))
                    {
                        allowed = false;
                    }
                }
            }

            if (!allowed)
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(tc, "checkConsumerAuthority", "not authorized to consume from this destination");

                // Get the username
                String userName = secContext.getUserName(failingOpisIdentityAdopter);
                OperationType operationType =
                                failingOpisIdentityAdopter ? OperationType.IDENTITY_ADOPTER :
                                                OperationType.RECEIVE;

                // Build the message for the Exception and the Notification
                String nlsMessage =
                                nls.getFormattedMessage("USER_NOT_AUTH_RECEIVE_ERROR_CWSIP0309",
                                                        new Object[] { destination.getName(),
                                                                      userName },
                                                        null);

                // Fire a Notification if Eventing is enabled
                _accessChecker.
                                fireDestinationAccessNotAuthorizedEvent(destination.getName(),
                                                                        userName,
                                                                        operationType,
                                                                        nlsMessage);

                // Thrown if user denied access to destination
                throw new SINotAuthorizedException(nlsMessage);
            }
        }

        // If the discriminator is non-wildcarded, we can check authority to consume on
        // the discriminator.
        if (discriminator != null &&
            !_messageProcessor.getMessageProcessorMatching().isWildCarded(discriminator))
        {
            // set the discriminator into the security context
            secContext.setDiscriminator(discriminator);
            if (!destination.checkDiscriminatorAccess(secContext,
                                                      OperationType.RECEIVE))
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(tc, "checkConsumerAuthority", "not authorized to consume from this destination's discriminator");
                // Write an audit record if access is denied
                SibTr.audit(tc, nls.getFormattedMessage(
                                                        "USER_NOT_AUTH_RECEIVE_ERROR_CWSIP0310",
                                                        new Object[] { destination.getName(),
                                                                      discriminator,
                                                                      secContext.getUserName(false) },
                                                        null));

                // Thrown if user denied access to destination
                throw new SINotAuthorizedException(
                                nls.getFormattedMessage(
                                                        "USER_NOT_AUTH_RECEIVE_ERROR_CWSIP0310",
                                                        new Object[] { destination.getName(),
                                                                      discriminator,
                                                                      secContext.getUserName(false) },
                                                        null));
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "checkConsumerAuthority");
    }
70475
private boolean checkConsumerDiscriminatorAccess(DestinationHandler destination,
                                                     String discriminator,
                                                     SecurityContext secContext)

                    throws SIDiscriminatorSyntaxException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(
                        tc,
                        "checkConsumerDiscriminatorAccess",
                        new Object[] { destination,
                                      discriminator,
                                      secContext });

        boolean allowed = true;
        // If the discriminator is non-wildcarded, we can check authority to consume on
        // the discriminator.
        if (discriminator != null &&
            !_messageProcessor.getMessageProcessorMatching().isWildCarded(discriminator))
        {
            // set the discriminator into the security context
            secContext.setDiscriminator(discriminator);
            if (!destination.checkDiscriminatorAccess(secContext,
                                                      OperationType.RECEIVE))
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(tc, "checkConsumerDiscriminatorAccess", "not authorized to consume from this destination's discriminator");
                // Write an audit record if access is denied
                SibTr.audit(tc, nls.getFormattedMessage(
                                                        "USER_NOT_AUTH_RECEIVE_ERROR_CWSIP0310",
                                                        new Object[] { destination.getName(),
                                                                      discriminator,
                                                                      secContext.getUserName(false) },
                                                        null));

                allowed = false;
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "checkConsumerDiscriminatorAccess", Boolean.valueOf(allowed));
        return allowed;
    }
394682
public <T> T convert(ConversionContext context, Object source,
			TypeReference<T> destinationType) throws ConverterException {
		try {
			return (T) multiConverter.convert(context, source, destinationType);
		} catch (ConverterException e) {
			throw e;
		} catch (Exception e) {
			// There is a problem with one converter. This should not happen.
			// Either there is a bug in this converter or it is not properly
			// configured
			throw new ConverterException(
					MessageFormat
							.format(
									"Could not convert given object with class ''{0}'' to object with type signature ''{1}''",
									source == null ? "null" : source.getClass()
											.getName(), destinationType), e);
		}
	}
190965
public void setProxyIdpAuthenticationContextLookupStrategy(
      final Function<AuthenticationContext, ProxyIdpAuthenticationContext> strategy) {
    ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
    this.proxyIdpAuthenticationContextLookupStrategy = Constraint.isNotNull(strategy,
      "ProxyIdPAuthenticationContext lookup strategy cannot be null");
  }
1036144
public static String encrypt(Key key, String content) throws Exception {
        try {
            Cipher cipher = Cipher.getInstance(CRYPTO_ALGORITHM);
            cipher.init(Cipher.ENCRYPT_MODE, key);
            return Base64.encodeBase64String(cipher.doFinal(content.getBytes()));
        } catch (Exception e) {
            log.error("Error while encrypting", e);
            throw e;
        }
    }
786102
public User setUserContext(User userContext) throws InvalidArgumentException {

        if (null == cryptoSuite) {
            throw new InvalidArgumentException("No cryptoSuite has been set.");
        }
        userContextCheck(userContext);

        User ret = this.userContext;
        this.userContext = userContext;

        logger.debug(
                format("Setting user context to MSPID: %s user: %s", userContext.getMspId(), userContext.getName()));

        return ret;
    }
849862
public DestinationDefinition createDestinationDefinition(
                                                             DestinationType destinationType, String destinationName) {
        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.entry(tc, "createDestinationDefinition", new Object[] {
                                                                         destinationType, destinationName });

        JsAdminFactory factory = (JsAdminFactory) getSingletonInstance(SIMPConstants.JS_ADMIN_FACTORY);

        DestinationDefinition destDef = factory.createDestinationDefinition(
                                                                            destinationType, destinationName);

        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.exit(tc, "createDestinationDefinition", destDef);

        return destDef;
    }
999655
private void initializeEncryptionProvider() {
		if (key != null) {
			try {
				encryptionProvider = EncryptionProviderFactory.getProvider(key);
			} catch (UnsupportedKeySizeException e) {
				throw new RuntimeCryptoException(e.getMessage(), e);
			} catch (UnsupportedAlgorithmException e) {
				throw new RuntimeCryptoException(e.getMessage(), e);
			}
		}
	}