Example usage for org.apache.commons.lang ArrayUtils add

List of usage examples for org.apache.commons.lang ArrayUtils add

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils add.

Prototype

public static short[] add(short[] array, short element) 

Source Link

Document

Copies the given array and adds the given element at the end of the new array.

Usage

From source file:org.brushingbits.jnap.email.Email.java

public void addTo(String to) {
    setTo((String[]) ArrayUtils.add(getTo(), to));
}

From source file:org.brushingbits.jnap.email.Email.java

public void addCc(String cc) {
    setCc((String[]) ArrayUtils.add(getCc(), cc));
}

From source file:org.brushingbits.jnap.email.Email.java

public void addBcc(String bcc) {
    setBcc((String[]) ArrayUtils.add(getBcc(), bcc));
}

From source file:org.caleydo.datadomain.mock.MockDataDomain.java

private static TablePerspective addGrouping(MockDataDomain dataDomain, EDimension dim, boolean fillOut,
        int... groups) {
    Table table = dataDomain.getTable();
    int total = dim.select(table.size(), table.depth());
    int sum = sum(groups);
    if (sum < total && fillOut) {
        groups = ArrayUtils.add(groups, total - sum); // fill out
        sum = total;//from  w w w .j  a v  a 2  s. co m
    } else if (sum > total)
        throw new IllegalStateException("have more groups that items");

    PerspectiveInitializationData data = new PerspectiveInitializationData();
    data.setLabel(groups.length + " grouping");
    VirtualArray va = (dim.isRecord() ? table.getDefaultRecordPerspective(false)
            : table.getDefaultDimensionPerspective(false)).getVirtualArray();

    List<Integer> samples = new ArrayList<>();
    int acc = 0;
    for (int group : groups) {
        samples.add(va.get(acc));
        acc += group;
    }
    data.setData(new ArrayList<>(va.getIDs().subList(0, sum)), Ints.asList(groups), samples);

    return registerAndGet(dataDomain, dim, data);
}

From source file:org.chenillekit.tapestry.core.base.AbstractEventMixin.java

void afterRender() {
    String id = clientElement.getClientId();
    if (!StringUtils.isEmpty(id)) {

        final Link link = resources.createEventLink(EVENT_NAME, ArrayUtils.add(contextArray, id));

        String jsString = "new Ck.OnEvent('%s', '%s', %b, '%s', '%s');";
        String callBackString = resources.isBound("onCompleteCallback") ? onCompleteCallback : "";
        boolean doStop = resources.isBound("stop") && stop;

        javascriptSupport.addScript(jsString, getEventName(), id, doStop, link.toAbsoluteURI(), callBackString);
    }//from w  w w  . j  a  va2  s . co  m
}

From source file:org.chenillekit.tapestry.core.base.AbstractEventMixin.java

Object onInternalEvent(Object[] context) {
    String input = request.getParameter(PARAM_NAME);

    final Holder<Object> valueHolder = Holder.create();

    ComponentEventCallback<Object> callback = new ComponentEventCallback<Object>() {
        public boolean handleResult(Object result) {
            valueHolder.put(result);/*from   ww  w  .  ja va 2  s. c  o m*/
            return true;
        }
    };
    resources.triggerEvent(getEventName(), ArrayUtils.add(context, input), callback);
    return valueHolder.get();
}

From source file:org.cloudfoundry.identity.uaa.mock.providers.IdentityProviderEndpointDocs.java

@Test
void createOAuthIdentityProvider() throws Exception {
    IdentityProvider identityProvider = new IdentityProvider();
    identityProvider.setType(OAUTH20);//from  w  ww.j av a  2  s.  co m
    identityProvider.setName("UAA Provider");
    identityProvider.setOriginKey("my-oauth2-provider");
    AbstractXOAuthIdentityProviderDefinition definition = new RawXOAuthIdentityProviderDefinition();
    definition.setAuthUrl(new URL("http://auth.url"));
    definition.setTokenUrl(new URL("http://token.url"));
    definition.setTokenKey("token-key");
    definition.setRelyingPartyId("uaa");
    definition.setRelyingPartySecret("secret");
    definition.setShowLinkText(false);
    definition.setAttributeMappings(getAttributeMappingMap());
    identityProvider.setConfig(definition);
    identityProvider.setSerializeConfigRaw(true);

    FieldDescriptor[] idempotentFields = (FieldDescriptor[]) ArrayUtils
            .addAll(commonProviderFields,
                    ArrayUtils.addAll(
                            new FieldDescriptor[] {
                                    fieldWithPath("type").required().description("`\"" + OAUTH20 + "\"`"),
                                    fieldWithPath(
                                            "originKey")
                                                    .required()
                                                    .description("A unique alias for a OAuth provider"),
                                    fieldWithPath("config.authUrl").required().type(STRING)
                                            .description("The OAuth 2.0 authorization endpoint URL"),
                                    fieldWithPath("config.tokenUrl")
                                            .required().type(STRING)
                                            .description("The OAuth 2.0 token endpoint URL"),
                                    fieldWithPath("config.tokenKeyUrl")
                                            .optional(null).type(STRING).description(
                                                    "The URL of the token key endpoint which renders a verification key for validating token signatures"),
                                    fieldWithPath("config.tokenKey")
                                            .optional(null).type(STRING).description(
                                                    "A verification key for validating token signatures, set to null if a `tokenKeyUrl` is provided."),
                                    fieldWithPath("config.showLinkText")
                                            .optional(true).type(BOOLEAN).description(
                                                    "A flag controlling whether a link to this provider's login will be shown on the UAA login page"),
                                    fieldWithPath("config.linkText")
                                            .optional(null).type(STRING)
                                            .description("Text to use for the login link to the provider"),
                                    fieldWithPath("config.relyingPartyId")
                                            .required().type(STRING).description(
                                                    "The client ID which is registered with the external OAuth provider for use by the UAA"),
                                    fieldWithPath("config.skipSslValidation")
                                            .optional(null).type(BOOLEAN).description(
                                                    "A flag controlling whether SSL validation should be skipped when communicating with the external OAuth server"),
                                    fieldWithPath("config.scopes").optional(null).type(ARRAY).description(
                                            "What scopes to request on a call to the external OAuth provider"),
                                    fieldWithPath("config.checkTokenUrl")
                                            .optional(null).type(OBJECT)
                                            .description("Reserved for future OAuth use."),
                                    fieldWithPath("config.responseType")
                                            .optional("code").type(STRING).description(
                                                    "Response type for the authorize request, will be sent to OAuth server, defaults to `code`"),
                                    fieldWithPath("config.clientAuthInBody")
                                            .optional(false).type(BOOLEAN).description(
                                                    "Sends the client credentials in the token retrieval call as body parameters instead of a Basic Authorization header."),
                                    fieldWithPath("config.issuer").optional(null).type(STRING).description(
                                            "The OAuth 2.0 token issuer. This value is used to validate the issuer inside the token."),
                                    fieldWithPath("config.attributeMappings.user_name").optional("sub")
                                            .type(STRING).description(
                                                    "Map `user_name` to the attribute for user name in the provider assertion or token. The default for OpenID Connect is `sub`"), },
                            attributeMappingFields));
    Snippet requestFields = requestFields(
            (FieldDescriptor[]) ArrayUtils.add(idempotentFields, relyingPartySecret));
    Snippet responseFields = responseFields((FieldDescriptor[]) ArrayUtils.addAll(idempotentFields,
            new FieldDescriptor[] { VERSION, ID, ADDITIONAL_CONFIGURATION, IDENTITY_ZONE_ID, CREATED,
                    LAST_MODIFIED, fieldWithPath("config.externalGroupsWhitelist").optional(null).type(ARRAY)
                            .description("Not currently used.") }));

    ResultActions resultActions = mockMvc
            .perform(post("/identity-providers").param("rawConfig", "true")
                    .header("Authorization", "Bearer " + adminToken).contentType(APPLICATION_JSON)
                    .content(serializeExcludingProperties(identityProvider, "id", "version", "created",
                            "last_modified", "identityZoneId", "config.externalGroupsWhitelist",
                            "config.checkTokenUrl", "config.additionalConfiguration")))
            .andExpect(status().isCreated());

    resultActions.andDo(document("{ClassName}/{methodName}", preprocessRequest(prettyPrint()),
            preprocessResponse(prettyPrint()),
            requestHeaders(headerWithName("Authorization").description(
                    "Bearer token containing `zones.<zone id>.admin` or `uaa.admin` or `idps.write` (only in the same zone that you are a user of)"),
                    IDENTITY_ZONE_ID_HEADER, IDENTITY_ZONE_SUBDOMAIN_HEADER),
            commonRequestParams, requestFields, responseFields));
}

From source file:org.cloudfoundry.identity.uaa.mock.providers.IdentityProviderEndpointDocs.java

