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

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

Introduction

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

Prototype

public static double[] addAll(double[] array1, double[] array2) 

Source Link

Document

Adds all the elements of the given arrays into a new array.

Usage

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

@Test
public void createOidcIdentityProvider() throws Exception {
    IdentityProvider identityProvider = new IdentityProvider();
    identityProvider.setType(OIDC10);/*www . j a v a  2  s.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);
    identityProvider.setConfig(definition);
    identityProvider.setSerializeConfigRaw(true);

    FieldDescriptor[] idempotentFields = (FieldDescriptor[]) ArrayUtils.addAll(commonProviderFields,
            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").required().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."),
                    fieldWithPath("config.tokenUrl").required().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."),
                    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."),
                    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."),
                    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.relyingPartySecret").required().type(STRING).description(
                            "The client secret of the relying party at the external OAuth provider"),
                    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.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."),
                    ADD_SHADOW_USER_ON_LOGIN, EXTERNAL_GROUPS, ATTRIBUTE_MAPPING,
                    fieldWithPath("config.attributeMappings.user_name").optional("preferred_username")
                            .type(STRING).description(
                                    "Map `user_name` to the attribute for username in the provider assertion."),
                    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.") });
    Snippet requestFields = requestFields(idempotentFields);

    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 = getMockMvc()
            .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")))
            .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)"),
                    headerWithName("X-Identity-Zone-Id").description(
                            "May include this header to administer another zone if using `zones.<zone id>.admin` or `uaa.admin` scope against the default UAA zone.")
                            .optional()),
            commonRequestParams, requestFields, responseFields));
}

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

public void createLDAPProvider(IdentityProvider<LdapIdentityProviderDefinition> identityProvider,
        FieldDescriptor[] fields, String name) throws Exception {
    BaseClientDetails admin = new BaseClientDetails("admin", null, "", "client_credentials", "uaa.admin");
    admin.setClientSecret("adminsecret");

    IdentityZoneCreationResult zone = MockMvcUtils.createOtherIdentityZoneAndReturnResult(
            new RandomValueStringGenerator(8).generate().toLowerCase(), getMockMvc(),
            getWebApplicationContext(), admin);

    Snippet requestFields = requestFields(fields);

    Snippet responseFields = responseFields(
            (FieldDescriptor[]) ArrayUtils.addAll(ldapAllFields, new FieldDescriptor[] { VERSION, ID,
                    ADDITIONAL_CONFIGURATION, IDENTITY_ZONE_ID, CREATED, LAST_MODIFIED }));

    ResultActions resultActions = getMockMvc()
            .perform(post("/identity-providers")
                    .header(IdentityZoneSwitchingFilter.SUBDOMAIN_HEADER, zone.getIdentityZone().getSubdomain())
                    .param("rawConfig", "true").header("Authorization", "Bearer " + zone.getZoneAdminToken())
                    .contentType(APPLICATION_JSON)
                    .content(serializeExcludingProperties(identityProvider, "id", "version", "created",
                            "last_modified", "identityZoneId", "config.additionalConfiguration")))
            .andExpect(status().isCreated());

    resultActions.andDo(document("{ClassName}/" + name, 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)"),
                    headerWithName("X-Identity-Zone-Id").description(
                            "May include this header to administer another zone if using `zones.<zone id>.admin` or `uaa.admin` scope against the default UAA zone.")
                            .optional()),
            commonRequestParams, requestFields, responseFields));

    getMockMvc()/*www . j  a v  a  2s . c o  m*/
            .perform(post("/login.do").header("Host", zone.getIdentityZone().getSubdomain() + ".localhost")
                    .with(cookieCsrf()).param("username", "marissa4").param("password", "ldap4"))
            .andExpect(status().isFound()).andExpect(redirectedUrl("/"));

}

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

