Example usage for java.util Collections EMPTY_SET

List of usage examples for java.util Collections EMPTY_SET

Introduction

In this page you can find the example usage for java.util Collections EMPTY_SET.

Prototype

Set EMPTY_SET

To view the source code for java.util Collections EMPTY_SET.

Click Source Link

Document

The empty set (immutable).

Usage

From source file:org.wso2.carbon.core.security.CarbonJMXAuthenticator.java

public Subject authenticate(Object credentials) {
    // Verify that credentials is of type String[].
    ///*from ww  w .  j  a  v  a 2 s .c o  m*/
    if (!(credentials instanceof String[])) {
        // Special case for null so we get a more informative message
        if (credentials == null) {
            throw new SecurityException("Credentials required");
        }
        throw new SecurityException("Credentials should be String[]");
    }

    // Verify that the array contains username/password
    //
    final String[] aCredentials = (String[]) credentials;
    if (aCredentials.length < 2) {
        throw new SecurityException("Credentials should have at least username & password");
    }

    // Perform authentication
    //
    String userName = aCredentials[0];
    String password = aCredentials[1];

    UserStoreManager authenticator;
    try {
        authenticator = userRealm.getUserStoreManager();
    } catch (UserStoreException e) {
        String msg = "Cannot get authenticator from Realm";
        log.error(msg, e);
        throw new SecurityException(msg, e);
    }

    try {

        // for new cahing, every thread should has its own populated CC. During the deployment time we assume super tenant
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);

        String domainNameFromUserName = extractTenantDomain(userName);
        if (domainNameFromUserName != null
                && domainNameFromUserName.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) {
            if (log.isDebugEnabled()) {
                log.debug("Authentication Failure..Provided tenant domain name is reserved..");
            }
            throw new SecurityException(
                    "Authentication failed - System error occurred. Tenant domain name is reserved.");
        }
        if (authenticator.authenticate(userName, password)) {

            UserRealmService userRealmService = CarbonCoreDataHolder.getInstance().getRealmService();
            TenantManager tenantManager = userRealmService.getTenantManager();
            String tenantDomain = MultitenantUtils.getTenantDomain(userName);
            int tenantId = tenantManager.getTenantId(tenantDomain);
            carbonContext.setTenantId(tenantId);
            carbonContext.setTenantDomain(tenantDomain);

            audit.info("User " + userName + " successfully authenticated to perform JMX operations.");

            if (authorize(userName)) {

                audit.info("User : " + userName + " successfully authorized to perform JMX operations.");

                return new Subject(true, Collections.singleton(new JMXPrincipal(userName)),
                        Collections.EMPTY_SET, Collections.EMPTY_SET);
            } else {
                throw new SecurityException(
                        "User : " + userName + " not authorized to perform JMX operations.");
            }

        } else {
            throw new SecurityException(
                    "Login failed for user : " + userName + ". Invalid username or password.");
        }
    } catch (SecurityException se) {

        String msg = "Unauthorized access attempt to JMX operation. ";
        audit.warn(msg, se);
        throw new SecurityException(msg, se);

    } catch (Exception e) {

        String msg = "JMX operation failed.";
        log.error(msg, e);
        throw new SecurityException(msg, e);
    }
}

From source file:org.flite.cach3.aop.LogicalCacheImpl.java

Set<String> checkIdsForDuplication(final Collection<String> ids, final Duration duration) {
    if (ids == null || ids.size() < 1) {
        return Collections.EMPTY_SET;
    }/*w  w w.  ja va2 s  .  c o  m*/
    final Map<String, Duration> history = nanny.getAllPresent(ids);
    if (history == null || history.size() < 1) {
        return Collections.EMPTY_SET;
    }

    final Set<String> results = new HashSet<String>(ids.size());
    for (final Map.Entry<String, Duration> entry : history.entrySet()) {
        final Duration previous = entry.getValue();
        if (duration != previous) {
            results.add(duration.name() + " vs " + previous.name() + ": " + entry.getKey());
        }
    }

    return results;
}

From source file:org.springsource.ide.eclipse.boot.maven.analyzer.graph.DirectedGraph.java

public Collection<Object> getPredecessors(Object node) {
    Collection preds = (Collection) inverted.get(node);
    if (preds != null) {
        return preds;
    }//w  w w.  ja  va2s. co  m
    return Collections.EMPTY_SET;
}

