Creates an audit entry for the 'contract broken' event.
@param bean the bean
@param securityContext the security context
@return the audit entry
7482
public static AuditEntryBean contractBrokenToApi(ContractBean bean, ISecurityContext securityContext) {
        AuditEntryBean entry = newEntry(bean.getApi().getApi().getOrganization().getId(), AuditEntityType.Api, securityContext);
        entry.setWhat(AuditEntryType.BreakContract);
        entry.setEntityId(bean.getApi().getApi().getId());
        entry.setEntityVersion(bean.getApi().getVersion());
        ContractData data = new ContractData(bean);
        entry.setData(toJSON(data));
        return entry;
    }
1289628
public static ContractBean unmarshallContract(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        ContractBean bean = new ContractBean();
        bean.setId(asLong(source.get("id")));
        bean.setCreatedBy(asString(source.get("createdBy")));
        bean.setCreatedOn(asDate(source.get("createdOn")));
        postMarshall(bean);
        return bean;
    }
570432
@Internal
    @SuppressWarnings({"WeakerAccess", "unused"})
    @UsedByGeneratedCode
    protected Object injectBean(BeanResolutionContext resolutionContext, BeanContext context, Object bean) {
        return bean;
    }
725604
@Override
    public JMSContext createContext(String userName, String password) throws JMSRuntimeException, JMSSecurityRuntimeException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createContext", new Object[] { userName, password });

        JMSContext jmsContext = null;
        try {
            // Pass sessionMode as AUTO_ACKNOWLEDGE. The sessionMode is used to create a session.In simplified
            // API(JMS 2.0), AUTO_ACKNOWLEDGE is the default sessionMode 
            jmsContext = createContext(userName, password, JMSContext.AUTO_ACKNOWLEDGE);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createContext");
        }
        return jmsContext;
    }
775482
@Override
    public void contextInitialized(ServletContextEvent contextEvent) {
        configSupport = new ServletContexConfigSupport();
        if (configSupport.hasHandlers(contextEvent.getServletContext())) {
            AuditManager.startWithConfiguration(configSupport.loadConfig(contextEvent.getServletContext()));
        } else {
            AuditManager.getInstance();
        }
    }
255567
@SuppressWarnings("unchecked")
	public <T> Optional<AuditableBeanWrapper<T>> getBeanWrapperFor(T source) {

		Assert.notNull(source, "Source must not be null!");

		return Optional.of(source).map(it -> {

			if (it instanceof Auditable) {
				return (AuditableBeanWrapper<T>) new AuditableInterfaceBeanWrapper(
						(Auditable<Object, ?, TemporalAccessor>) it);
			}

			AnnotationAuditingMetadata metadata = AnnotationAuditingMetadata
					.getMetadata(it.getClass());

			if (metadata.isAuditable()) {
				return new ReflectionAuditingBeanWrapper<T>(it);
			}

			return null;
		});
	}
164783
protected Service restoreAuthenticationRequestInContext(final RequestContext requestContext,
                                                            final J2EContext webContext,
                                                            final String clientName) {
        val logoutEndpoint = isLogoutRequest(webContext.getRequest());
        if (logoutEndpoint) {
            return null;
        } else {
            try {
                val client = (BaseClient<Credentials, CommonProfile>) this.clients.findClient(clientName);
                return delegatedClientWebflowManager.retrieve(requestContext, webContext, client);
            } catch (final Exception e) {
                LOGGER.error(e.getMessage(), e);
            }
            throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, "Service unauthorized");
        }
    }
539204
@Override
    public void audit(final LoggingEvent e) {
        try {
            logger.info(MarkerFactory.getMarker(AUDIT), serialize(e));
        } catch (Exception ex) {
            throw new RuntimeException("unable to serialize event", ex);
        }
    }
