@Activate public void activate(BundleContext bundleContext) { // This config property will be read by Carbon-Security-Component only once at @Activate. // Hence need to set before activating Carbon-Security-Component. //TODO: Check once carbon-security component is adapted Startup-Order-Resolver System.setProperty("java.security.auth.login.config", Utils.getCarbonConfigHome().resolve("security").resolve("carbon-jaas.config").toString() ); }
/** * Initialization of JMS ConnectionFactory with the user specified properties. * * @param properties Properties to be added to the initial context. * @throws JMSConnectorException Thrown when initial context name is wrong or when creating connection factory. */ public JMSServerConnectionFactory(Properties properties) throws JMSConnectorException { super(properties); isSharedSubscription = Boolean.parseBoolean(properties.getProperty(JMSConstants.PARAM_IS_SHARED_SUBSCRIPTION)); noPubSubLocal = Boolean.valueOf(properties.getProperty(JMSConstants.PARAM_PUBSUB_NO_LOCAL)); subscriptionName = properties.getProperty(JMSConstants.PARAM_DURABLE_SUB_ID); if (isSharedSubscription && subscriptionName == null) { logger.warn("Subscription name is not given. Therefore declaring a non-shared subscription"); isSharedSubscription = false; } isDurable = !StringUtils.isNullOrEmptyAfterTrim(properties.getProperty(JMSConstants.PARAM_DURABLE_SUB_ID)); String msgSelector = properties.getProperty(JMSConstants.PARAM_MSG_SELECTOR); if (null != msgSelector) { messageSelector = msgSelector; } this.destinationName = properties.getProperty(JMSConstants.PARAM_DESTINATION_NAME); }
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings("DMI_NONSERIALIZABLE_OBJECT_WRITTEN") public static void backUpOauthData(Map<String, OAuthApplication> applications, Map<String, OAuthApplication> appsByClientId) { String backUpPath = Utils.getCarbonHome() + File.separator + "database" + File.separator; FileOutputStream fos = null; ObjectOutputStream oos = null; try { fos = new FileOutputStream(backUpPath + "applications.data"); oos = new ObjectOutputStream(fos); oos.writeObject(applications); oos.close(); fos = new FileOutputStream(backUpPath + "appsByClientId.data"); oos = new ObjectOutputStream(fos); oos.writeObject(appsByClientId); } catch (IOException e) { log.error("Error while backing up token data", e); } finally { if (oos != null) { try { oos.close(); } catch (IOException e) { log.error("Error while closing the stream", e); } } } }
private boolean isUsernamePresent(UserBean userBean) { return userBean.getClaims().stream() .filter(claim -> USERNAME_CLAIM.equals(claim.getClaimUri()) && !isNullOrEmpty(claim.getValue())) .findAny() .isPresent(); }
private void doHandle(List<CarbonCallbackHandler> callbackHandlers, Callback[] callbacks) { callbackHandlers .stream() .filter((handler) -> { handler.setCarbonMessage(carbonMessage); return handler.canHandle(); }) .findFirst() .ifPresent(rethrowConsumer(handler -> { handler.handle(callbacks); })); }
@Override public Group getGroup(String uniqueGroupId) throws IdentityStoreException, GroupNotFoundException { if (cacheStatus.get(UNIQUE_GROUP_CACHE) && !isNullOrEmpty(uniqueGroupId)) { return doGetGroup(uniqueGroupId, identityStore.getPrimaryDomainName()); } Group group = identityStore.getGroup(uniqueGroupId); group.setIdentityStore(this); return group; }
/** * Initialization of JMS ConnectionFactory with the user specified properties. * * @param properties Properties to be added to the initial context. * @throws JMSConnectorException Thrown when initial context name is wrong or when creating connection factory. */ public JMSServerConnectionFactory(Properties properties) throws JMSConnectorException { super(properties); isSharedSubscription = Boolean.parseBoolean(properties.getProperty(JMSConstants.PARAM_IS_SHARED_SUBSCRIPTION)); noPubSubLocal = Boolean.valueOf(properties.getProperty(JMSConstants.PARAM_PUBSUB_NO_LOCAL)); subscriptionName = properties.getProperty(JMSConstants.PARAM_DURABLE_SUB_ID); if (isSharedSubscription && subscriptionName == null) { logger.warn("Subscription name is not given. Therefore declaring a non-shared subscription"); isSharedSubscription = false; } isDurable = !StringUtils.isNullOrEmptyAfterTrim(properties.getProperty(JMSConstants.PARAM_DURABLE_SUB_ID)); String msgSelector = properties.getProperty(JMSConstants.PARAM_MSG_SELECTOR); if (null != msgSelector) { messageSelector = msgSelector; } this.destinationName = properties.getProperty(JMSConstants.PARAM_DESTINATION_NAME); }
private List<String> getDomainEntityIds(List<String> uniqueEntityIds, int domainId) throws IdentityStoreException { List<String> domainEntityIds = new ArrayList<>(); uniqueEntityIds.forEach(rethrowConsumer(uniqueEntityId -> { SimpleEntry<Integer, String> decodedUniqueEntityId = getDecodedUniqueEntityId(uniqueEntityId); if (domainId != decodedUniqueEntityId.getKey()) { throw new IdentityStoreClientException("User and group must be in the same domain."); } domainEntityIds.add(decodedUniqueEntityId.getValue()); })); return domainEntityIds; } }
@Activate protected void init() { if (Boolean.parseBoolean(SystemVariableUtil.getValue(HTTP_MONITORING_ENABLED, Boolean.FALSE.toString()))) { String dataAgentConfigPath = SystemVariableUtil.getValue(HTTP_MONITORING_DAS_DATAAGENTCONFIGPATH, Utils.getCarbonConfigHome() + File.separator + "data-bridge" + File.separator + "data-agent-conf.xml"); System.setProperty(HTTP_MONITORING_DAS_DATAAGENTCONFIGPATH, dataAgentConfigPath); HTTPMonitoringDataPublisher.init(); } }
@Override public User getUser(String uniqueUserId) throws IdentityStoreException, UserNotFoundException { if (cacheStatus.get(UNIQUE_USER_CACHE) && isNullOrEmpty(uniqueUserId)) { return doGetUser(uniqueUserId, identityStore.getPrimaryDomainName()); } User user = identityStore.getUser(uniqueUserId); user.setIdentityStore(this); return user; }
private Map<String, String> resolveInheritingDialects(Map<String, Map<String, String>> initialMappings, ClaimMappingEntry claimMappingEntry) { Map<String, String> ownClaims = initialMappings.get(claimMappingEntry.getMappingDialectURI()); if (!StringUtils.isNullOrEmptyAfterTrim(claimMappingEntry.getInherits())) { Map<String, String> inheritingMap = initialMappings.get(claimMappingEntry.getInherits()); ownClaims.putAll(inheritingMap); return ownClaims; } else { return ownClaims; } }
@Activate protected void init() { if (Boolean.parseBoolean(SystemVariableUtil.getValue(METRICS_ENABLED, Boolean.FALSE.toString()))) { String dataAgentConfigPath = SystemVariableUtil.getValue(METRICS_REPORTING_DAS_DATAAGENTCONFIGPATH, Utils.getCarbonConfigHome() + File.separator + "data-bridge" + File.separator + "data-agent-conf.xml"); System.setProperty(METRICS_REPORTING_DAS_DATAAGENTCONFIGPATH, dataAgentConfigPath); Metrics.init(MetricReporter.JMX, MetricReporter.DAS); } }
@Override public User getUser(Claim claim, String domainName) throws IdentityStoreException, UserNotFoundException { if (isNullOrEmpty(domainName)) { return getUser(claim); } if (claim == null || isNullOrEmpty(claim.getValue())) { throw new IdentityStoreClientException("Invalid claim."); } Domain domain; try { domain = getDomainFromDomainName(domainName); } catch (DomainException e) { throw new IdentityStoreServerException(String.format("Error while retrieving domain from the domain name " + "- %s", domainName), e); } return doGetUser(claim, domain); }
@Override public Group getGroup(Claim claim, String domainName) throws IdentityStoreException, GroupNotFoundException { if (isNullOrEmpty(domainName)) { return getGroup(claim); } if (claim == null || isNullOrEmpty(claim.getValue())) { throw new IdentityStoreClientException("Invalid claim."); } Domain domain; try { domain = getDomainFromDomainName(domainName); } catch (DomainException e) { throw new IdentityStoreServerException(String.format("Error while retrieving domain from the domain name " + "- %s", domainName), e); } return doGetGroup(claim, domain); }
@Override public void deleteUser(String uniqueUserId) throws IdentityStoreException, UserNotFoundException { if (isNullOrEmpty(uniqueUserId)) { throw new IdentityStoreClientException("Invalid user unique id."); } SimpleEntry<Integer, String> decodedUniqueUserId = getDecodedUniqueEntityId(uniqueUserId); Domain domain = domains.get(decodedUniqueUserId.getKey()); try { domain.deleteUser(decodedUniqueUserId.getValue()); } catch (DomainException e) { throw new IdentityStoreServerException(String.format("Failed to delete user - %s", uniqueUserId)); } }
@Override public void deleteGroup(String uniqueGroupId) throws IdentityStoreException, GroupNotFoundException { if (isNullOrEmpty(uniqueGroupId)) { throw new IdentityStoreClientException("Invalid group unique id."); } SimpleEntry<Integer, String> decodedUniqueGroupId = getDecodedUniqueEntityId(uniqueGroupId); Domain domain = domains.get(decodedUniqueGroupId.getKey()); try { domain.deleteGroup(decodedUniqueGroupId.getValue()); } catch (DomainException e) { throw new IdentityStoreServerException(String.format("Failed to delete user - %s", uniqueGroupId)); } }
@Override public Group getGroup(Claim claim) throws IdentityStoreException, GroupNotFoundException { if (claim == null || isNullOrEmpty(claim.getValue())) { throw new IdentityStoreClientException("Invalid claim."); } Domain domain; try { domain = getPrimaryDomain(); } catch (DomainException e) { throw new IdentityStoreServerException("Error while retrieving the primary domain.", e); } return doGetGroup(claim, domain); }
@Override public User getUser(Claim claim) throws IdentityStoreException, UserNotFoundException { if (claim == null || isNullOrEmpty(claim.getValue())) { throw new IdentityStoreClientException("Provided claim is invalid."); } Domain domain; try { domain = getPrimaryDomain(); } catch (DomainException e) { throw new IdentityStoreServerException("Error while retrieving the primary domain.", e); } return doGetUser(claim, domain); }
@Override public void setUserState(String uniqueUserId, String targetState) throws IdentityStoreException, UserNotFoundException { if (isNullOrEmpty(uniqueUserId)) { throw new UserNotFoundException("Invalid unique user id."); } SimpleEntry<Integer, String> decodedUniqueUserId = getDecodedUniqueEntityId(uniqueUserId); Domain domain = domains.get(decodedUniqueUserId.getKey()); try { domain.setUserState(decodedUniqueUserId.getValue(), targetState); } catch (DomainException e) { throw new IdentityStoreServerException("Failed to set user state", e); } }
@Override public List<Group> listGroups(Claim claim, int offset, int length) throws IdentityStoreException { if (claim == null || isNullOrEmpty(claim.getValue())) { throw new IdentityStoreClientException("Invalid claim."); } if (offset < 0) { throw new IdentityStoreClientException("Invalid offset value."); } if (length == 0) { return Collections.emptyList(); } Domain domain; try { domain = getPrimaryDomain(); } catch (DomainException e) { throw new IdentityStoreServerException("Error while retrieving the primary domain.", e); } return doListGroups(claim, offset, length, domain); }