Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:Evolveum/midpoint
- Loading branch information
Showing
36 changed files
with
3,821 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2010-2014 Evolveum | ||
~ | ||
~ 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. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<name>midPoint Customizations</name> | ||
<artifactId>custom</artifactId> | ||
<packaging>pom</packaging> | ||
<parent> | ||
<artifactId>parent</artifactId> | ||
<groupId>com.evolveum.midpoint</groupId> | ||
<version>3.1-SNAPSHOT</version> | ||
<relativePath>../build-system/pom.xml</relativePath> | ||
</parent> | ||
<organization> | ||
<name>Evolveum</name> | ||
<url>http://www.evolveum.com</url> | ||
</organization> | ||
<licenses> | ||
<license> | ||
<name>Apache License v2.0</name> | ||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
</licenses> | ||
<issueManagement> | ||
<system>Atlassian JIRA</system> | ||
<url>http://jira.evolveum.com/</url> | ||
</issueManagement> | ||
<scm> | ||
<connection>https://github.com/Evolveum/midpoint.git</connection> | ||
<developerConnection>git@github.com:Evolveum/midpoint.git</developerConnection> | ||
<url>https://fisheye.evolveum.com/browse/midPoint</url> | ||
</scm> | ||
<modules> | ||
<!-- add submodule here: | ||
<module>custom-foo</module> | ||
--> | ||
</modules> | ||
</project> |
30 changes: 30 additions & 0 deletions
30
infra/schema/src/main/java/com/evolveum/midpoint/schema/util/OidUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright (c) 2014 Evolveum | ||
* | ||
* 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 com.evolveum.midpoint.schema.util; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* @author semancik | ||
* | ||
*/ | ||
public class OidUtil { | ||
|
||
public static String generateOid() { | ||
return UUID.randomUUID().toString(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
...common/src/main/java/com/evolveum/midpoint/model/common/util/AbstractModelWebService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/** | ||
* Copyright (c) 2014 Evolveum | ||
* | ||
* 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 com.evolveum.midpoint.model.common.util; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
|
||
import com.evolveum.midpoint.audit.api.AuditEventRecord; | ||
import com.evolveum.midpoint.audit.api.AuditEventStage; | ||
import com.evolveum.midpoint.audit.api.AuditEventType; | ||
import com.evolveum.midpoint.audit.api.AuditService; | ||
import com.evolveum.midpoint.model.api.ModelService; | ||
import com.evolveum.midpoint.prism.PrismContext; | ||
import com.evolveum.midpoint.prism.PrismObject; | ||
import com.evolveum.midpoint.schema.constants.SchemaConstants; | ||
import com.evolveum.midpoint.schema.result.OperationResultStatus; | ||
import com.evolveum.midpoint.security.api.MidPointPrincipal; | ||
import com.evolveum.midpoint.task.api.Task; | ||
import com.evolveum.midpoint.task.api.TaskManager; | ||
import com.evolveum.midpoint.util.exception.SystemException; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; | ||
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; | ||
|
||
/** | ||
* Abstract superclass that provides methods common to all web service implementations that | ||
* use ModelService. | ||
* | ||
* @author Radovan Semancik | ||
* | ||
*/ | ||
public abstract class AbstractModelWebService { | ||
|
||
@Autowired(required = true) | ||
protected ModelService modelService; | ||
|
||
@Autowired(required = true) | ||
protected TaskManager taskManager; | ||
|
||
@Autowired(required = true) | ||
protected AuditService auditService; | ||
|
||
@Autowired(required = true) | ||
protected PrismContext prismContext; | ||
|
||
protected void setTaskOwner(Task task) { | ||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | ||
if (authentication == null) { | ||
throw new SystemException("Failed to get authentication object"); | ||
} | ||
UserType userType = (UserType) ((MidPointPrincipal)(SecurityContextHolder.getContext().getAuthentication().getPrincipal())).getUser(); | ||
if (userType == null) { | ||
throw new SystemException("Failed to get user from authentication object"); | ||
} | ||
task.setOwner(userType.asPrismObject()); | ||
} | ||
|
||
protected Task createTaskInstance(String operationName) { | ||
// TODO: better task initialization | ||
Task task = taskManager.createTaskInstance(operationName); | ||
setTaskOwner(task); | ||
task.setChannel(SchemaConstants.CHANNEL_WEB_SERVICE_URI); | ||
return task; | ||
} | ||
|
||
protected void auditLogin(Task task) { | ||
AuditEventRecord record = new AuditEventRecord(AuditEventType.CREATE_SESSION, AuditEventStage.REQUEST); | ||
PrismObject<UserType> owner = task.getOwner(); | ||
if (owner != null) { | ||
record.setInitiator(owner); | ||
PolyStringType name = owner.asObjectable().getName(); | ||
if (name != null) { | ||
record.setParameter(name.getOrig()); | ||
} | ||
} | ||
|
||
record.setChannel(SchemaConstants.CHANNEL_WEB_SERVICE_URI); | ||
record.setTimestamp(System.currentTimeMillis()); | ||
record.setSessionIdentifier(task.getTaskIdentifier()); | ||
|
||
record.setOutcome(OperationResultStatus.SUCCESS); | ||
|
||
auditService.audit(record, task); | ||
} | ||
|
||
protected void auditLogout(Task task) { | ||
AuditEventRecord record = new AuditEventRecord(AuditEventType.TERMINATE_SESSION, AuditEventStage.REQUEST); | ||
PrismObject<UserType> owner = task.getOwner(); | ||
if (owner != null) { | ||
record.setInitiator(owner); | ||
PolyStringType name = owner.asObjectable().getName(); | ||
if (name != null) { | ||
record.setParameter(name.getOrig()); | ||
} | ||
} | ||
|
||
record.setChannel(SchemaConstants.CHANNEL_WEB_SERVICE_URI); | ||
record.setTimestamp(System.currentTimeMillis()); | ||
record.setSessionIdentifier(task.getTaskIdentifier()); | ||
|
||
record.setOutcome(OperationResultStatus.SUCCESS); | ||
|
||
auditService.audit(record, task); | ||
} | ||
|
||
} |
Oops, something went wrong.