Gets cached principal attributes.

@param principal         the principal
@param registeredService the registered service
@return the cached principal attributes
355918
@JsonIgnore
    protected Map<String, List<Object>> getCachedPrincipalAttributes(final Principal principal, final RegisteredService registeredService) {
        try {
            val cache = getCacheInstanceFromApplicationContext();
            return cache.getCachedAttributesFor(registeredService, this, principal);
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
        return new HashMap<>(0);
    }
648021
private void registerCachedServiceInstance(ProvidedServiceInstance instance, ServiceInstanceHealth registryHealth) {
        try {
            write.lock();
            ServiceInstanceId id = new ServiceInstanceId(instance.getServiceName(),
                    instance.getProviderId());
            CachedProviderServiceInstance cachedInstance = getCacheServiceInstances().get(id);

            if(cachedInstance == null){
                cachedInstance = new CachedProviderServiceInstance(
                    instance);
                getCacheServiceInstances().put(id, cachedInstance);

            }
            if(LOGGER.isDebugEnabled()){
                LOGGER.debug("add cached ProvidedServiceInstance: {}.", cachedInstance.toString());
            }
            cachedInstance.setServiceInstanceHealth(registryHealth);
        } finally {
            write.unlock();
        }
    }
229250
public java.util.List<PrincipalIdFormat> getPrincipals() {
        if (principals == null) {
            principals = new com.amazonaws.internal.SdkInternalList<PrincipalIdFormat>();
        }
        return principals;
    }
532561
@Override
    protected Principal getPrincipal(String username) {
        Principal principal;

        // force lookup of user info
        if (username.startsWith("*")) {
            principal = readPrincipal(username.substring(1));
            if (principal != null) {
                synchronized (principals) {
                    principals.put(username.substring(1), principal);
                }
            }
        }

        synchronized (principals) {
            principal = (Principal) principals.get(username);
        }
        if (principal == null) {
            principal = readPrincipal(username);
            if (principal != null) {
                synchronized (principals) {
                    principals.put(username, principal);
                }
            }
        }
        return principal;
    }
602768
public RegisteredService get(final String id) {
        if (NumberUtils.isCreatable(id)) {
            return get(Long.parseLong(id));
        }
        val keys = new HashMap<String, AttributeValue>();
        keys.put(ColumnNames.SERVICE_ID.getColumnName(), new AttributeValue(id));
        return getRegisteredServiceByKeys(keys);
    }
1068951
protected Map<String, List<Object>> getCasPrincipalAttributes(final Map<String, Object> model, final RegisteredService registeredService) {
        return getPrincipalAttributesAsMultiValuedAttributes(model);
    }
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);
    }
1051218
public static Predicate<RegisteredService> getRegisteredServiceExpirationPolicyPredicate() {
        return service -> {
            try {
                if (service == null) {
                    return false;
                }
                val policy = service.getExpirationPolicy();
                if (policy == null || StringUtils.isBlank(policy.getExpirationDate())) {
                    return true;
                }
                val now = getCurrentSystemTime();
                val expirationDate = DateTimeUtils.localDateTimeOf(policy.getExpirationDate());
                LOGGER.debug("Service expiration date is [{}] while now is [{}]", expirationDate, now);
                return !now.isAfter(expirationDate);
            } catch (final Exception e) {
                LOGGER.warn(e.getMessage(), e);
            }
            return false;
        };
    }
394826
static synchronized CacheInstanceInfo [] getCacheInstanceInfo( CacheServiceImpl cacheService ) {
		CacheInstanceInfo infoOut [] = currentCacheInstanceInfoOut;
		if ( System.currentTimeMillis() - lastPopulate > populateInterval ) {
			if (cacheService!=null) {
				if ( cacheInstanceInfo == null ) {
					cacheInstanceInfo = new CacheInstanceInfo();
				}
				cacheService.populateCacheInstanceInfo( cacheInstanceInfo );
				CacheInstanceInfo.cacheService = cacheService;
				infoOut = new CacheInstanceInfo[allConfigured.size()];
				Iterator i = allConfigured.iterator();
				int x=0;
				while ( i.hasNext() ) {
					String cacheName =  (String)i.next();
					CacheInstanceInfo info = new CacheInstanceInfo();

					info.cacheName      = cacheName;
					info.isActive       = CacheInstanceInfo.allActive.contains(cacheName);
					info.isFactory      = CacheInstanceInfo.allFactory.contains(cacheName);
					info.isFile         = CacheInstanceInfo.allFile.contains(cacheName);
					info.isObjectCache  = CacheInstanceInfo.objectConfigured.contains(cacheName);
					info.isServletCache = CacheInstanceInfo.servletConfigured.contains(cacheName);

					infoOut[x++] = info;
				}
				currentCacheInstanceInfoOut = infoOut;
				CacheInstanceInfo.allConfigured.clear();
				CacheInstanceInfo.allActive.clear();
				CacheInstanceInfo.allFactory.clear();
				CacheInstanceInfo.allFile.clear();
				CacheInstanceInfo.objectConfigured.clear();
				CacheInstanceInfo.servletConfigured.clear();

			}
			lastPopulate = System.currentTimeMillis();
		}
		return infoOut;
	}
