cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf-fediz git commit: Initial prototyping a home/account service
Date Fri, 18 Mar 2016 17:39:32 GMT
Repository: cxf-fediz
Updated Branches:
  refs/heads/master cb89526b5 -> 44b61cfae


Initial prototyping a home/account service


Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/44b61cfa
Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/44b61cfa
Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/44b61cfa

Branch: refs/heads/master
Commit: 44b61cfaedbc3e6829d7b3d7aaa586b60b28f2f5
Parents: cb89526
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Fri Mar 18 17:39:16 2016 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Fri Mar 18 17:39:16 2016 +0000

----------------------------------------------------------------------
 .../fediz/service/oidc/account/UserAccount.java | 33 ++++++++++
 .../oidc/account/UserAccountService.java        | 44 +++++++++++++
 .../main/webapp/WEB-INF/applicationContext.xml  | 10 +++
 .../main/webapp/WEB-INF/views/userAccount.jsp   | 67 ++++++++++++++++++++
 services/oidc/src/main/webapp/WEB-INF/web.xml   | 13 ++++
 5 files changed, 167 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/44b61cfa/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/account/UserAccount.java
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/account/UserAccount.java
b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/account/UserAccount.java
new file mode 100644
index 0000000..e5a9ee6
--- /dev/null
+++ b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/account/UserAccount.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.cxf.fediz.service.oidc.account;
+
+public class UserAccount {
+    private String userName;
+    public UserAccount(String userName) {
+        this.userName = userName;
+    }
+    public String getUserName() {
+        return userName;
+    }
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/44b61cfa/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/account/UserAccountService.java
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/account/UserAccountService.java
b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/account/UserAccountService.java
new file mode 100644
index 0000000..d56c2d8
--- /dev/null
+++ b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/account/UserAccountService.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.cxf.fediz.service.oidc.account;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.SecurityContext;
+
+@Path("/")
+public class UserAccountService {
+
+    @Context
+    private SecurityContext sc;
+
+    @GET
+    @Produces(MediaType.TEXT_HTML)
+    public UserAccount getAccount() {
+        return new UserAccount(getUserName()); 
+    }
+    private String getUserName() {
+        return sc.getUserPrincipal().getName();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/44b61cfa/services/oidc/src/main/webapp/WEB-INF/applicationContext.xml
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/webapp/WEB-INF/applicationContext.xml b/services/oidc/src/main/webapp/WEB-INF/applicationContext.xml
index 8a51037..8f774cf 100644
--- a/services/oidc/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/services/oidc/src/main/webapp/WEB-INF/applicationContext.xml
@@ -143,6 +143,16 @@
         </jaxrs:providers> 
     </jaxrs:server>
     
+    <bean id="accountService" class="org.apache.cxf.fediz.service.oidc.account.UserAccountService"/>
+    <jaxrs:server address="/home">
+        <jaxrs:serviceBeans>
+            <ref bean="accountService"/>
+        </jaxrs:serviceBeans>
+        <jaxrs:providers>
+            <ref bean="viewProvider"/>
+        </jaxrs:providers> 
+    </jaxrs:server>
+    
     <bean id="viewProvider" class="org.apache.cxf.jaxrs.provider.RequestDispatcherProvider">
        <property name="useClassNames" value="true"/>
        <property name="locationPrefix" value="/WEB-INF/views/"/>

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/44b61cfa/services/oidc/src/main/webapp/WEB-INF/views/userAccount.jsp
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/webapp/WEB-INF/views/userAccount.jsp b/services/oidc/src/main/webapp/WEB-INF/views/userAccount.jsp
new file mode 100644
index 0000000..e48f517
--- /dev/null
+++ b/services/oidc/src/main/webapp/WEB-INF/views/userAccount.jsp
@@ -0,0 +1,67 @@
+<%@ page
+	import="javax.servlet.http.HttpServletRequest,java.util.Map,java.util.Iterator,org.apache.cxf.fediz.service.oidc.account.UserAccount"%>
+<%
+    UserAccount account = (UserAccount)request.getAttribute("data");
+    String basePath = request.getContextPath() + request.getServletPath();
+    if (!basePath.endsWith("/")) {
+        basePath += "/";
+    }
+%>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>User Account</title>
+<style TYPE="text/css">
+<!--
+h2 {
+	font-size: 1.5em;
+	font-family: verdana, arial, helvetica, sans-serif;
+	margin: 0;
+	text-align: center;
+}
+
+.header-text {
+	border-bottom: 1px solid gray;
+	padding: 24px 0;
+	margin: 12px 36px 12px;
+}
+
+label {
+	font-weight: bold;
+	margin-bottom: 9px;
+	display: block;
+	white-space: normal;
+}
+
+.form {
+	max-width: 425px;
+	margin-bottom: 25px;
+	margin-left: auto;
+	margin-right: auto;
+}
+
+.form-line {
+	margin: 6 0 6 0;
+	padding: 12 36 12 36;
+}
+
+.form-required {
+	color: red;
+	margin-left: 5px;
+}
+
+input, select, button {
+	width: 100%;
+}
+
+.form-submit-button {
+	padding: 4px;
+	text-align: center;
+}
+-->
+</style>
+</head>
+<body>
+    <h2>Welcome to Fediz OpenId Connect Console</h2>
+	<p><a href="<%=basePath%>clients">Client Registrations</a></p>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/44b61cfa/services/oidc/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/webapp/WEB-INF/web.xml b/services/oidc/src/main/webapp/WEB-INF/web.xml
index e76a95d..738c8bb 100644
--- a/services/oidc/src/main/webapp/WEB-INF/web.xml
+++ b/services/oidc/src/main/webapp/WEB-INF/web.xml
@@ -42,6 +42,10 @@
         <filter-name>FederationFilter</filter-name>
         <url-pattern>/clients/*</url-pattern>
     </filter-mapping>
+    <filter-mapping>
+        <filter-name>FederationFilter</filter-name>
+        <url-pattern>/home/*</url-pattern>
+    </filter-mapping>
 
     <context-param>
         <param-name>contextConfigLocation</param-name>
@@ -91,6 +95,15 @@
             <role-name>*</role-name>
         </auth-constraint>
     </security-constraint>
+    <security-constraint>
+        <web-resource-collection>
+            <web-resource-name>OIDC Account Protected Area</web-resource-name>
+            <url-pattern>/home/*</url-pattern>
+        </web-resource-collection>
+        <auth-constraint>
+            <role-name>*</role-name>
+        </auth-constraint>
+    </security-constraint>
     <login-config>
         <auth-method>WSFED</auth-method>
         <realm-name>WSFED</realm-name>


Mime
View raw message