@Override public CAValue get( String uri ) { String jsonCa = restClient.getJSON( uri ); return vbf.newValueFromJSON( CAValue.class, jsonCa ); }
@Override public CryptoStoreValue get( String uri ) { String jsonCryptoStore = restClient.getJSON( uri ); return vbf.newValueFromJSON( CryptoStoreValue.class, jsonCryptoStore ); }
@Override public CaApiURIsValue fetchApiURIs() { String jsonApi = getJSON( API_URI ); return valueBuilderFactory.newValueFromJSON( CaApiURIsValue.class, jsonApi ); }
@Override public CaApiURIsValue fetchApiURIs() { String jsonApi = getJSON( API_URI ); return valueBuilderFactory.newValueFromJSON( CaApiURIsValue.class, jsonApi ); }
@Override public Iterable<CryptoStoreValue> list( int start ) { String jsonCryptoStoreList = restClient.getJSON( restClient.fetchApiURIs().cryptoStoreListUri().get() ); RestListValue restList = vbf.newValueFromJSON( RestListValue.class, jsonCryptoStoreList ); return new RestListValueIterable<CryptoStoreValue>( restList ); }
@Override public Iterable<CryptoStoreValue> list( int start ) { String jsonCryptoStoreList = restClientService.getJSON( restClientService.fetchApiURIs().cryptoStoreListUri().get() ); RestListValue restList = valueBuilderFactory.newValueFromJSON( RestListValue.class, jsonCryptoStoreList ); return new RestListValueIterable<CryptoStoreValue>( restList ); }
@Override public Iterable<CAValue> list( int start ) { String jsonCaList = restClient.getJSON( restClient.fetchApiURIs().caListUri().get() ); RestListValue restList = vbf.newValueFromJSON( RestListValue.class, jsonCaList ); return new RestListValueIterable<CAValue>( restList ); }
@Override public CAValue create( CAFactoryParamsValue params ) { String jsonCa = restClient.postJSON( restClient.fetchApiURIs().caListUri().get(), params.toJSON() ); return vbf.newValueFromJSON( CAValue.class, jsonCa ); }
@Override public Iterable<CryptoStoreValue> list( int start ) { String jsonCryptoStoreList = restClientService.getJSON( restClientService.fetchApiURIs().cryptoStoreListUri().get() ); RestListValue restList = valueBuilderFactory.newValueFromJSON( RestListValue.class, jsonCryptoStoreList ); return new RestListValueIterable<CryptoStoreValue>( restList ); }
@Override public CryptoStoreValue create( CryptoStoreFactoryParamsValue params ) { String jsonCryptoStore = restClient.postJSON( restClient.fetchApiURIs().cryptoStoreListUri().get(), params.toJSON() ); return vbf.newValueFromJSON( CryptoStoreValue.class, jsonCryptoStore ); }
@Override public CaApiURIsValue fetchApiURIs() { String apiUri = "http://localhost:8443/api"; if ( configuration != null && !Strings.isEmpty( configuration.apiUri().get() ) ) { apiUri = configuration.apiUri().get(); } String jsonApi = getJSON( apiUri ); return valueBuilderFactory.newValueFromJSON( CaApiURIsValue.class, jsonApi ); }
@Override protected Representation post( Representation entity ) throws ResourceException { try { // Data String x509Identity = ensureRequestAttribute( PARAM_IDENTITY, String.class, Status.CLIENT_ERROR_BAD_REQUEST ); X509RevocationParamsValue params = module.valueBuilderFactory().newValueFromJSON( X509RevocationParamsValue.class, entity.getText() ); // Context RootContext rootCtx = newRootContext(); X509Context x509Ctx = rootCtx.x509Context( x509Identity ); // Interaction Revocation revocation = x509Ctx.revoke( params.reason().get() ); // Representation return new StringRepresentation( valuesFactory.revocation( revocation ).toJSON(), MediaType.APPLICATION_JSON ); } catch ( IOException ex ) { LOGGER.warn( "500: {}", ex.getMessage(), ex ); throw new ResourceException( Status.SERVER_ERROR_INTERNAL, "Unable to read posted value", ex ); } }
@Override protected Representation post( Representation entity ) throws ResourceException { try { // Data EscrowedKeyPairFactoryParamsValue params = module.valueBuilderFactory().newValueFromJSON( EscrowedKeyPairFactoryParamsValue.class, entity.getText() ); // Context EscrowedKeyPairListContext escrowListContext = newRootContext().escrowedKeyPairListContext(); // Interaction EscrowedKeyPair kp = escrowListContext.createEscrowedKeyPair( params.algorithm().get(), params.length().get() ); // Redirect to created resource EscrowedKeyPairValue kpValue = restValuesFactory.escrowedKeyPair( kp ); return redirectToCreatedResource( kpValue.uri().get() ); } catch ( IOException ex ) { LOGGER.trace( "500: {}", ex.getMessage(), ex ); throw new ResourceException( Status.SERVER_ERROR_INTERNAL, "Unable to read posted Value", ex ); } }
@Override protected Representation post( Representation entity, Variant variant ) throws ResourceException { try { // Data String identity = ensureRequestAttribute( PARAM_IDENTITY, String.class, Status.CLIENT_ERROR_BAD_REQUEST ); CAValue caValue = module.valueBuilderFactory().newValueFromJSON( CAValue.class, entity.getText() ); Map<String, KeyEscrowPolicy> profileAssignments = new HashMap<String, KeyEscrowPolicy>(); for ( X509ProfileAssignmentValue eachAssignment : caValue.allowedX509Profiles().get() ) { profileAssignments.put( new CaUriResolver( getRootRef(), eachAssignment.x509ProfileUri().get() ).identity(), eachAssignment.keyEscrowPolicy().get() ); } // Context CAContext caCtx = newRootContext().caContext( identity ); // Interaction CA ca = caCtx.updateCA( profileAssignments ); // Redirect to updated resource caValue = restValuesFactory.ca( ca ); return redirectToUpdatedResource( caValue.uri().get() ); } catch ( IOException ex ) { LOGGER.warn( "500: {}", ex.getMessage(), ex ); throw new ResourceException( Status.SERVER_ERROR_INTERNAL, "Unable to read posted value", ex ); } }
@Override protected Representation post( Representation entity ) throws ResourceException { try { // Data CryptoStoreFactoryParamsValue params = module.valueBuilderFactory().newValueFromJSON( CryptoStoreFactoryParamsValue.class, entity.getText() ); // Context CryptoStoreListContext csListCtx = newRootContext().cryptoStoreListContext(); // Interaction CryptoStore cs = csListCtx.createCryptoStore( params.name().get(), params.storeType().get(), params.password().get() ); // Redirect to created resource CryptoStoreValue csValue = restValuesFactory.cryptoStore( cs ); return redirectToCreatedResource( csValue.uri().get() ); } catch ( IOException ex ) { LOGGER.trace( "500: {}", ex.getMessage(), ex ); throw new ResourceException( Status.SERVER_ERROR_INTERNAL, "Unable to read posted Value", ex ); } }
@Override protected Representation post( Representation entity ) throws ResourceException { try { // Data X509ProfileFactoryParamsValue params = module.valueBuilderFactory().newValueFromJSON( X509ProfileFactoryParamsValue.class, entity.getText() ); // Context X509ProfileListContext x509ProfileListCtx = newRootContext().x509ProfileListContext(); // Interaction X509Profile x509Profile = x509ProfileListCtx.createX509Profile( params.name().get(), params.validityDays().get(), params.netscapeCertComment().get(), params.keyUsages().get(), params.extendedKeyUsages().get(), params.netscapeCertTypes().get(), params.basicConstraints().get(), params.nameConstraints().get() ); // Redirect to created resource X509ProfileValue x509ProfileValue = restValuesFactory.x509Profile( x509Profile ); return redirectToCreatedResource( x509ProfileValue.uri().get() ); } catch ( IOException ex ) { LOGGER.warn( "500: {}", ex.getMessage(), ex ); throw new ResourceException( Status.SERVER_ERROR_INTERNAL, "Unable to read posted value", ex ); } }
CAFactoryParamsValue params = module.valueBuilderFactory().newValueFromJSON( CAFactoryParamsValue.class, entity.getText() );
@Override protected Representation post( Representation entity ) throws ResourceException { try { // Data X509FactoryParamsValue params = module.valueBuilderFactory().newValueFromJSON( X509FactoryParamsValue.class, entity.getText() ); Boolean escrowed = params.escrowedKeyPairUri().get() != null; // Context X509ListContext caListCtx = newRootContext().x509ListContext(); // Interaction X509 x509; if ( escrowed ) { x509 = caListCtx.createX509( new CaUriResolver( getRootRef(), params.caUri().get() ).identity(), new CaUriResolver( getRootRef(), params.x509ProfileUri().get() ).identity(), new CaUriResolver( getRootRef(), params.escrowedKeyPairUri().get() ).identity(), params.distinguishedName().get() ); } else { x509 = caListCtx.createX509( new CaUriResolver( getRootRef(), params.caUri().get() ).identity(), new CaUriResolver( getRootRef(), params.x509ProfileUri().get() ).identity(), params.pemPkcs10().get() ); } // Redirect to created resource X509Value x509Value = restValuesFactory.x509( x509 ); return redirectToCreatedResource( x509Value.uri().get() ); } catch ( IOException ex ) { LOGGER.warn( "500: {}", ex.getMessage(), ex ); throw new ResourceException( Status.SERVER_ERROR_INTERNAL, "Unable to read posted value", ex ); } }