use of javax.annotation.security.PermitAll in project traccar by tananaev.
the class PasswordResource method reset.
@Path("reset")
@PermitAll
@POST
public Response reset(@FormParam("email") String email) throws StorageException, MessagingException {
for (long userId : Context.getUsersManager().getAllItems()) {
User user = Context.getUsersManager().getById(userId);
if (email.equals(user.getEmail())) {
String token = UUID.randomUUID().toString().replaceAll("-", "");
user.set(PASSWORD_RESET_TOKEN, token);
Context.getUsersManager().updateItem(user);
VelocityContext velocityContext = TextTemplateFormatter.prepareContext(null);
velocityContext.put("token", token);
NotificationMessage fullMessage = TextTemplateFormatter.formatMessage(velocityContext, "passwordReset", "full");
Context.getMailManager().sendMessage(userId, fullMessage.getSubject(), fullMessage.getBody());
break;
}
}
return Response.ok().build();
}
use of javax.annotation.security.PermitAll in project irontest by zheng-wang.
the class HTTPStubResource method loadAll.
@POST
@Path("testcases/{testcaseId}/httpstubs/loadAll")
@PermitAll
public void loadAll(@PathParam("testcaseId") long testcaseId) throws IOException {
// gather referenceable string properties
List<UserDefinedProperty> testcaseUDPs = udpDAO.findByTestcaseId(testcaseId);
Map<String, String> referenceableStringProperties = IronTestUtils.udpListToMap(testcaseUDPs);
DataTable dataTable = dataTableDAO.getTestcaseDataTable(testcaseId, true);
if (dataTable.getRows().size() > 0) {
IronTestUtils.checkDuplicatePropertyNameBetweenDataTableAndUPDs(referenceableStringProperties.keySet(), dataTable);
referenceableStringProperties.putAll(dataTable.getStringPropertiesInRow(0));
}
List<HTTPStubMapping> stubs = httpStubMappingDAO.findByTestcaseId(testcaseId);
// resolve string property references in HTTPStubMapping objects
List<String> undefinedStringProperties = new ArrayList<>();
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
IronTestUtils.addMixInsForWireMock(objectMapper);
String httpStubMappingsJSON = objectMapper.writeValueAsString(stubs);
MapValueLookup propertyReferenceResolver = new MapValueLookup(referenceableStringProperties, true);
String resolvedHttpStubMappingsJSON = new StrSubstitutor(propertyReferenceResolver).replace(httpStubMappingsJSON);
stubs = objectMapper.readValue(resolvedHttpStubMappingsJSON, new TypeReference<List<HTTPStubMapping>>() {
});
undefinedStringProperties.addAll(propertyReferenceResolver.getUnfoundKeys());
if (!undefinedStringProperties.isEmpty()) {
throw new RuntimeException("String properties " + undefinedStringProperties + " not defined.");
}
IronTestUtils.substituteRequestBodyMainPatternValue(stubs);
// load stubs
final List<HTTPStubMapping> finalStubs = stubs;
wireMockServer.loadMappingsUsing(stubMappings -> {
for (HTTPStubMapping stub : finalStubs) {
// delete old instances if exist
List<StubMapping> existingInstances = wireMockServer.findStubMappingsByMetadata(matchingJsonPath("$." + WIREMOCK_STUB_METADATA_ATTR_NAME_IRON_TEST_ID, equalTo(Long.toString(stub.getId()))));
for (StubMapping existingInstance : existingInstances) {
wireMockServer.removeStubMapping(existingInstance);
}
StubMapping stubInstance = IronTestUtils.createStubInstance(stub.getId(), stub.getNumber(), stub.getSpec());
stubMappings.addMapping(stubInstance);
}
});
}
use of javax.annotation.security.PermitAll in project irontest by zheng-wang.
the class TestcaseResource method duplicate.
/**
* Clone/copy test case in the same system database.
* @param testcaseId
* @param targetFolderId
* @return the new test case (containing ID only)
*/
@POST
@Path("testcases/{testcaseId}/duplicate")
@PermitAll
public Testcase duplicate(@PathParam("testcaseId") long testcaseId, @QueryParam("targetFolderId") long targetFolderId) {
Testcase testcase = new Testcase();
testcase.setId(testcaseDAO.duplicate(testcaseId, targetFolderId));
return testcase;
}
use of javax.annotation.security.PermitAll in project irontest by zheng-wang.
the class UserResource method updatePassword.
@PUT
@Path("{userId}/password")
@PermitAll
public void updatePassword(@PathParam("userId") long userId, @QueryParam("newPassword") String newPassword, @Context SecurityContext context) {
SimplePrincipal principal = (SimplePrincipal) context.getUserPrincipal();
User user = userDAO.findByUsername(principal.getName());
if (user.getId() == userId) {
userDAO.updatePassword(userId, newPassword);
} else {
throw new RuntimeException("You can't change other user's password.");
}
}
use of javax.annotation.security.PermitAll in project irontest by zheng-wang.
the class ManagedEndpointResource method create.
@POST
@Path("environments/{environmentId}/endpoints")
@PermitAll
public Endpoint create(@PathParam("environmentId") long environmentId, Endpoint endpoint) {
Environment env = new Environment();
env.setId(environmentId);
endpoint.setEnvironment(env);
if (Endpoint.TYPE_SOAP.equals(endpoint.getType())) {
endpoint.setOtherProperties(new SOAPEndpointProperties());
} else if (Endpoint.TYPE_FTP.equals(endpoint.getType())) {
endpoint.setOtherProperties(new FTPEndpointProperties());
} else if (Endpoint.TYPE_MQ.equals(endpoint.getType())) {
MQEndpointProperties otherProperties = new MQEndpointProperties();
otherProperties.setConnectionMode(appInfo.getAppMode() == AppMode.LOCAL ? MQConnectionMode.BINDINGS : MQConnectionMode.CLIENT);
endpoint.setOtherProperties(otherProperties);
} else if (Endpoint.TYPE_IIB.equals(endpoint.getType())) {
endpoint.setOtherProperties(new IIBEndpointProperties());
}
long id = endpointDAO.insertManagedEndpoint(endpoint);
endpoint.setId(id);
return endpoint;
}
Aggregations