Search in sources :

Example 1 with XmlParser

use of org.codice.ddf.parser.xml.XmlParser in project ddf by codice.

the class RegistryPackageWebConverterTest method setUp.

@Before
public void setUp() {
    parser = new XmlParser();
    configurator = parser.configureParser(Arrays.asList(RegistryObjectType.class.getPackage().getName(), EbrimConstants.OGC_FACTORY.getClass().getPackage().getName(), EbrimConstants.GML_FACTORY.getClass().getPackage().getName()), this.getClass().getClassLoader());
}
Also used : XmlParser(org.codice.ddf.parser.xml.XmlParser) Before(org.junit.Before)

Example 2 with XmlParser

use of org.codice.ddf.parser.xml.XmlParser in project ddf by codice.

the class UPBSTValidatorTest method testValidateBadTokenCache.

@Test
public void testValidateBadTokenCache() {
    UPBSTValidator upbstValidator = getUpbstValidator(new XmlParser(), meanValidator);
    upbstValidator.addRealm(null);
    TokenValidatorParameters tokenParameters = new TokenValidatorParameters();
    tokenParameters.setTokenStore(new TokenStore() {

        @Override
        public void add(SecurityToken token) {
        }

        @Override
        public void add(String identifier, SecurityToken token) {
        }

        @Override
        public void remove(String identifier) {
        }

        @Override
        public Collection<String> getTokenIdentifiers() {
            return null;
        }

        @Override
        public SecurityToken getToken(String identifier) {
            SecurityToken securityToken = new SecurityToken();
            securityToken.setTokenHash(-1432225336);
            return securityToken;
        }
    });
    ReceivedToken validateTarget = new ReceivedToken(upbstToken);
    tokenParameters.setToken(validateTarget);
    tokenParameters.setStsProperties(stsPropertiesMBean);
    TokenValidatorResponse response = upbstValidator.validateToken(tokenParameters);
    Assert.assertEquals(ReceivedToken.STATE.INVALID, response.getToken().getState());
    verify(failedLoginDelayer, times(1)).delay(anyString());
}
Also used : TokenValidatorParameters(org.apache.cxf.sts.token.validator.TokenValidatorParameters) SecurityToken(org.apache.cxf.ws.security.tokenstore.SecurityToken) XmlParser(org.codice.ddf.parser.xml.XmlParser) Collection(java.util.Collection) TokenValidatorResponse(org.apache.cxf.sts.token.validator.TokenValidatorResponse) Matchers.anyString(org.mockito.Matchers.anyString) ReceivedToken(org.apache.cxf.sts.request.ReceivedToken) TokenStore(org.apache.cxf.ws.security.tokenstore.TokenStore) Test(org.junit.Test)

Example 3 with XmlParser

use of org.codice.ddf.parser.xml.XmlParser in project ddf by codice.

the class TestXmlMetacardTransformer method setup.

@Before
public void setup() {
    Parser parser = new XmlParser();
    MetacardMarshaller metacardMarshaller = new MetacardMarshallerImpl(parser, new PrintWriterProviderImpl());
    transformer = new XmlMetacardTransformer(metacardMarshaller);
}
Also used : XmlParser(org.codice.ddf.parser.xml.XmlParser) MetacardMarshallerImpl(ddf.catalog.transformer.xml.MetacardMarshallerImpl) MetacardMarshaller(ddf.catalog.transformer.api.MetacardMarshaller) PrintWriterProviderImpl(ddf.catalog.transformer.xml.PrintWriterProviderImpl) XmlMetacardTransformer(ddf.catalog.transformer.xml.XmlMetacardTransformer) XmlParser(org.codice.ddf.parser.xml.XmlParser) Parser(org.codice.ddf.parser.Parser) Before(org.junit.Before)

Example 4 with XmlParser

use of org.codice.ddf.parser.xml.XmlParser in project ddf by codice.

the class TestXmlResponseQueueTransformer method setup.

@Before
public void setup() throws MimeTypeParseException {
    parser = new XmlParser();
    PrintWriterProvider printWriterProvider = new PrintWriterProviderImpl();
    MetacardMarshaller metacardMarshaller = new MetacardMarshallerImpl(parser, printWriterProvider);
    mimeType = getMimeType();
    transformer = new XmlResponseQueueTransformer(parser, FJP, printWriterProvider, metacardMarshaller, mimeType);
}
Also used : XmlParser(org.codice.ddf.parser.xml.XmlParser) MetacardMarshallerImpl(ddf.catalog.transformer.xml.MetacardMarshallerImpl) PrintWriterProvider(ddf.catalog.transformer.api.PrintWriterProvider) MetacardMarshaller(ddf.catalog.transformer.api.MetacardMarshaller) PrintWriterProviderImpl(ddf.catalog.transformer.xml.PrintWriterProviderImpl) XmlResponseQueueTransformer(ddf.catalog.transformer.xml.XmlResponseQueueTransformer) Before(org.junit.Before)