172026
public static String validateSecurityContext(Subject subject, final byte[] serviceTicket) throws GSSException {

        // Accept the context and return the client principal name.
        return Subject.doAs(subject, (PrivilegedAction<String>)() -> {
            try {
                // Identify the server that communications are being made
                // to.
                GSSManager manager = GSSManager.getInstance();
                GSSContext context = manager.createContext((GSSCredential) null);
                context.acceptSecContext(serviceTicket, 0, serviceTicket.length);
                return context.getSrcName().toString();
            } catch (Exception e) {
                log.error(Util.getMessage("Krb5TokenKerberosContextProcessingException"),e);
                return null;
            }
        });
    }
211899
@Override
    protected WeldCreationalContext<T> getCreationalContext(ManagedObjectInvocationContext<T> invocationContext, boolean nonContextual) throws ManagedObjectException {

        ManagedObjectContext moc;
        // for managed bean case, if invocation context is not null, use that
        if (invocationContext != null) {
            moc = invocationContext.getManagedObjectContext();

        } else {
            //otherwise, use the one created when creating this object(annotated with scope)
            moc = createContext(nonContextual);
        }
        @SuppressWarnings("unchecked")
        WeldCreationalContext<T> creationalContext = moc.getContextData(WeldCreationalContext.class);
        return creationalContext;
    }
