Java Code Examples for org.apache.cxf.service.model.EndpointInfo#getProperty()

The following examples show how to use org.apache.cxf.service.model.EndpointInfo#getProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KerberosTokenInterceptorProvider.java    From steady with Apache License 2.0 6 votes vote down vote up
static final TokenStore getTokenStore(Message message) {
    EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
    synchronized (info) {
        TokenStore tokenStore = 
            (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        if (tokenStore == null) {
            tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        }
        if (tokenStore == null) {
            TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance();
            String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE;
            if (info.getName() != null) {
                cacheKey += "-" + info.getName().toString().hashCode();
            }
            tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message);
            info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore);
        }
        return tokenStore;
    }
}
 
Example 2
Source File: IssuedTokenInterceptorProvider.java    From steady with Apache License 2.0 6 votes vote down vote up
static final TokenStore createTokenStore(Message message) {
    EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
    synchronized (info) {
        TokenStore tokenStore = 
            (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        if (tokenStore == null) {
            tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        }
        if (tokenStore == null) {
            TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance();
            String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE;
            if (info.getName() != null) {
                cacheKey += "-" + info.getName().toString().hashCode();
            }
            tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message);
            info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore);
        }
        return tokenStore;
    }
}
 
Example 3
Source File: NegotiationUtils.java    From steady with Apache License 2.0 6 votes vote down vote up
static TokenStore getTokenStore(Message message) {
    EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
    synchronized (info) {
        TokenStore tokenStore = 
            (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        if (tokenStore == null) {
            tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        }
        if (tokenStore == null) {
            TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance();
            String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE;
            if (info.getName() != null) {
                cacheKey += "-" + info.getName().toString().hashCode();
            }
            tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message);
            info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore);
        }
        return tokenStore;
    }
}
 
Example 4
Source File: NegotiationUtils.java    From steady with Apache License 2.0 6 votes vote down vote up
static TokenStore getTokenStore(Message message) {
    EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
    synchronized (info) {
        TokenStore tokenStore = 
            (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        if (tokenStore == null) {
            tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        }
        if (tokenStore == null) {
            TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance();
            String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE;
            if (info.getName() != null) {
                cacheKey += "-" + info.getName().toString().hashCode();
            }
            tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message);
            info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore);
        }
        return tokenStore;
    }
}
 
Example 5
Source File: STSTokenValidator.java    From steady with Apache License 2.0 6 votes vote down vote up
static final TokenStore getTokenStore(Message message) {
    EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
    synchronized (info) {
        TokenStore tokenStore = 
            (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        if (tokenStore == null) {
            tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        }
        if (tokenStore == null) {
            TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance();
            String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE;
            if (info.getName() != null) {
                cacheKey += "-" + info.getName().toString().hashCode();
            }
            tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message);
            info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore);
        }
        return tokenStore;
    }
}
 
Example 6
Source File: CacheCleanupListener.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void shutdownResources(EndpointInfo info) {
    TokenStore ts = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
    if (ts instanceof Closeable) {
        close((Closeable)ts);
    }
    ReplayCache rc = (ReplayCache)info.getProperty(SecurityConstants.NONCE_CACHE_INSTANCE);
    if (rc != null) {
        close(rc);
    }
    rc = (ReplayCache)info.getProperty(SecurityConstants.TIMESTAMP_CACHE_INSTANCE);
    if (rc != null) {
        close(rc);
    }
    rc = (ReplayCache)info.getProperty(SecurityConstants.SAML_ONE_TIME_USE_CACHE_INSTANCE);
    if (rc != null) {
        close(rc);
    }
}
 
Example 7
Source File: ProtobufQueryHandler.java    From fuchsia with Apache License 2.0 6 votes vote down vote up
/**
 * @see org.apache.cxf.transports.http.QueryHandler#writeResponse(String,.
 * String, org.apache.cxf.service.model.EndpointInfo,
 * java.io.OutputStream)
 */
@SuppressWarnings("unchecked")
public void writeResponse(String fullQueryString, String ctx,
                          EndpointInfo endpoint, OutputStream os) {
    try {
        Class<? extends Message> messageClass = endpoint.getProperty(
                ProtobufServerFactoryBean.PROTOBUF_MESSAGE_CLASS,
                Class.class);
        PrintStream out = new PrintStream(os);
        Descriptor wrapperMessage = ((Descriptor) messageClass.getMethod(
                "getDescriptor").invoke(null));
        new ProtoGenerator().generateProtoFromDescriptor(wrapperMessage
                .getFile(), out, wrapperMessage);
        out.flush();
    } catch (Exception x) {
        throw new RuntimeException(x);
    }
}
 