1012406
public Optional<String> getSigningKey(final RegisteredService registeredService) {
        val property = getSigningKeyRegisteredServiceProperty();
        if (property.isAssignedTo(registeredService)) {
            val signingKey = property.getPropertyValue(registeredService).getValue();
            return Optional.of(signingKey);
        }
        return Optional.empty();
    }
1270487
@Override
    public Principal getCallerPrincipal() {
        synchronized (this) {
            if ((state == PRE_CREATE) || (state == CREATING) || (!allowRollbackOnly))
                throw new IllegalStateException();
        }

        return super.getCallerPrincipal();

    }
169583
@SneakyThrows
    public User getOrCreateUser(final Principal principal) {
        val attributes = principal.getAttributes();
        if (!attributes.containsKey(this.mailAttribute)) {
            throw new IllegalArgumentException("No email address found for " + principal.getId());
        }
        if (!attributes.containsKey(this.phoneAttribute)) {
            throw new IllegalArgumentException("No phone number found for " + principal.getId());
        }

        val email = attributes.get(this.mailAttribute).get(0).toString();
        val phone = attributes.get(this.phoneAttribute).get(0).toString();
        return this.authyUsers.createUser(email, phone, this.countryCode);
    }
271832
public void putCachedAttributesFor(final RegisteredService registeredService,
                                       final CachingPrincipalAttributesRepository repository,
                                       final String id, final Map<String, List<Object>> attributes) {
        val cache = getRegisteredServiceCacheInstance(registeredService, repository);
        cache.put(id, attributes);
    }
991260
protected IPermissionSet cacheGet(IAuthorizationPrincipal principal)
            throws AuthorizationException {
        try {
            return (IPermissionSet)
                    EntityCachingService.getEntityCachingService()
                            .get(this.PERMISSION_SET_TYPE, principal.getPrincipalString());
        } catch (CachingException ce) {
            throw new AuthorizationException(
                    "Problem getting permissions for " + principal + " from cache", ce);
        }
    }
165474
public Principal buildSurrogatePrincipal(final String surrogate, final Principal primaryPrincipal, final Credential credentials,
                                             final RegisteredService registeredService) {
        val repositories = new HashSet<String>(0);
        if (registeredService != null) {
            repositories.addAll(registeredService.getAttributeReleasePolicy().getPrincipalAttributesRepository().getAttributeRepositoryIds());
        }
        val attributes = (Map) CoreAuthenticationUtils.retrieveAttributesFromAttributeRepository(attributeRepository, surrogate, repositories);
        val principal = principalFactory.createPrincipal(surrogate, attributes);
        return new SurrogatePrincipal(primaryPrincipal, principal);
    }
105120
@Override
    public CacheKey getCacheKey(HttpServletRequest request, HttpServletResponse response) {
        final CacheKey parentKey = this.wrappedComponent.getCacheKey(request, response);
        final CacheKey attributeKey = this.attributeSource.getCacheKey(request, response);
        return CacheKey.build(this.beanName, parentKey, attributeKey);
    }
1280797
protected String getRegisteredServiceJwtProperty(final RegisteredService service, final RegisteredServiceProperty.RegisteredServiceProperties propName) {
        if (service == null || !service.getAccessStrategy().isServiceAccessAllowed()) {
            LOGGER.debug("Service is not defined/found or its access is disabled in the registry");
            throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE);
        }
        if (propName.isAssignedTo(service)) {
            return propName.getPropertyValue(service).getValue();
        }
        LOGGER.warn("Service [{}] does not define a property [{}] in the registry", service.getServiceId(), propName);
        return null;
    }