978076
public static SecurityContext getSecurityContext() {
        Session session = ExecutionContext.getSession();
        @SuppressWarnings("resource")
        WebSocketSession ws = session == null ? null : session.getSocket();
        return ws == null ? null
                : (SecurityContext) ws.getAttributes().get(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
    }
813804
public static List<Audit> findByHostName(EntityManager em, String hostName) {
        requireArgument(em != null, "Entity manager cannot be null.");
        requireArgument(hostName != null && !hostName.isEmpty(), "Host name cannot be null or empty.");

        TypedQuery<Audit> query = em.createNamedQuery("Audit.findByHostName", Audit.class);

        try {
            query.setParameter("hostName", hostName);
            return query.getResultList();
        } catch (NoResultException ex) {
            return new ArrayList<Audit>(0);
        }
    }
1275110
public static AuditEntryBean contractCreatedToApi(ContractBean bean, ISecurityContext securityContext) {
        AuditEntryBean entry = newEntry(bean.getApi().getApi().getOrganization().getId(), AuditEntityType.Api, securityContext);
        // Ensure the order of contract-created events are deterministic by adding 1 ms to this one
        entry.setCreatedOn(new Date(entry.getCreatedOn().getTime() + 1));
        entry.setWhat(AuditEntryType.CreateContract);
        entry.setEntityId(bean.getApi().getApi().getId());
        entry.setEntityVersion(bean.getApi().getVersion());
        ContractData data = new ContractData(bean);
        entry.setData(toJSON(data));
        return entry;
    }
431356
@Before("@within(org.audit4j.core.annotation.Audit) || @annotation(org.audit4j.core.annotation.Audit)")
    public void audit(final JoinPoint jointPoint) throws Throwable {

        MethodSignature methodSignature = (MethodSignature) jointPoint.getSignature();
        Method method = methodSignature.getMethod();

        if (method.getDeclaringClass().isInterface()) {
            try {
                method = jointPoint.getTarget().getClass()
                        .getDeclaredMethod(jointPoint.getSignature().getName(), method.getParameterTypes());
            } catch (final SecurityException exception) {
                throw new Audit4jRuntimeException(
                        "Exception occured while proceding Audit Aspect in Audit4j Spring Integration", exception);
            } catch (final NoSuchMethodException exception) {
                throw new Audit4jRuntimeException(
                        "Exception occured while proceding Audit Aspect in Audit4j Spring Integration", exception);
            }
        }

        AuditManager.getInstance().audit(jointPoint.getTarget().getClass(), method, jointPoint.getArgs());
    }
360164
private org.ironjacamar.core.api.deploymentrepository.Recovery
      createRecovery(javax.resource.spi.ManagedConnectionFactory mcf, ConnectionDefinition cd) throws Throwable
   {
      Boolean padXid = Defaults.PAD_XID;
      Boolean isSameRMOverride = Defaults.IS_SAME_RM_OVERRIDE;
      Boolean wrapXAResource = Defaults.WRAP_XA_RESOURCE;
      String securityDomain = null;
      RecoveryPlugin plugin = null;
      Collection<org.ironjacamar.core.api.deploymentrepository.ConfigProperty> dcps = null;
      
      if (transactionIntegration.getRecoveryRegistry() == null)
         return null;

      if (subjectFactory == null)
         return null;

      if (cd.getRecovery() != null && cd.getRecovery().isNoRecovery())
         return null;

      // Check security domain
      if (cd.getRecovery() != null && cd.getRecovery().getCredential() != null)
         securityDomain = cd.getRecovery().getCredential().getSecurityDomain();

      if (securityDomain == null && cd.getSecurity() != null)
         securityDomain = cd.getSecurity().getSecurityDomain();

      if (securityDomain == null)
         return null;

      if (cd.getRecovery() != null && cd.getRecovery().getPlugin() != null)
      {
         Extension extension = cd.getRecovery().getPlugin();
         Collection<org.ironjacamar.common.api.metadata.spec.ConfigProperty> configProperties =
            new ArrayList<org.ironjacamar.common.api.metadata.spec.ConfigProperty>();

         for (Map.Entry<String, String> property : extension.getConfigPropertiesMap().entrySet())
         {
            org.ironjacamar.common.api.metadata.spec.ConfigProperty c =
               new org.ironjacamar.common.metadata.spec.ConfigPropertyImpl(null,
                                                                           new XsdString(property.getKey(), null),
                                                                           XsdString.NULL_XSDSTRING,
                                                                           new XsdString(property.getValue(), null),
                                                                           Boolean.FALSE, Boolean.FALSE,
                                                                           Boolean.FALSE,
                                                                           null, false,
                                                                           null, null, null, null);

            configProperties.add(c);
         }

         Class<?> clz = Class.forName(extension.getClassName(), true, mcf.getClass().getClassLoader());
         plugin = (RecoveryPlugin)clz.newInstance();
         
         dcps = injectConfigProperties(plugin, configProperties, null, plugin.getClass().getClassLoader());
      }

      if (plugin == null)
         plugin = new DefaultRecoveryPlugin();

      if (dcps == null)
         dcps = new ArrayList<>(1);

      if (cd.getPool() != null)
      {
         org.ironjacamar.common.api.metadata.common.XaPool xaPool =
            (org.ironjacamar.common.api.metadata.common.XaPool)cd.getPool();

         if (xaPool.isPadXid() != null)
            padXid = xaPool.isPadXid();

         if (xaPool.isIsSameRmOverride() != null)
            isSameRMOverride = xaPool.isIsSameRmOverride();

         if (xaPool.isWrapXaResource() != null)
            wrapXAResource = xaPool.isWrapXaResource();
      }

      XAResourceRecovery r = transactionIntegration.createXAResourceRecovery(mcf,
                                                                             padXid,
                                                                             isSameRMOverride,
                                                                             wrapXAResource,
                                                                             securityDomain,
                                                                             subjectFactory,
                                                                             plugin,
                                                                             null);

      return new RecoveryImpl(plugin.getClass().getName(), dcps, r, cd.getJndiName(),
                              transactionIntegration.getRecoveryRegistry());
   }
1343703
public static AuditEntryBean apiVersionUpdated(ApiVersionBean bean, EntityUpdatedData data,
            ISecurityContext securityContext) {
        if (data.getChanges().isEmpty()) {
            return null;
        }
        AuditEntryBean entry = newEntry(bean.getApi().getOrganization().getId(), AuditEntityType.Api, securityContext);
        entry.setEntityId(bean.getApi().getId());
        entry.setEntityVersion(bean.getVersion());
        entry.setWhat(AuditEntryType.Update);
        entry.setData(toJSON(data));
        return entry;
    }
432550
@Bean
    @ConditionalOnMissingBean
    RolloutApprovalStrategy rolloutApprovalStrategy(final UserDetailsService userDetailsService,
            final TenantConfigurationManagement tenantConfigurationManagement,
            final SystemSecurityContext systemSecurityContext) {
        return new DefaultRolloutApprovalStrategy(userDetailsService, tenantConfigurationManagement,
                systemSecurityContext);
    }