List of usage examples for org.apache.commons.lang ArrayUtils isNotEmpty
public static boolean isNotEmpty(boolean[] array)
Checks if an array of primitive booleans is not empty or not null
.
From source file:org.wso2.carbon.user.mgt.UserRealmProxy.java
public UserRealmInfo getUserRealmInfo() throws UserAdminException { UserRealmInfo userRealmInfo = new UserRealmInfo(); String userName = CarbonContext.getThreadLocalCarbonContext().getUsername(); try {// w w w. ja v a2 s . com RealmConfiguration realmConfig = realm.getRealmConfiguration(); if (realm.getAuthorizationManager().isUserAuthorized(userName, "/permission/admin/configure/security", CarbonConstants.UI_PERMISSION_ACTION) || realm.getAuthorizationManager().isUserAuthorized(userName, "/permission/admin/configure/security/usermgt/users", CarbonConstants.UI_PERMISSION_ACTION) || realm.getAuthorizationManager().isUserAuthorized(userName, "/permission/admin/configure/security/usermgt/passwords", CarbonConstants.UI_PERMISSION_ACTION) || realm.getAuthorizationManager().isUserAuthorized(userName, "/permission/admin/configure/security/usermgt/profiles", CarbonConstants.UI_PERMISSION_ACTION)) { userRealmInfo.setAdminRole(realmConfig.getAdminRoleName()); userRealmInfo.setAdminUser(realmConfig.getAdminUserName()); userRealmInfo.setEveryOneRole(realmConfig.getEveryOneRoleName()); ClaimMapping[] defaultClaims = realm.getClaimManager() .getAllClaimMappings(UserCoreConstants.DEFAULT_CARBON_DIALECT); if (ArrayUtils.isNotEmpty(defaultClaims)) { Arrays.sort(defaultClaims, new ClaimMappingsComparator()); } List<String> fullClaimList = new ArrayList<String>(); List<String> requiredClaimsList = new ArrayList<String>(); List<String> defaultClaimList = new ArrayList<String>(); for (ClaimMapping claimMapping : defaultClaims) { Claim claim = claimMapping.getClaim(); fullClaimList.add(claim.getClaimUri()); if (claim.isRequired()) { requiredClaimsList.add(claim.getClaimUri()); } if (claim.isSupportedByDefault()) { defaultClaimList.add(claim.getClaimUri()); } } userRealmInfo.setUserClaims(fullClaimList.toArray(new String[fullClaimList.size()])); userRealmInfo .setRequiredUserClaims(requiredClaimsList.toArray(new String[requiredClaimsList.size()])); userRealmInfo.setDefaultUserClaims(defaultClaimList.toArray(new String[defaultClaimList.size()])); } List<UserStoreInfo> storeInfoList = new ArrayList<UserStoreInfo>(); List<String> domainNames = new ArrayList<String>(); RealmConfiguration secondaryConfig = realmConfig; UserStoreManager secondaryManager = realm.getUserStoreManager(); while (true) { secondaryConfig = secondaryManager.getRealmConfiguration(); UserStoreInfo userStoreInfo = getUserStoreInfo(secondaryConfig, secondaryManager); if (secondaryConfig.isPrimary()) { userRealmInfo.setPrimaryUserStoreInfo(userStoreInfo); } storeInfoList.add(userStoreInfo); userRealmInfo.setBulkImportSupported(secondaryManager.isBulkImportSupported()); String domainName = secondaryConfig .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME); if (domainName != null && domainName.trim().length() > 0) { domainNames.add(domainName.toUpperCase()); } secondaryManager = secondaryManager.getSecondaryUserStoreManager(); if (secondaryManager == null) { break; } } if (storeInfoList.size() > 1) { userRealmInfo.setMultipleUserStore(true); } userRealmInfo.setUserStoresInfo(storeInfoList.toArray(new UserStoreInfo[storeInfoList.size()])); userRealmInfo.setDomainNames(domainNames.toArray(new String[domainNames.size()])); String itemsPerPageString = realmConfig.getRealmProperty("MaxItemsPerUserMgtUIPage"); int itemsPerPage = 15; try { itemsPerPage = Integer.parseInt(itemsPerPageString); } catch (Exception e) { if (log.isDebugEnabled()) { log.info("Error parsing number of items per page, using default value", e); } } userRealmInfo.setMaxItemsPerUIPage(itemsPerPage); String maxPageInCacheString = realmConfig.getRealmProperty("MaxUserMgtUIPagesInCache"); int maxPagesInCache = 6; try { maxPagesInCache = Integer.parseInt(maxPageInCacheString); } catch (Exception e) { if (log.isDebugEnabled()) { log.info("Error parsing number of maximum pages in cache, using default value", e); } } userRealmInfo.setMaxUIPagesInCache(maxPagesInCache); String enableUIPageCacheString = realmConfig.getRealmProperty("EnableUserMgtUIPageCache"); boolean enableUIPageCache = true; if (FALSE.equals(enableUIPageCacheString)) { enableUIPageCache = false; } userRealmInfo.setEnableUIPageCache(enableUIPageCache); } catch (Exception e) { // previously logged so logging not needed throw new UserAdminException(e.getMessage(), e); } return userRealmInfo; }
From source file:org.wso2.identity.integration.test.identity.mgt.AccountLockEnabledTestCase.java
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL }) @Test(groups = "wso2.is", description = "Check whether the user account lock successfully") public void testSuccessfulLockedInitially() { try {//ww w . jav a 2 s .com usmClient.addUser(testLockUser1, testLockUser1Password, new String[] { "admin" }, new ClaimValue[0], null, false); int maximumAllowedFailedLogins = 5; for (int i = 0; i < maximumAllowedFailedLogins; i++) { try { authenticatorClient.login(testLockUser1, testLockUser1WrongPassword, "localhost"); } catch (Exception e) { log.error("Login attempt: " + i + " for user: " + testLockUser1 + " failed"); } } ClaimValue[] claimValues = usmClient.getUserClaimValuesForClaims(testLockUser1, new String[] { accountLockClaimUri }, "default"); String userAccountLockClaimValue = null; if (ArrayUtils.isNotEmpty(claimValues)) { userAccountLockClaimValue = claimValues[0].getValue(); } Assert.assertTrue("Test Failure : User Account Didn't Locked Properly", Boolean.valueOf(userAccountLockClaimValue)); } catch (Exception e) { log.error("Error occurred when locking the test user.", e); } }
From source file:org.wso2.identity.integration.test.user.mgt.UserImportLoggingTestCase.java
@Test(description = "Perform bulk user import and check the bulkuserimport log file is created.") @SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE }) public void testBulkUserImportLogFileIsPresent() throws RemoteException, UserAdminUserAdminException { File bulkUserFile = new File(BULK_USER_FILE + BULK_USER_IMPORT_SUCCESS_FILE); DataHandler handler = new DataHandler(new FileDataSource(bulkUserFile)); userMgtClient.bulkImportUsers(USER_STORE_DOMAIN, BULK_USER_IMPORT_SUCCESS_FILE, handler, null); File logDir = new File(LOG_FILE_LOCATION); String[] logFiles = logDir.list(); if (ArrayUtils.isNotEmpty(logFiles)) { for (String fileName : logFiles) { if (LOG_FILE_NAME.equals(fileName)) { isFilePresent = true;//from w w w .j a v a2 s .co m } } } assertTrue(isFilePresent); }
From source file:org.xdi.oxauth.model.common.AuthorizationGrantList.java
public static String extractClientIdFromTokenDn(String p_dn) { try {//from w ww.j av a 2 s. c o m if (StringUtils.isNotBlank(p_dn)) { final RDN[] rdNs = DN.getRDNs(p_dn); if (ArrayUtils.isNotEmpty(rdNs)) { for (RDN r : rdNs) { final String[] names = r.getAttributeNames(); if (ArrayUtils.isNotEmpty(names) && Arrays.asList(names).contains("inum")) { final String[] values = r.getAttributeValues(); if (ArrayUtils.isNotEmpty(values)) { return values[0]; } } } } } } catch (LDAPException e) { LOGGER.trace(e.getMessage(), e); } return ""; }
From source file:org.xdi.oxauth.uma.ws.rs.ScopeIconWS.java
@GET @Path("{id}") @Produces({ UmaConstants.JSON_MEDIA_TYPE }) public Response getScopeDescription(@PathParam("id") String id) { log.trace("UMA - get scope's icon : id: {0}", id); try {/*from w ww . j av a2s . c om*/ if (StringUtils.isNotBlank(id)) { final ScopeDescription scope = umaScopeService.getInternalScope(id); if (scope != null && StringUtils.isNotBlank(scope.getFaviconImageAsXml())) { final GluuImage gluuImage = xmlService.getGluuImageFromXML(scope.getFaviconImageAsXml()); if (gluuImage != null && ArrayUtils.isNotEmpty(gluuImage.getData())) { // todo yuriyz : it must be clarified how exactly content of image must be shared between oxTrust and oxAuth // currently oxTrust save content on disk however oxAuth expects it in ldap as we must support clustering! // send non-streamed image as it's anyway picked up in memory (i know it's not nice...) return Response.status(Response.Status.OK).entity(gluuImage.getData()).build(); } } } } catch (Exception e) { log.error(e.getMessage(), e); throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR) .entity(errorResponseFactory.getUmaJsonErrorResponse(UmaErrorResponseType.SERVER_ERROR)) .build()); } throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity(errorResponseFactory.getUmaJsonErrorResponse(UmaErrorResponseType.NOT_FOUND)).build()); }
From source file:ru.histone.v2.parser.tokenizer.Tokenizer.java
public TokenizerResult next(List<Integer> ignored, Integer... selector) { if (ArrayUtils.isNotEmpty(selector)) { return getTokenB(true, ignored, selector); }//from w ww . j a v a2 s . com return getTokenA(true, ignored); }
From source file:ru.histone.v2.parser.tokenizer.Tokenizer.java
public TokenizerResult test(List<Integer> ignored, Integer... selector) { if (ArrayUtils.isNotEmpty(selector)) { return getTokenB(false, ignored, selector); }/* ww w . j ava 2 s . c o m*/ return getTokenA(false, ignored); }
From source file:tasly.greathealth.oms.export.financial.facades.impl.DefaulTaslyFinancialReportFacade.java
/** * @param taslyFinancialReport// w ww . j a v a2s . c o m * @param order */ private void initFinancialReport(final TaslyFinancialReport taslyFinancialReport, final TaslyOrderData order) { // YTODO Auto-generated method stub taslyFinancialReport.setOriginalOrderId(order.getOriginal_order_id()); // ? final ShippingAndHandlingData shipping = order.getShippingAndHandling(); if (null != shipping) { taslyFinancialReport.setFreight((shipping.getShippingPrice().getSubTotalValue())); } else { taslyFinancialReport.setFreight(0); } taslyFinancialReport.setTotalPrice(0); final String[] priceArray = DEFAULT_RENTS.split(","); if (ArrayUtils.isNotEmpty(priceArray)) { final Map<String, Double> priceMap = new LinkedHashMap<String, Double>(); for (final String priceType : priceArray) { priceMap.put(priceType, new Double(0)); } taslyFinancialReport.setPriceMap(priceMap); } }
From source file:to.sparks.mtgox.example.HowToGetInfo.java
public static void main(String[] args) throws Exception { // Obtain a $USD instance of the API ApplicationContext context = new ClassPathXmlApplicationContext("to/sparks/mtgox/example/Beans.xml"); MtGoxHTTPClient mtgoxUSD = (MtGoxHTTPClient) context.getBean("mtgoxUSD"); Lag lag = mtgoxUSD.getLag();/*from w w w . ja v a2 s .c om*/ logger.log(Level.INFO, "Current lag: {0}", lag.getLag()); Ticker ticker = mtgoxUSD.getTicker(); logger.log(Level.INFO, "Last price: {0}", ticker.getLast().toPlainString()); // Get the private account info AccountInfo info = mtgoxUSD.getAccountInfo(); logger.log(Level.INFO, "Logged into account: {0}", info.getLogin()); Order[] openOrders = mtgoxUSD.getOpenOrders(); if (ArrayUtils.isNotEmpty(openOrders)) { for (Order order : openOrders) { logger.log(Level.INFO, "Open order: {0} status: {1} price: {2}{3} amount: {4}", new Object[] { order.getOid(), order.getStatus(), order.getCurrency().getCurrencyCode(), order.getPrice().getDisplay(), order.getAmount().getDisplay() }); } } else { logger.info("There are no currently open bid or ask orders."); } }
From source file:to.sparks.mtgox.example.TradingBot.java
private static boolean isOrdersValid(MtGoxFiatCurrency[] optimumBidPrices, MtGoxFiatCurrency[] optimumAskPrices, Order[] orders) {// www . ja v a 2 s . com boolean bRet = false; if (ArrayUtils.isNotEmpty(orders) && orders.length == percentagesOrderPriceSpread.length * 2 && orders.length == percentagesAboveOrBelowPrice.length * 2) { return isWithinAllowedDeviation(percentAllowedPriceDeviation, orders, optimumBidPrices, optimumAskPrices); } return bRet; }