Example 5 with XmlParser

use of org.codice.ddf.parser.xml.XmlParser in project ddf by codice.

the class TestUsernameTokenValidator method testValidateBadTokenNoTokenStore.

@Test
public void testValidateBadTokenNoTokenStore() {
    UsernameTokenValidator usernameTokenValidator = getUsernameTokenValidator(new XmlParser(), meanValidator);
    usernameTokenValidator.addRealm(null);
    TokenValidatorParameters tokenValidatorParameters = mock(TokenValidatorParameters.class);
    STSPropertiesMBean stsPropertiesMBean = mock(STSPropertiesMBean.class);
    when(stsPropertiesMBean.getSignatureCrypto()).thenReturn(mock(Crypto.class));
    when(tokenValidatorParameters.getStsProperties()).thenReturn(stsPropertiesMBean);
    ReceivedToken receivedToken = mock(ReceivedToken.class);
    doCallRealMethod().when(receivedToken).setState(any(ReceivedToken.STATE.class));
    doCallRealMethod().when(receivedToken).getState();
    when(receivedToken.isUsernameToken()).thenReturn(true);
    when(tokenValidatorParameters.getToken()).thenReturn(receivedToken);
    Set<Class<?>> classes = new HashSet<>();
    classes.add(ObjectFactory.class);
    classes.add(org.apache.cxf.ws.security.sts.provider.model.wstrust14.ObjectFactory.class);
    JAXBContextCache.CachedContextAndSchemas cache = null;
    try {
        cache = JAXBContextCache.getCachedContextAndSchemas(classes, null, null, null, false);
    } catch (JAXBException e) {
        fail(e.getMessage());
    }
    JAXBContext jaxbContext = cache.getContext();
    Unmarshaller unmarshaller = null;
    try {
        if (jaxbContext != null) {
            unmarshaller = jaxbContext.createUnmarshaller();
        }
    } catch (JAXBException e) {
        fail(e.getMessage());
    }
    JAXBElement<?> token = null;
    if (unmarshaller != null) {
        try {
            token = (JAXBElement<?>) unmarshaller.unmarshal(this.getClass().getResourceAsStream("/user-no-password.xml"));
        } catch (JAXBException e) {
            fail(e.getMessage());
        }
    }
    when(receivedToken.getToken()).thenReturn(token.getValue());
    TokenValidatorResponse tokenValidatorResponse = usernameTokenValidator.validateToken(tokenValidatorParameters);
    assertEquals(ReceivedToken.STATE.INVALID, tokenValidatorResponse.getToken().getState());
    verify(failedLoginDelayer, times(1)).delay(anyString());
}
Also used : XmlParser(org.codice.ddf.parser.xml.XmlParser) JAXBContextCache(org.apache.cxf.common.jaxb.JAXBContextCache) JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) TokenValidatorParameters(org.apache.cxf.sts.token.validator.TokenValidatorParameters) Crypto(org.apache.wss4j.common.crypto.Crypto) JAASUsernameTokenValidator(org.apache.wss4j.dom.validate.JAASUsernameTokenValidator) STSPropertiesMBean(org.apache.cxf.sts.STSPropertiesMBean) TokenValidatorResponse(org.apache.cxf.sts.token.validator.TokenValidatorResponse) ReceivedToken(org.apache.cxf.sts.request.ReceivedToken) Unmarshaller(javax.xml.bind.Unmarshaller) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

XmlParser (org.codice.ddf.parser.xml.XmlParser)32 Test (org.junit.Test)16 Before (org.junit.Before)14 ReceivedToken (org.apache.cxf.sts.request.ReceivedToken)9 TokenValidatorParameters (org.apache.cxf.sts.token.validator.TokenValidatorParameters)9 SecurityLogger (ddf.security.audit.SecurityLogger)7 JAXBContext (javax.xml.bind.JAXBContext)7 TokenValidatorResponse (org.apache.cxf.sts.token.validator.TokenValidatorResponse)7 File (java.io.File)5 HashSet (java.util.HashSet)5 RegistryObjectMetacardType (org.codice.ddf.registry.common.metacard.RegistryObjectMetacardType)5 MetacardMarshaller (org.codice.ddf.registry.schemabindings.helper.MetacardMarshaller)5 MetacardMarshaller (ddf.catalog.transformer.api.MetacardMarshaller)4 MetacardMarshallerImpl (ddf.catalog.transformer.xml.MetacardMarshallerImpl)4 PrintWriterProviderImpl (ddf.catalog.transformer.xml.PrintWriterProviderImpl)4 ArrayList (java.util.ArrayList)4 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)3 XmlMetacardTransformer (ddf.catalog.transformer.xml.XmlMetacardTransformer)3 StringWriter (java.io.StringWriter)3 Writer (java.io.Writer)3