@Test
void createOidcIdentityProvider() throws Exception {
    IdentityProvider identityProvider = new IdentityProvider();
    identityProvider.setType(OIDC10);//w ww .  ja v a2s.  co m
    identityProvider.setName("UAA Provider");
    identityProvider
            .setOriginKey("my-oidc-provider-" + new RandomValueStringGenerator().generate().toLowerCase());
    OIDCIdentityProviderDefinition definition = new OIDCIdentityProviderDefinition();
    definition.setDiscoveryUrl(new URL("https://accounts.google.com/.well-known/openid-configuration"));
    definition.setSkipSslValidation(true);
    definition.setRelyingPartyId("uaa");
    definition.setRelyingPartySecret("secret");
    definition.setShowLinkText(false);
    definition.setAttributeMappings(getAttributeMappingMap());
    definition.setExternalGroupsWhitelist(Arrays.asList("uaa.user"));
    List<Prompt> prompts = Arrays.asList(new Prompt("username", "text", "Email"),
            new Prompt("password", "password", "Password"),
            new Prompt("passcode", "password", "Temporary Authentication Code (Get on at /passcode)"));
    definition.setPrompts(prompts);
    identityProvider.setConfig(definition);
    identityProvider.setSerializeConfigRaw(true);

    FieldDescriptor[] idempotentFields = (FieldDescriptor[]) ArrayUtils.addAll(commonProviderFields,
            ArrayUtils.addAll(new FieldDescriptor[] {
                    fieldWithPath("type").required().description("`\"" + OIDC10 + "\"`"),
                    fieldWithPath("originKey").required()
                            .description("A unique alias for the OIDC 1.0 provider"),
                    fieldWithPath("config.discoveryUrl").optional(null).type(STRING).description(
                            "The OpenID Connect Discovery URL, typically ends with /.well-known/openid-configurationmit "),
                    fieldWithPath("config.authUrl").optional().type(STRING).description(
                            "The OIDC 1.0 authorization endpoint URL. This can be left blank if a discovery URL is provided. If both are provided, this property overrides the discovery URL.")
                            .attributes(new Attributes.Attribute("constraints",
                                    "Required unless `discoveryUrl` is set.")),
                    fieldWithPath("config.tokenUrl").optional().type(STRING).description(
                            "The OIDC 1.0 token endpoint URL.  This can be left blank if a discovery URL is provided. If both are provided, this property overrides the discovery URL.")
                            .attributes(new Attributes.Attribute("constraints",
                                    "Required unless `discoveryUrl` is set.")),
                    fieldWithPath("config.tokenKeyUrl").optional(null).type(STRING).description(
                            "The URL of the token key endpoint which renders a verification key for validating token signatures.  This can be left blank if a discovery URL is provided. If both are provided, this property overrides the discovery URL.")
                            .attributes(new Attributes.Attribute("constraints",
                                    "Required unless `discoveryUrl` is set.")),
                    fieldWithPath("config.tokenKey").optional(null).type(STRING).description(
                            "A verification key for validating token signatures. We recommend not setting this as it will not allow for key rotation.  This can be left blank if a discovery URL is provided. If both are provided, this property overrides the discovery URL.")
                            .attributes(new Attributes.Attribute("constraints",
                                    "Required unless `discoveryUrl` is set.")),
                    fieldWithPath("config.showLinkText").optional(true).type(BOOLEAN).description(
                            "A flag controlling whether a link to this provider's login will be shown on the UAA login page"),
                    fieldWithPath("config.linkText").optional(null).type(STRING)
                            .description("Text to use for the login link to the provider"),
                    fieldWithPath("config.relyingPartyId").required().type(STRING).description(
                            "The client ID which is registered with the external OAuth provider for use by the UAA"),
                    fieldWithPath("config.skipSslValidation").optional(null).type(BOOLEAN).description(
                            "A flag controlling whether SSL validation should be skipped when communicating with the external OAuth server"),
                    fieldWithPath("config.scopes").optional(null).type(ARRAY).description(
                            "What scopes to request on a call to the external OAuth/OpenID provider. For example, can provide "
                                    + "`openid`, `roles`, or `profile` to request ID token, scopes populated in the ID token external groups attribute mappings, or the user profile information, respectively."),
                    fieldWithPath("config.checkTokenUrl").optional(null).type(OBJECT)
                            .description("Reserved for future OAuth/OIDC use."),
                    fieldWithPath("config.clientAuthInBody").optional(false).type(BOOLEAN).description(
                            "Sends the client credentials in the token retrieval call as body parameters instead of a Basic Authorization header."),
                    fieldWithPath("config.userInfoUrl").optional(null).type(OBJECT).description(
                            "Reserved for future OIDC use.  This can be left blank if a discovery URL is provided. If both are provided, this property overrides the discovery URL."),
                    fieldWithPath("config.responseType").optional("code").type(STRING).description(
                            "Response type for the authorize request, defaults to `code`, but can be `code id_token` if the OIDC server can return an id_token as a query parameter in the redirect."),
                    fieldWithPath("config.issuer").optional(null).type(STRING).description(
                            "The OAuth 2.0 token issuer. This value is used to validate the issuer inside the token."),
                    GROUP_WHITELIST,
                    fieldWithPath("config.passwordGrantEnabled").optional(false).type(BOOLEAN).description(
                            "Enable Resource Owner Password Grant flow for this identity provider."),
                    fieldWithPath("config.attributeMappings.user_name").optional("sub").type(STRING)
                            .description(
                                    "Map `user_name` to the attribute for user name in the provider assertion or token. The default for OpenID Connect is `sub`."),
                    fieldWithPath("config.prompts[]").optional(null).type(ARRAY).description(
                            "List of fields that users are prompted on to the OIDC provider through the password grant flow. Defaults to username, password, and passcode. Any additional prompts beyond username, password, and passcode will be forwarded on to the OIDC provider."),
                    fieldWithPath("config.prompts[].name").optional(null).type(STRING)
                            .description("Name of field"),
                    fieldWithPath("config.prompts[].type").optional(null).type(STRING)
                            .description("What kind of field this is (e.g. text or password)"),
                    fieldWithPath("config.prompts[].text").optional(null).type(STRING)
                            .description("Actual text displayed on prompt for field") },
                    attributeMappingFields));
    Snippet requestFields = requestFields(
            (FieldDescriptor[]) ArrayUtils.add(idempotentFields, relyingPartySecret));
    Snippet responseFields = responseFields(
            (FieldDescriptor[]) ArrayUtils.addAll(idempotentFields, new FieldDescriptor[] { VERSION, ID,
                    ADDITIONAL_CONFIGURATION, IDENTITY_ZONE_ID, CREATED, LAST_MODIFIED, }));

    ResultActions resultActions = mockMvc.perform(post("/identity-providers").param("rawConfig", "true")
            .header("Authorization", "Bearer " + adminToken).contentType(APPLICATION_JSON)
            .content(serializeExcludingProperties(identityProvider, "id", "version", "created", "last_modified",
                    "identityZoneId", "config.checkTokenUrl", "config.additionalConfiguration")))
            .andDo(print()).andExpect(status().isCreated());

    resultActions.andDo(document("{ClassName}/{methodName}", preprocessRequest(prettyPrint()),
            preprocessResponse(prettyPrint()),
            requestHeaders(headerWithName("Authorization").description(
                    "Bearer token containing `zones.<zone id>.admin` or `uaa.admin` or `idps.write` (only in the same zone that you are a user of)"),
                    IDENTITY_ZONE_ID_HEADER, IDENTITY_ZONE_SUBDOMAIN_HEADER),
            commonRequestParams, requestFields, responseFields));
}