Example 8
Source File: NegotiationUtils.java    From steady with Apache License 2.0 6 votes vote down vote up
static TokenStore getTokenStore(Message message) {
    EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
    synchronized (info) {
        TokenStore tokenStore = 
            (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        if (tokenStore == null) {
            tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        }
        if (tokenStore == null) {
            TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance();
            String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE;
            if (info.getName() != null) {
                cacheKey += "-" + info.getName().toString().hashCode();
            }
            tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message);
            info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore);
        }
        return tokenStore;
    }
}
 
Example 9
Source File: PolicyEngineImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
EndpointPolicy createEndpointPolicyInfo(EndpointInfo ei,
                                            boolean isRequestor,
                                            Assertor assertor,
                                            Message m) {
    EndpointPolicy ep = (EndpointPolicy)ei.getProperty(isRequestor
                                                       ? POLICY_INFO_ENDPOINT_CLIENT : POLICY_INFO_ENDPOINT_SERVER);
    if (ep == null) {
        synchronized (ei) {
            ep = (EndpointPolicy)ei.getProperty(isRequestor
                ? POLICY_INFO_ENDPOINT_CLIENT : POLICY_INFO_ENDPOINT_SERVER);
            if (ep == null) {
                EndpointPolicyImpl epi = new EndpointPolicyImpl(ei, this, isRequestor, assertor);
                epi.initialize(m);
                if (m != null) {
                    ei.setProperty(isRequestor ? POLICY_INFO_ENDPOINT_CLIENT : POLICY_INFO_ENDPOINT_SERVER, epi);
                }
                ep = epi;
            }
        }
    }
    return ep;
}
 
Example 10
Source File: STSTokenValidator.java    From steady with Apache License 2.0 6 votes vote down vote up
static final TokenStore getTokenStore(Message message) {
    EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
    synchronized (info) {
        TokenStore tokenStore = 
            (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        if (tokenStore == null) {
            tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        }
        if (tokenStore == null) {
            TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance();
            String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE;
            if (info.getName() != null) {
                cacheKey += "-" + info.getName().toString().hashCode();
            }
            tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message);
            info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore);
        }
        return tokenStore;
    }
}
 
Example 11
Source File: KerberosTokenInterceptorProvider.java    From steady with Apache License 2.0 6 votes vote down vote up
static final TokenStore getTokenStore(Message message) {
    EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
    synchronized (info) {
        TokenStore tokenStore = 
            (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        if (tokenStore == null) {
            tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        }
        if (tokenStore == null) {
            TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance();
            String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE;
            if (info.getName() != null) {
                cacheKey += "-" + info.getName().toString().hashCode();
            }
            tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message);
            info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore);
        }
        return tokenStore;
    }
}
 
Example 12
Source File: IssuedTokenInterceptorProvider.java    From steady with Apache License 2.0 6 votes vote down vote up
static final TokenStore createTokenStore(Message message) {
    EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
    synchronized (info) {
        TokenStore tokenStore = 
            (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        if (tokenStore == null) {
            tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        }
        if (tokenStore == null) {
            TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance();
            String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE;
            if (info.getName() != null) {
                cacheKey += "-" + info.getName().toString().hashCode();
            }
            tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message);
            info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore);
        }
        return tokenStore;
    }
}
 
Example 13
Source File: MAPAggregatorImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
private EndpointReferenceType getReplyTo(Message message,
                                         EndpointReferenceType originalReplyTo) {
    Exchange exchange = message.getExchange();
    Endpoint info = exchange.getEndpoint();
    if (info == null) {
        return originalReplyTo;
    }
    synchronized (info) {
        EndpointInfo ei = info.getEndpointInfo();
        Destination dest = ei.getProperty(DECOUPLED_DESTINATION, Destination.class);
        if (dest == null) {
            dest = createDecoupledDestination(message);
            if (dest != null) {
                info.getEndpointInfo().setProperty(DECOUPLED_DESTINATION, dest);
            }
        }
        if (dest != null) {
            // if the decoupled endpoint context prop is set and the address is relative, return the absolute url.
            final String replyTo = dest.getAddress().getAddress().getValue();
            if (replyTo.startsWith("/")) {
                String debase =
                    (String)message.getContextualProperty(WSAContextUtils.DECOUPLED_ENDPOINT_BASE_PROPERTY);
                if (debase != null) {
                    return EndpointReferenceUtils.getEndpointReference(debase + replyTo);
                }
            }
            return dest.getAddress();
        }
    }
    return originalReplyTo;
}
 
Example 14
Source File: CacheCleanupListener.java    From steady with Apache License 2.0 5 votes vote down vote up
protected void shutdownResources(EndpointInfo info) {
    TokenStore ts = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
    if (ts instanceof Closeable) {
        close((Closeable)ts);
    }
    ReplayCache rc = (ReplayCache)info.getProperty(SecurityConstants.NONCE_CACHE_INSTANCE);
    if (rc instanceof Closeable) {
        close((Closeable)rc);
    }
    rc = (ReplayCache)info.getProperty(SecurityConstants.TIMESTAMP_CACHE_INSTANCE);
    if (rc instanceof Closeable) {
        close((Closeable)rc);
    }
}
 
