Refine search
/** * Set the quiet local auth property to the given value if the user hasn't already set this property. * * @param optionMap the option map * @param useQuietAuth the value to set the quiet local auth property to * @return the option map with the quiet local auth property set to the given value if the user hasn't already set this property */ private static OptionMap setQuietLocalAuth(final OptionMap optionMap, final boolean useQuietAuth) { final Sequence<Property> existingSaslProps = optionMap.get(Options.SASL_PROPERTIES); if (existingSaslProps != null) { for (Property prop : existingSaslProps) { final String propKey = prop.getKey(); if (propKey.equals(LocalUserClient.QUIET_AUTH) || propKey.equals(LocalUserClient.LEGACY_QUIET_AUTH)) { // quiet local auth property was already set, do not override it return optionMap; } } // set the quiet local auth property since it wasn't already set in SASL_PROPERTIES existingSaslProps.add(Property.of(LocalUserClient.QUIET_AUTH, Boolean.toString(useQuietAuth))); return optionMap; } // set the quiet local auth property since no SASL_PROPERTIES were set final OptionMap.Builder updatedOptionMapBuilder = OptionMap.builder().addAll(optionMap); updatedOptionMapBuilder.set(Options.SASL_PROPERTIES, Sequence.of(Property.of(LocalUserClient.QUIET_AUTH, Boolean.toString(useQuietAuth)))); return updatedOptionMapBuilder.getMap(); }
AbstractAcceptingSslChannel(final SSLContext sslContext, final AcceptingChannel<? extends S> tcpServer, final OptionMap optionMap, final Pool<ByteBuffer> socketBufferPool, final Pool<ByteBuffer> applicationBufferPool, final boolean startTls) { this.tcpServer = tcpServer; this.sslContext = sslContext; this.socketBufferPool = socketBufferPool; this.applicationBufferPool = applicationBufferPool; this.startTls = startTls; clientAuthMode = optionMap.get(Options.SSL_CLIENT_AUTH_MODE); useClientMode = optionMap.get(Options.SSL_USE_CLIENT_MODE, false) ? 1 : 0; enableSessionCreation = optionMap.get(Options.SSL_ENABLE_SESSION_CREATION, true) ? 1 : 0; final Sequence<String> enabledCipherSuites = optionMap.get(Options.SSL_ENABLED_CIPHER_SUITES); cipherSuites = enabledCipherSuites != null ? enabledCipherSuites.toArray(new String[enabledCipherSuites.size()]) : null; final Sequence<String> enabledProtocols = optionMap.get(Options.SSL_ENABLED_PROTOCOLS); protocols = enabledProtocols != null ? enabledProtocols.toArray(new String[enabledProtocols.size()]) : null; //noinspection ThisEscapedInObjectConstruction closeSetter = ChannelListeners.<AcceptingChannel<C>>getDelegatingSetter(tcpServer.getCloseSetter(), this); //noinspection ThisEscapedInObjectConstruction acceptSetter = ChannelListeners.<AcceptingChannel<C>>getDelegatingSetter(tcpServer.getAcceptSetter(), this); }
public Sequence<T> cast(final Object o) { if (o == null) { return null; } else if (o instanceof Sequence) { return ((Sequence<?>)o).cast(elementType); } else if (o instanceof Object[]){ return Sequence.of((Object[])o).cast(elementType); } else if (o instanceof Collection) { return Sequence.of((Collection<?>)o).cast(elementType); } else { throw new ClassCastException("Not a sequence"); } }
public Sequence<Class<? extends T>> parseValue(final String string, final ClassLoader classLoader) throws IllegalArgumentException { final List<Class<? extends T>> list = new ArrayList<Class<? extends T>>(); if (string.isEmpty()) { return Sequence.empty(); } for (String value : string.split(",")) { list.add(parser.parseValue(value, classLoader)); } return Sequence.of(list); } }
private OptionMap getOptionMap(Set<String> disabledMechanisms) { OptionMap.Builder builder = OptionMap.builder(); builder.set(SASL_POLICY_NOANONYMOUS, Boolean.FALSE); builder.set(SASL_POLICY_NOPLAINTEXT, Boolean.FALSE); List<Property> tempProperties = new ArrayList<Property>(1); tempProperties.add(Property.of("jboss.sasl.local-user.quiet-auth", "true")); builder.set(Options.SASL_PROPERTIES, Sequence.of(tempProperties)); builder.set(Options.SSL_ENABLED, true); builder.set(Options.SSL_STARTTLS, true); if (disabledMechanisms != null && disabledMechanisms.size() > 0) { builder.set(Options.SASL_DISALLOWED_MECHANISMS, Sequence.of(disabledMechanisms)); } return builder.getMap(); }
@Override public synchronized void start(final StartContext context) throws StartException { final Endpoint endpoint = injectedEndpoint.getValue(); OptionMap.Builder builder = OptionMap.builder(); if(connectorPropertiesOptionMap.contains(optionMechanismNames)) { Object o = connectorPropertiesOptionMap.get(optionMechanismNames); if (o instanceof Sequence) { Sequence<String> sequence = (Sequence<String>) connectorPropertiesOptionMap.get(optionMechanismNames); mechanismNames = sequence.toArray(new String[sequence.size()]);
public Sequence<Class<? extends T>> cast(final Object o) { if (o == null) { return null; } else if (o instanceof Sequence) { return castSeq((Sequence<?>) o, elementDeclType); } else if (o instanceof Object[]){ return castSeq(Sequence.of((Object[]) o), elementDeclType); } else if (o instanceof Collection) { return castSeq(Sequence.of((Collection<?>) o), elementDeclType); } else { throw new ClassCastException("Not a sequence"); } }
config = config.useMechanismProperties(props); if (options.contains(Options.SASL_DISALLOWED_MECHANISMS)) { config = config.setSaslMechanismSelector(SaslMechanismSelector.DEFAULT.forbidMechanisms(options.get(Options.SASL_DISALLOWED_MECHANISMS).toArray(NO_STRINGS))); } else if (options.contains(Options.SASL_MECHANISMS)) { config = config.setSaslMechanismSelector(SaslMechanismSelector.DEFAULT.addMechanisms(options.get(Options.SASL_MECHANISMS).toArray(NO_STRINGS)));
final String provider = optionMap.get(Options.SSL_PROVIDER); final String protocol = optionMap.get(Options.SSL_PROTOCOL); final SSLContext sslContext; if (protocol == null) { final Sequence<Class<? extends KeyManager>> keyManagerClasses = optionMap.get(Options.SSL_JSSE_KEY_MANAGER_CLASSES); if (keyManagerClasses != null) { final int size = keyManagerClasses.size(); keyManagers = new KeyManager[size]; for (int i = 0; i < size; i ++) { keyManagers[i] = instantiate(keyManagerClasses.get(i)); final Sequence<Class<? extends TrustManager>> trustManagerClasses = optionMap.get(Options.SSL_JSSE_TRUST_MANAGER_CLASSES); if (trustManagerClasses != null) { final int size = trustManagerClasses.size(); trustManagers = new TrustManager[size]; for (int i = 0; i < size; i ++) { trustManagers[i] = instantiate(trustManagerClasses.get(i));
Assert.checkNotNullParam("authenticationConfiguration", authenticationConfiguration); final String saslProtocol = optionMap.get(SASL_PROTOCOL); authenticationConfiguration = authenticationConfiguration.useSaslProtocol(saslProtocol != null ? saslProtocol : RemotingOptions.DEFAULT_SASL_PROTOCOL); final String realm = optionMap.get(AUTH_REALM); if (realm != null) { authenticationConfiguration = authenticationConfiguration.useRealm(realm); final String authzId = optionMap.get(AUTHORIZE_ID); if (authzId != null) { authenticationConfiguration = authenticationConfiguration.useAuthorizationName(authzId); final Sequence<String> disallowedMechs = optionMap.get(Options.SASL_DISALLOWED_MECHANISMS); if (mechanisms != null || disallowedMechs != null) { SaslMechanismSelector selector = mechanisms != null ? SaslMechanismSelector.NONE.addMechanisms(mechanisms.toArray(NO_STRINGS)) : SaslMechanismSelector.DEFAULT; selector = selector.forbidMechanisms(disallowedMechs.toArray(NO_STRINGS)); final Sequence<SaslQop> qop = optionMap.get(Options.SASL_QOP); if (qop != null) { final Iterator<SaslQop> iterator = qop.iterator(); if (iterator.hasNext()) { StringBuilder b = new StringBuilder().append(iterator.next().getString());
private Map<String, String> getSaslProperties(final OptionMap optionMap) { Map<String, String> saslProperties = null; final Sequence<Property> value = optionMap.get(Options.SASL_PROPERTIES); if (value != null) { saslProperties = new HashMap<>(value.size()); for (Property property : value) { saslProperties.put(property.getKey(), (String) property.getValue()); } } return saslProperties; }
public <T> T setOption(final Option<T> option, final T value) throws IllegalArgumentException, IOException { if (option == Options.SSL_CLIENT_AUTH_MODE) { return option.cast(clientAuthModeUpdater.getAndSet(this, Options.SSL_CLIENT_AUTH_MODE.cast(value))); } else if (option == Options.SSL_USE_CLIENT_MODE) { final Boolean valueObject = Options.SSL_USE_CLIENT_MODE.cast(value); if (valueObject != null) return option.cast(Boolean.valueOf(useClientModeUpdater.getAndSet(this, valueObject.booleanValue() ? 1 : 0) != 0)); } else if (option == Options.SSL_ENABLE_SESSION_CREATION) { final Boolean valueObject = Options.SSL_ENABLE_SESSION_CREATION.cast(value); if (valueObject != null) return option.cast(Boolean.valueOf(enableSessionCreationUpdater.getAndSet(this, valueObject.booleanValue() ? 1 : 0) != 0)); } else if (option == Options.SSL_ENABLED_CIPHER_SUITES) { final Sequence<String> seq = Options.SSL_ENABLED_CIPHER_SUITES.cast(value); String[] old = this.cipherSuites; this.cipherSuites = seq == null ? null : seq.toArray(new String[seq.size()]); return option.cast(old); } else if (option == Options.SSL_ENABLED_PROTOCOLS) { final Sequence<String> seq = Options.SSL_ENABLED_PROTOCOLS.cast(value); String[] old = this.protocols; this.protocols = seq == null ? null : seq.toArray(new String[seq.size()]); return option.cast(old); } else { return tcpServer.setOption(option, value); } throw UndertowLogger.ROOT_LOGGER.nullParameter("value"); }
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.star); int width = bm.getWidth(); int height = bm.getHeight(); RgbImage jjImage = RgbImageAndroid.toRgbImage(bm); Sequence seq = new Sequence(); seq.add(new Rgb3x3Average()); RgbImage jjImageResult = null; try { seq.push(jjImage.clone()); jjImageResult = (RgbImage) seq.getFront(); } catch (Error e) { // TODO Auto-generated catch block e.printStackTrace(); } int[] jjpixel = jjImageResult.getData(); Bitmap bm2 = bm.copy(bm.getConfig(), true); bm2.setPixels(jjpixel, 0, width, 0, 0, width, height);
@Test public void testSequenceCreation() throws ClassNotFoundException { EnvironmentConfig econf = EnvironmentConfig.DEFAULT.setAllowCreate(true); Environment env = new Environment(envHome, econf); StoreConfig sconf = StoreConfig.DEFAULT.setAllowCreate(true); EntityStore store = new EntityStore(env, "TestStore", sconf); store.setPrimaryConfig(FakeEntity.class, DatabaseConfig.DEFAULT.setAllowCreate(true)); store.setSequenceConfig("testSequence", SequenceConfig.DEFAULT.setAllowCreate(true)); Sequence seq = store.getSequence("testSequence"); Assert.assertEquals(0, seq.get(null, 1)); Assert.assertEquals(1, seq.get(null, 1)); Assert.assertEquals(2, seq.get(null, 1)); store.sync(); seq.close(); store.close(); env.close(); }
/** * Determine whether this sequence is equal to another. * * @param other the other sequence * @return {@code true} if they are equal, {@code false} otherwise */ public boolean equals(Object other) { return other instanceof Sequence && equals((Sequence<?>)other); }
private OptionMap getOptionMap(Set<String> disabledMechanisms) { OptionMap.Builder builder = OptionMap.builder(); builder.set(SASL_POLICY_NOANONYMOUS, Boolean.FALSE); builder.set(SASL_POLICY_NOPLAINTEXT, Boolean.FALSE); List<Property> tempProperties = new ArrayList<Property>(1); tempProperties.add(Property.of("jboss.sasl.local-user.quiet-auth", "true")); builder.set(Options.SASL_PROPERTIES, Sequence.of(tempProperties)); builder.set(Options.SSL_ENABLED, true); builder.set(Options.SSL_STARTTLS, true); if (disabledMechanisms != null && disabledMechanisms.size() > 0) { builder.set(Options.SASL_DISALLOWED_MECHANISMS, Sequence.of(disabledMechanisms)); } return builder.getMap(); }
/** * Set int values for an Integer sequence key. * * @param key the key * @param values the values * @return this builder */ public Builder setSequence(Option<Sequence<Integer>> key, int... values) { if (key == null) { throw msg.nullParameter("key"); } Integer[] a = new Integer[values.length]; for (int i = 0; i < values.length; i++) { a[i] = Integer.valueOf(values[i]); } list.add(new OVPair<Sequence<Integer>>(key, Sequence.of(a))); return this; }