From source file:org.cloudfoundry.identity.uaa.mock.providers.IdentityProviderEndpointDocs.java

@Test
void create_SearchAndBind_Groups_Map_ToScopes_LDAPIdentityProvider() throws Exception {
    IdentityProvider identityProvider = MultitenancyFixture.identityProvider(OriginKeys.LDAP, "");
    identityProvider.setType(LDAP);/*  ww w  .  ja v  a2s . co  m*/

    LdapIdentityProviderDefinition providerDefinition = new LdapIdentityProviderDefinition();
    providerDefinition.setLdapProfileFile("ldap/ldap-search-and-bind.xml");
    providerDefinition.setLdapGroupFile("ldap/ldap-groups-map-to-scopes.xml");
    providerDefinition.setBaseUrl(ldapServerUrl);
    providerDefinition.setBindUserDn("cn=admin,ou=Users,dc=test,dc=com");
    providerDefinition.setBindPassword("adminsecret");
    providerDefinition.setUserSearchBase("dc=test,dc=com");
    providerDefinition.setUserSearchFilter("cn={0}");
    providerDefinition.setGroupSearchBase("ou=scopes,dc=test,dc=com");
    providerDefinition.setGroupSearchFilter("member={0}");
    providerDefinition.setMailAttributeName("mail");
    providerDefinition.setMailSubstitute("{0}@my.org");
    providerDefinition.setMailSubstituteOverridesLdap(false);
    providerDefinition.setGroupSearchSubTree(true);
    providerDefinition.setMaxGroupSearchDepth(3);

    identityProvider.setConfig(providerDefinition);
    identityProvider.setSerializeConfigRaw(true);

    FieldDescriptor[] fields = (FieldDescriptor[]) ArrayUtils.add(ldapSearchAndBind_GroupsToScopes,
            LDAP_BIND_PASSWORD);
    createLDAPProvider(identityProvider, fields,
            "create_SearchAndBind_Groups_Map_ToScopes_LDAPIdentityProvider");

}

From source file:org.codehaus.groovy.eclipse.core.model.GroovyRuntime.java

/**
 * Adds a classpath entry to a project//from w w w. j av a2s.co  m
 *
 * @param project
 *            The project to add the entry to.
 * @param newEntry
 *            The entry to add.
 * @throws JavaModelException
 */
public static void addClassPathEntry(IJavaProject project, IClasspathEntry newEntry) throws JavaModelException {
    IClasspathEntry[] newEntries = (IClasspathEntry[]) ArrayUtils.add(project.getRawClasspath(), newEntry);
    project.setRawClasspath(newEntries, null);
}