@Test
public void updateIdentityProvider() throws Exception {
    IdentityProvider identityProvider = identityProviderProvisioning.retrieveByOrigin(OriginKeys.UAA,
            IdentityZoneHolder.get().getId());

    UaaIdentityProviderDefinition config = new UaaIdentityProviderDefinition();
    config.setLockoutPolicy(new LockoutPolicy(8, 8, 8));
    identityProvider.setConfig(config);/*from w w w.  j  av  a2 s .com*/
    identityProvider.setSerializeConfigRaw(true);

    FieldDescriptor[] idempotentFields = (FieldDescriptor[]) ArrayUtils.addAll(commonProviderFields,
            new FieldDescriptor[] { fieldWithPath("type").required().description("`uaa`"),
                    fieldWithPath("originKey").required()
                            .description("A unique identifier for the IDP. Cannot be updated."),
                    VERSION.required(), fieldWithPath("config.passwordPolicy").ignored(),
                    fieldWithPath("config.passwordPolicy.minLength")
                            .constrained("Required when `passwordPolicy` in the config is not null")
                            .type(NUMBER)
                            .description(
                                    "Minimum number of characters required for password to be considered valid (defaults to 0).")
                            .optional(),
                    fieldWithPath("config.passwordPolicy.maxLength")
                            .constrained("Required when `passwordPolicy` in the config is not null")
                            .type(NUMBER)
                            .description(
                                    "Maximum number of characters required for password to be considered valid (defaults to 255).")
                            .optional(),
                    fieldWithPath("config.passwordPolicy.requireUpperCaseCharacter")
                            .constrained("Required when `passwordPolicy` in the config is not null")
                            .type(NUMBER)
                            .description(
                                    "Minimum number of uppercase characters required for password to be considered valid (defaults to 0).")
                            .optional(),
                    fieldWithPath("config.passwordPolicy.requireLowerCaseCharacter")
                            .constrained("Required when `passwordPolicy` in the config is not null")
                            .type(NUMBER)
                            .description(
                                    "Minimum number of lowercase characters required for password to be considered valid (defaults to 0).")
                            .optional(),
                    fieldWithPath("config.passwordPolicy.requireDigit")
                            .constrained("Required when `passwordPolicy` in the config is not null")
                            .type(NUMBER)
                            .description(
                                    "Minimum number of digits required for password to be considered valid (defaults to 0).")
                            .optional(),
                    fieldWithPath("config.passwordPolicy.requireSpecialCharacter")
                            .constrained("Required when `passwordPolicy` in the config is not null")
                            .type(NUMBER)
                            .description(
                                    "Minimum number of special characters required for password to be considered valid (defaults to 0).")
                            .optional(),
                    fieldWithPath("config.passwordPolicy.expirePasswordInMonths")
                            .constrained("Required when `passwordPolicy` in the config is not null")
                            .type(NUMBER)
                            .description(
                                    "Number of months after which current password expires (defaults to 0).")
                            .optional(),
                    fieldWithPath("config.passwordPolicy.passwordNewerThan")
                            .constrained("Required when `passwordPolicy` in the config is not null")
                            .type(NUMBER).description(
                                    "This timestamp value can be used to force change password for every user. If the user's passwordLastModified is older than this value, the password is expired (defaults to null)."),
                    fieldWithPath("config.lockoutPolicy.lockoutPeriodSeconds")
                            .constrained("Required when `LockoutPolicy` in the config is not null").type(NUMBER)
                            .description(
                                    "Number of seconds in which lockoutAfterFailures failures must occur in order for account to be locked (defaults to 3600).")
                            .optional(),
                    fieldWithPath("config.lockoutPolicy.lockoutAfterFailures")
                            .constrained("Required when `LockoutPolicy` in the config is not null").type(NUMBER)
                            .description("Number of allowed failures before account is locked (defaults to 5).")
                            .optional(),
                    fieldWithPath("config.lockoutPolicy.countFailuresWithin")
                            .constrained("Required when `LockoutPolicy` in the config is not null").type(NUMBER)
                            .description(
                                    "Number of seconds to lock out an account when lockoutAfterFailures failures is exceeded (defaults to 300).")
                            .optional(),
                    fieldWithPath("config.disableInternalUserManagement").optional(null).type(BOOLEAN)
                            .description(
                                    "When set to true, user management is disabled for this provider, defaults to false")
                            .optional() });
    Snippet requestFields = requestFields(idempotentFields);

    Snippet responseFields = responseFields(
            (FieldDescriptor[]) ArrayUtils.addAll(idempotentFields, new FieldDescriptor[] { VERSION, ID,
                    ADDITIONAL_CONFIGURATION, IDENTITY_ZONE_ID, CREATED, LAST_MODIFIED, }));

    getMockMvc()
            .perform(put("/identity-providers/{id}", identityProvider.getId()).param("rawConfig", "true")
                    .header("Authorization", "Bearer " + adminToken).contentType(APPLICATION_JSON)
                    .content(serializeExcludingProperties(identityProvider, "id", "created", "last_modified",
                            "identityZoneId", "config.additionalConfiguration")))
            .andExpect(status().isOk())
            .andDo(document("{ClassName}/{methodName}", preprocessResponse(prettyPrint()),
                    pathParameters(parameterWithName("id").description(ID_DESC)),
                    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)"),
                            headerWithName("X-Identity-Zone-Id").description(
                                    "May include this header to administer another zone if using `zones.<zone id>.admin` or `uaa.admin` scope against the default UAA zone.")
                                    .optional()),
                    commonRequestParams, requestFields, responseFields));
}

From source file:org.codehaus.groovy.grails.plugins.DefaultGrailsPlugin.java

/**
 * @return the watchedResources//from  w  w w . j  a v  a2 s  . c o  m
 */