Example 15
Source File: WSDLGetUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieve the published endpoint url from the working information set.
 *
 * @param def a wsdl as class objects
 * @param epurl the request URL
 * @param endpointInfo information for a web service 'port' inside of a service
 * @return String
 */
public String getPublishableEndpointUrl(Definition def,
                                        String epurl,
                                        EndpointInfo endpointInfo) {

    if (endpointInfo.getProperty(PUBLISHED_ENDPOINT_URL) != null) {
        epurl = String.valueOf(
            endpointInfo.getProperty(PUBLISHED_ENDPOINT_URL));
        updatePublishedEndpointUrl(epurl, def, endpointInfo.getName());
    }
    return epurl;
}
 
Example 16
Source File: WadlGenerator.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected String getBaseURI(Message m, UriInfo ui) {
    EndpointInfo ei = m.getExchange().getEndpoint().getEndpointInfo();
    String publishedEndpointUrl = (String)ei.getProperty("publishedEndpointUrl");
    if (publishedEndpointUrl == null) {
        return ui.getBaseUri().toString();
    }
    return publishedEndpointUrl;
}
 
Example 17
Source File: AbstractTokenInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected TokenStore getTokenStore(SoapMessage message) {
    EndpointInfo info = message.getExchange().getEndpoint().getEndpointInfo();
    synchronized (info) {
        TokenStore tokenStore =
            (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        if (tokenStore == null) {
            tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        }
        return tokenStore;
    }
}
 
Example 18
Source File: CacheCleanupListener.java    From steady with Apache License 2.0 5 votes vote down vote up
protected void shutdownResources(EndpointInfo info) {
    TokenStore ts = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
    if (ts instanceof Closeable) {
        close((Closeable)ts);
    }
    ReplayCache rc = (ReplayCache)info.getProperty(SecurityConstants.NONCE_CACHE_INSTANCE);
    if (rc instanceof Closeable) {
        close((Closeable)rc);
    }
    rc = (ReplayCache)info.getProperty(SecurityConstants.TIMESTAMP_CACHE_INSTANCE);
    if (rc instanceof Closeable) {
        close((Closeable)rc);
    }
}
 
Example 19
Source File: CacheCleanupListener.java    From steady with Apache License 2.0 5 votes vote down vote up
protected void shutdownResources(EndpointInfo info) {
    TokenStore ts = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
    if (ts instanceof Closeable) {
        close((Closeable)ts);
    }
    ReplayCache rc = (ReplayCache)info.getProperty(SecurityConstants.NONCE_CACHE_INSTANCE);
    if (rc instanceof Closeable) {
        close((Closeable)rc);
    }
    rc = (ReplayCache)info.getProperty(SecurityConstants.TIMESTAMP_CACHE_INSTANCE);
    if (rc instanceof Closeable) {
        close((Closeable)rc);
    }
}
 
Example 20
Source File: WSS4JUtils.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
 * Get a ReplayCache instance. It first checks to see whether caching has been explicitly 
 * enabled or disabled via the booleanKey argument. If it has been set to false then no
 * replay caching is done (for this booleanKey). If it has not been specified, then caching
 * is enabled only if we are not the initiator of the exchange. If it has been specified, then
 * caching is enabled.
 * 
 * It tries to get an instance of ReplayCache via the instanceKey argument from a 
 * contextual property, and failing that the message exchange. If it can't find any, then it
 * defaults to using an EH-Cache instance and stores that on the message exchange.
 */
public static ReplayCache getReplayCache(
    SoapMessage message, String booleanKey, String instanceKey
) {
    boolean specified = false;
    Object o = message.getContextualProperty(booleanKey);
    if (o != null) {
        if (!MessageUtils.isTrue(o)) {
            return null;
        }
        specified = true;
    }

    if (!specified && MessageUtils.isRequestor(message)) {
        return null;
    }
    Endpoint ep = message.getExchange().get(Endpoint.class);
    if (ep != null && ep.getEndpointInfo() != null) {
        EndpointInfo info = ep.getEndpointInfo();
        synchronized (info) {
            ReplayCache replayCache = 
                    (ReplayCache)message.getContextualProperty(instanceKey);
            if (replayCache == null) {
                replayCache = (ReplayCache)info.getProperty(instanceKey);
            }
            if (replayCache == null) {
                ReplayCacheFactory replayCacheFactory = ReplayCacheFactory.newInstance();
                String cacheKey = instanceKey;
                if (info.getName() != null) {
                    cacheKey += "-" + info.getName().toString().hashCode();
                }
                replayCache = replayCacheFactory.newReplayCache(cacheKey, message);
                info.setProperty(instanceKey, replayCache);
            }
            return replayCache;
        }
    }
    return null;
}