From source file:SessionMap.java

/**
 * @see java.util.Map#keySet()// www  .  j  ava2s .c  o  m
 */
public Set keySet() {
    if (session != null) {
        Set keySet = new HashSet();

        Enumeration enumeration = session.getAttributeNames();
        while (enumeration.hasMoreElements()) {
            keySet.add(enumeration.nextElement());
        }

        return keySet;

    } else {
        return Collections.EMPTY_SET;
    }
}

From source file:org.paxml.launch.LaunchModelBuilder.java

public static Set<PaxmlResource> findResources(String base, Set<String> includes, Set<String> excludes) {
    if (includes == null) {
        includes = new HashSet<String>(1);
        includes.add("**/*.*");
    }/* w  w w.  j a  v a2 s .  c om*/
    if (excludes == null) {
        excludes = Collections.EMPTY_SET;
    }
    if (base == null) {
        base = ""; // the current working dir
    }
    File f = new File(base);
    if (f.isDirectory()) {
        f = new File(f, "fake.file");
    }
    Resource baseRes = new FileSystemResource(f).getSpringResource();
    Set<PaxmlResource> include = new LinkedHashSet<PaxmlResource>(0);
    Set<PaxmlResource> exclude = new LinkedHashSet<PaxmlResource>(0);
    ResourceMatcher matcher = new ResourceMatcher(includes, excludes);
    for (String pattern : matcher.include) {
        include.addAll(ResourceLocator.findResources(pattern, baseRes));
    }
    for (String pattern : matcher.exclude) {
        exclude.addAll(ResourceLocator.findResources(pattern, baseRes));
    }
    include.removeAll(exclude);

    return include;
}

From source file:com.github.p4535992.database.datasource.database.data.Dao.java

@SuppressWarnings("unchecked")
public void insert(Map<String, Object> rowData) {
    final Set<Entry<String, Object>> entries = rowData.entrySet();
    final String insertScript = createInsertScript(entries);

    execute(entries, Collections.EMPTY_SET, insertScript);
}

From source file:org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.LinuxTestCase.java

/**
 * This method will return a set of timestamps and their corresponding map
 * of attributes and state values. The attribute list does not have to
 * contain all attributes in the state system, only the ones that should be
 * tested.// w  w  w.ja v  a  2  s .  c  o m
 *
 * @return A set of {@link PunctualInfo} objects to verify
 */
public Set<PunctualInfo> getPunctualTestData() {
    return Collections.EMPTY_SET;
}

From source file:org.lockss.poller.v3.VersionCounts.java

/**
 * @param landslideMinimum The minimum number of votes which would
 * make a version "popular".//from   ww  w .j  av  a2s . co m
 * @return A Map of ParticipantUserData to plain hash values,
 * including only those with head versions which have at least the
 * minimum support.
 */
public Map<ParticipantUserData, HashResult> getRepairCandidates(int landslideMinimum) {
    return getRepairCandidates(landslideMinimum, Collections.EMPTY_SET);
}

From source file:hr.fer.spocc.grammar.Grammar.java

@SuppressWarnings("unchecked")
protected Set<ProductionRule<T>> getProductionsLeftSymbol(Symbol<T> symbol) {
    if (!this.leftSideSymbolMap.containsKey(symbol))
        return Collections.EMPTY_SET;
    return this.leftSideSymbolMap.getAll(symbol);
}

From source file:com.adobe.ags.curly.test.ErrorBehaviorTest.java

@Test
public void testActionRequireFailure2() throws IOException, ParseException {
    ApplicationState.getInstance().errorBehaviorProperty().set(ErrorBehavior.HALT);
    Action fail1 = successAction();
    Action fail2 = failureAction();
    fail1.setErrorBehavior(ErrorBehavior.SKIP_IF_SUCCESSFUL);
    fail2.setErrorBehavior(ErrorBehavior.SKIP_IF_SUCCESSFUL);
    List<Action> actions = Arrays.asList(fail1, fail2);
    ActionGroupRunner runner = new ActionGroupRunner("Action Require Failure Test", ignore -> client, actions,
            Collections.EMPTY_MAP, Collections.EMPTY_SET);
    runner.run();/*from   www  .  java  2 s .  c  om*/
    assertResults(runner.getResult(), false, false);
}