public Resource[] getWatchedResources() {
    if (watchedResources.length == 0 && watchedResourcePatternReferences != null) {
        for (String resourcesReference : watchedResourcePatternReferences) {
            try {
                Resource[] resources = resolver.getResources(resourcesReference);
                if (resources.length > 0) {
                    watchedResources = (Resource[]) ArrayUtils.addAll(watchedResources, resources);
                }
            } catch (Exception ignored) {
                // ignore
            }
        }
    }
    return watchedResources;
}

From source file:org.codelabor.example.remoting.message.services.MessageAdapterServiceImpl.java

public void call(HeaderDTO inputHeaderDTO, DataDTO inputDataDTO, HeaderDTO outputHeaderDTO,
        DataDTO outputDataDTO) throws Exception {

    // stnd_tlg_thwh_len
    KsfcHeaderDTO ksfcInputHeaderDTO = (KsfcHeaderDTO) inputHeaderDTO;
    int stndTlgThwhLen = ksfcInputHeaderDTO.getLength() + inputDataDTO.toBytes().length;
    ksfcInputHeaderDTO.getSystemHeaderDTO().setStndTlgThwhLen(stndTlgThwhLen);

    // tlg_dscd/*ww w.  j  a v a  2s  .com*/
    ksfcInputHeaderDTO.getSystemHeaderDTO().setTlgDscd("S");

    // itn_incd
    ksfcInputHeaderDTO.getSystemHeaderDTO().setItnIncd("KSF");

    // sys_dscd
    ksfcInputHeaderDTO.getSystemHeaderDTO().setSysDscd("UA");

    // tr_id
    String nextId = idGenerationService.getNextStringId();
    String pid = nextId.substring(3, 11);
    ksfcInputHeaderDTO.getSystemHeaderDTO().setTrIdChCode(nextId.substring(0, 3));
    ksfcInputHeaderDTO.getSystemHeaderDTO().setTrIdPid(pid);
    ksfcInputHeaderDTO.getSystemHeaderDTO().setTrIdReqDt(nextId.substring(11, 17));
    ksfcInputHeaderDTO.getSystemHeaderDTO().setTrIdReqTm(nextId.substring(17, 25));
    ksfcInputHeaderDTO.getSystemHeaderDTO().setTrIdSeq(nextId.substring(25, 27));

    // lnkg_sno
    ksfcInputHeaderDTO.getSystemHeaderDTO().setLnkgSno("000");

    // og_tr_id
    ksfcInputHeaderDTO.getSystemHeaderDTO().setOgTrId(nextId);

    // cd_vl_stup_dscd
    ksfcInputHeaderDTO.getSystemHeaderDTO().setCdVlStupDscd(0);

    // sync_dscd
    ksfcInputHeaderDTO.getSystemHeaderDTO().setSyncDscd("S");

    // rsp_tpcd
    ksfcInputHeaderDTO.getSystemHeaderDTO().setRspTpcd(0);

    // tlg_pout_tpcd
    ksfcInputHeaderDTO.getSystemHeaderDTO().setTlgPoutTpcd(0);

    // nxt_tr_yn
    ksfcInputHeaderDTO.getSystemHeaderDTO().setNxtTrYn(0);
    // tmnl_ip
    ksfcInputHeaderDTO.getSystemHeaderDTO().setTmnlIp(SecurityContextUtil.getRemoteAddress());

    // tr_rqs_chnl_cd
    ksfcInputHeaderDTO.getSystemHeaderDTO().setTrRqsChnlCd("IBS");

    // og_tr_rqs_chnl_cd
    ksfcInputHeaderDTO.getSystemHeaderDTO().setOgTrRqsChnlCd("IBS");

    // tr_prcs_rsl_cd
    ksfcInputHeaderDTO.getSystemHeaderDTO().setTrPrcsRslCd(0);

    // og_tr_cd
    ksfcInputHeaderDTO.getSystemHeaderDTO().setOgTrCd(nextId);

    // hnd_empno
    ksfcInputHeaderDTO.getTransactionHeaderDTO().setHndEmpno("Z9001");

    // lgn_yn
    // ksfcInputHeaderDTO.getTransactionHeaderDTO().setLgnYn(BooleanUtils.toInteger(SecurityContextUtil.isAuthenticated()));
    ksfcInputHeaderDTO.getTransactionHeaderDTO().setLgnYn(1);

    // clsn_bf_af_dscd
    ksfcInputHeaderDTO.getTransactionHeaderDTO().setClsnBfAfDscd("0");

    // iccd_rdr_inp_yn
    ksfcInputHeaderDTO.getTransactionHeaderDTO().setIccdRdrInpYn("N");

    // pinpd_inp_yn
    ksfcInputHeaderDTO.getTransactionHeaderDTO().setPinpdInpYn("N");

    // bkbk_prtr_inp_yn
    ksfcInputHeaderDTO.getTransactionHeaderDTO().setBkbkPrtrInpYn("N");

    // rspr_aprv_tr_obj_yn
    ksfcInputHeaderDTO.getTransactionHeaderDTO().setRsprAprvTrObjYn("0");

    // cnc_tlg_dscd
    ksfcInputHeaderDTO.getTransactionHeaderDTO().setCncTlgDscd(0);

    // tlg_tr_tpcd
    ksfcInputHeaderDTO.getTransactionHeaderDTO().setTlgTrTpcd(0);

    byte[] inputHeaderBytes = inputHeaderDTO.toBytes();
    byte[] inputDataBytes = inputDataDTO.toBytes();
    byte[] inputMessageBytes = ArrayUtils.addAll(inputHeaderBytes, inputDataBytes);

    String inputMessage = new String(inputMessageBytes, charsetName);
    String outputMessage = socketAdapterService.send(inputMessage);
    if (log.isDebugEnabled()) {
        StringBuilder sb = new StringBuilder();
        sb.append("input message: ").append(inputMessage);
        log.debug(sb.toString());
        sb = new StringBuilder();
        sb.append("output message: ").append(outputMessage);
        log.debug(sb.toString());
    }

    byte[] outputMessageBytes = outputMessage.getBytes(charsetName);
    byte[] outputHeaderBytes = ArrayUtils.subarray(outputMessageBytes, 0, outputHeaderDTO.getLength());
    byte[] outputDataBytes = ArrayUtils.subarray(outputMessageBytes, outputHeaderDTO.getLength(),
            outputMessageBytes.length);
    outputHeaderDTO.fromBytes(outputHeaderBytes);
    if (!outputHeaderDTO.isError()) {
        outputDataDTO.fromBytes(outputDataBytes);
    }
}

