All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.getlime.security.powerauth.lib.cmd.steps.v3.RemoveStep Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2018 Wultra s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.getlime.security.powerauth.lib.cmd.steps.v3;

import io.getlime.security.powerauth.lib.cmd.consts.BackwardCompatibilityConst;
import io.getlime.security.powerauth.lib.cmd.consts.PowerAuthConst;
import io.getlime.security.powerauth.lib.cmd.consts.PowerAuthStep;
import io.getlime.security.powerauth.lib.cmd.consts.PowerAuthVersion;
import io.getlime.security.powerauth.lib.cmd.logging.StepLogger;
import io.getlime.security.powerauth.lib.cmd.logging.StepLoggerFactory;
import io.getlime.security.powerauth.lib.cmd.header.PowerAuthHeaderFactory;
import io.getlime.security.powerauth.lib.cmd.status.ResultStatusService;
import io.getlime.security.powerauth.lib.cmd.steps.AbstractBaseStep;
import io.getlime.security.powerauth.lib.cmd.steps.context.RequestContext;
import io.getlime.security.powerauth.lib.cmd.steps.context.StepContext;
import io.getlime.security.powerauth.lib.cmd.steps.model.RemoveStepModel;
import io.getlime.security.powerauth.rest.api.model.response.EciesEncryptedResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * Helper class with activation remove logic.
 *
 * 

PowerAuth protocol versions: *

    *
  • 3.0
  • *
  • 3.1
  • *
  • 3.2
  • *
  • 3.3
  • *
* * @author Lukas Lukovsky, [email protected] * @author Roman Strobl, [email protected] */ @Component(value = "removeStepV3") public class RemoveStep extends AbstractBaseStep { private final PowerAuthHeaderFactory powerAuthHeaderFactory; /** * Constructor * @param powerAuthHeaderFactory PowerAuth header factory * @param resultStatusService Result status service * @param stepLoggerFactory Step logger factory */ @Autowired public RemoveStep(PowerAuthHeaderFactory powerAuthHeaderFactory, ResultStatusService resultStatusService, StepLoggerFactory stepLoggerFactory) { super(PowerAuthStep.ACTIVATION_REMOVE, PowerAuthVersion.VERSION_3, resultStatusService, stepLoggerFactory); this.powerAuthHeaderFactory = powerAuthHeaderFactory; } /** * Constructor for backward compatibility */ public RemoveStep() { this( BackwardCompatibilityConst.POWER_AUTH_HEADER_FACTORY, BackwardCompatibilityConst.RESULT_STATUS_SERVICE, BackwardCompatibilityConst.STEP_LOGGER_FACTORY ); } @Override protected ParameterizedTypeReference getResponseTypeReference() { return PowerAuthConst.RESPONSE_TYPE_REFERENCE_V3; } @Override public StepContext prepareStepContext(StepLogger stepLogger, Map context) throws Exception { RemoveStepModel model = new RemoveStepModel(); model.fromMap(context); RequestContext requestContext = RequestContext.builder() .signatureHttpMethod("POST") .signatureRequestUri("/pa/activation/remove") .uri(model.getUriString() + "/pa/v3/activation/remove") .build(); StepContext stepContext = buildStepContext(stepLogger, model, requestContext); powerAuthHeaderFactory.getHeaderProvider(model).addHeader(stepContext); incrementCounter(model); return stepContext; } @Override public void processResponse(StepContext stepContext) { String activationId = stepContext.getModel().getResultStatus().getActivationId(); Map objectMap = new HashMap<>(); objectMap.put("activationId", activationId); stepContext.getStepLogger().writeItem( getStep().id() + "-removal-done", "Activation Removed", "Activation was successfully removed from the server", "OK", objectMap ); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy