Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.github.joschi.jersey.security.smime;
 
 

Author(s):
Bill Burke
Version:
$Revision: 1 $
@Consumes("*/*")
public class SignedReader implements MessageBodyReader<SignedInput> {
    static {
        BouncyIntegration.init();
    }
    @Context
    private Providers providers;
    public boolean isReadable(Class<?> typeType genericTypeAnnotation[] annotationsMediaType mediaType) {
        return SignedInput.class.isAssignableFrom(type);
    }
    public SignedInput readFrom(Class<SignedInputtypeType genericTypeAnnotation[] annotationsMediaType mediaTypeMultivaluedMap<StringStringheadersInputStream entityStreamthrows IOExceptionWebApplicationException {
        Class<?> baseType = null;
        Type baseGenericType = null;
        if (genericType instanceof ParameterizedType) {
            ParameterizedType param = (ParameterizedTypegenericType;
            baseGenericType = param.getActualTypeArguments()[0];
            baseType = Types.getRawType(baseGenericType);
        }
        try {
            ByteArrayDataSource ds = new ByteArrayDataSource(entityStreammediaType.toString());
            MimeMultipart mm = new MimeMultipart(ds);
            SignedInputImpl input = new SignedInputImpl();
            input.setType(baseType);
            input.setGenericType(baseGenericType);
            input.setAnnotations(annotations);
            input.setBody(mm);
            input.setProviders();
            return input;
        } catch (MessagingException e) {
            throw new RuntimeException(e);
        }
    }
New to GrepCode? Check out our FAQ X