From source file:org.codice.ddf.configuration.migration.AbstractMigrationSupport.java

/**
 * Creates a test directory under ${ddf.home} with the given name(s).
 *
 * @param dirs the directory pathnames to create under ${ddf.home} (one per level)
 * @return the newly created directory//www.java 2 s  .  c o m
 * @throws IOException if an I/O error occurs while creating the test directory
 */
public Path createDirectory(String... dirs) throws IOException {
    return testFolder.newFolder((String[]) ArrayUtils.addAll(new String[] { "ddf" }, dirs)).toPath();
}

From source file:org.codice.ddf.libs.klv.KlvDecoderTest.java

@Test
// One-byte length encoding has already been tested in all the key length tests.
public void testTwoByteLengthEncoding() throws KlvDecodingException {
    final byte[] expectedValueBytes = new byte[256];
    Arrays.fill(expectedValueBytes, (byte) 4);
    final byte[] klvBytes = ArrayUtils.addAll(new byte[] { 5, 1, 0 }, expectedValueBytes);
    final byte[] value = getValueBytes(KeyLength.OneByte, LengthEncoding.TwoBytes, klvBytes);
    assertThat(value, is(expectedValueBytes));
}

From source file:org.codice.ddf.libs.klv.KlvDecoderTest.java

@Test
public void testFourByteLengthEncoding() throws KlvDecodingException {
    final byte[] expectedValueBytes = new byte[256];
    Arrays.fill(expectedValueBytes, (byte) -2);
    final byte[] klvBytes = ArrayUtils.addAll(new byte[] { 5, 0, 0, 1, 0 }, expectedValueBytes);
    final byte[] value = getValueBytes(KeyLength.OneByte, LengthEncoding.FourBytes, klvBytes);
    assertThat(value, is(expectedValueBytes));
}

From source file:org.codice.ddf.libs.klv.KlvDecoderTest.java

@Test
public void testBERLengthEncodingSingleByte() throws KlvDecodingException {
    final byte length = 100;
    final byte[] expectedValueBytes = new byte[length];
    Arrays.fill(expectedValueBytes, (byte) 101);
    final byte[] klvBytes = ArrayUtils.addAll(new byte[] { 5, length }, expectedValueBytes);
    final byte[] value = getValueBytes(KeyLength.OneByte, LengthEncoding.BER, klvBytes);
    assertThat(value, is(expectedValueBytes));
}

From source file:org.codice.ddf.libs.klv.KlvDecoderTest.java

@Test
public void testBERLengthEncodingMultipleBytes() throws KlvDecodingException {
    final byte length = 55;
    final byte[] expectedValueBytes = new byte[length];
    Arrays.fill(expectedValueBytes, (byte) -25);
    final byte[] klvBytes = ArrayUtils.addAll(new byte[] { 5, (byte) 0b10000001, length }, expectedValueBytes);
    final byte[] value = getValueBytes(KeyLength.OneByte, LengthEncoding.BER, klvBytes);
    assertThat(value, is(expectedValueBytes));
}