You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2016/06/06 14:51:32 UTC
[04/13] isis git commit: ISIS-1429: removing
AuthenticationSessionUtils,
moving responsibility directly onto AuthenticationSession. Also removing
unused utility classes (Base64Serializer, HexUtils).
ISIS-1429: removing AuthenticationSessionUtils, moving responsibility directly onto AuthenticationSession. Also removing unused utility classes (Base64Serializer, HexUtils).
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/4e07d41e
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/4e07d41e
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/4e07d41e
Branch: refs/heads/master
Commit: 4e07d41ee2aa10cf68d2255d7098784c9f8363c0
Parents: b8dcd68
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sat Jun 4 20:08:26 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Jun 6 15:44:47 2016 +0100
----------------------------------------------------------------------
.../authentication/AnonymousSession.java | 3 +
.../authentication/AuthenticationSession.java | 3 +-
.../AuthenticationSessionAbstract.java | 16 ++++
.../AuthenticationSessionUtils.java | 41 ----------
.../core/commons/base64/Base64Serializer.java | 81 --------------------
.../isis/core/commons/encoding/HexUtils.java | 63 ---------------
.../DisableForSessionFacetViaMethod.java | 3 +-
.../HideForSessionFacetViaMethod.java | 3 +-
8 files changed, 23 insertions(+), 190 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/4e07d41e/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AnonymousSession.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AnonymousSession.java b/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AnonymousSession.java
index 89eb9a8..f26ec9c 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AnonymousSession.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AnonymousSession.java
@@ -31,7 +31,10 @@ import org.apache.isis.core.commons.encoding.DataInputExtended;
* <p>
* For example, a webapp want to have a registration/sign-up page, or a 'lost
* password' page.
+ *
+ * @deprecated - unused by framework and not part of applib
*/
+@Deprecated
public class AnonymousSession extends AuthenticationSessionAbstract {
private static final long serialVersionUID = 1L;
http://git-wip-us.apache.org/repos/asf/isis/blob/4e07d41e/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AuthenticationSession.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AuthenticationSession.java b/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AuthenticationSession.java
index e75e86b..03127f7 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AuthenticationSession.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AuthenticationSession.java
@@ -22,6 +22,7 @@ package org.apache.isis.core.commons.authentication;
import java.io.Serializable;
import java.util.List;
+import org.apache.isis.applib.security.UserMemento;
import org.apache.isis.core.commons.encoding.Encodable;
/**
@@ -68,5 +69,5 @@ public interface AuthenticationSession extends Encodable, Serializable {
*/
MessageBroker getMessageBroker();
-
+ UserMemento createUserMemento();
}
http://git-wip-us.apache.org/repos/asf/isis/blob/4e07d41e/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AuthenticationSessionAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AuthenticationSessionAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AuthenticationSessionAbstract.java
index 2df0e9c..ef79758 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AuthenticationSessionAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AuthenticationSessionAbstract.java
@@ -29,7 +29,10 @@ import java.util.List;
import java.util.Map;
import com.google.common.base.Objects;
+import com.google.common.collect.Lists;
+import org.apache.isis.applib.security.RoleMemento;
+import org.apache.isis.applib.security.UserMemento;
import org.apache.isis.core.commons.encoding.DataInputExtended;
import org.apache.isis.core.commons.encoding.DataOutputExtended;
import org.apache.isis.core.commons.util.ToString;
@@ -141,6 +144,19 @@ public abstract class AuthenticationSessionAbstract implements AuthenticationSes
//endregion
+ //region > createUserMemento
+
+ @Override
+ public UserMemento createUserMemento() {
+ final List<RoleMemento> roles = Lists.newArrayList();
+ for (final String roleName : getRoles()) {
+ roles.add(new RoleMemento(roleName));
+ }
+ return new UserMemento(getUserName(), roles);
+ }
+
+ //endregion
+
//region > toString
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/4e07d41e/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AuthenticationSessionUtils.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AuthenticationSessionUtils.java b/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AuthenticationSessionUtils.java
deleted file mode 100644
index 701afb9..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/commons/authentication/AuthenticationSessionUtils.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.isis.core.commons.authentication;
-
-import java.util.List;
-
-import com.google.common.collect.Lists;
-
-import org.apache.isis.applib.security.RoleMemento;
-import org.apache.isis.applib.security.UserMemento;
-
-public final class AuthenticationSessionUtils {
-
- private AuthenticationSessionUtils() {
- }
-
- public static UserMemento createUserMemento(final AuthenticationSession session) {
- final List<RoleMemento> roles = Lists.newArrayList();
- for (final String roleName : session.getRoles()) {
- roles.add(new RoleMemento(roleName));
- }
- return new UserMemento(session.getUserName(), roles);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/4e07d41e/core/metamodel/src/main/java/org/apache/isis/core/commons/base64/Base64Serializer.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/commons/base64/Base64Serializer.java b/core/metamodel/src/main/java/org/apache/isis/core/commons/base64/Base64Serializer.java
deleted file mode 100644
index 6513aa4..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/commons/base64/Base64Serializer.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.isis.core.commons.base64;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-
-import org.apache.commons.codec.binary.Base64;
-
-public class Base64Serializer {
-
- public static class Exception extends RuntimeException {
-
- private static final long serialVersionUID = 1L;
-
- public Exception(java.lang.Exception e) {
- super(e);
- }
- }
-
- public static Object fromString( String s ) {
- final byte [] data = Base64.decodeBase64( s );
- ObjectInputStream ois = null;
- try {
- ois = new ObjectInputStream(new ByteArrayInputStream( data ) );
- return ois.readObject();
- } catch (IOException e) {
- throw new Base64Serializer.Exception(e);
- } catch (ClassNotFoundException e) {
- throw new Base64Serializer.Exception(e);
- } finally {
- try {
- if(ois != null) {
- ois.close();
- }
- } catch (IOException e) {
- throw new Base64Serializer.Exception(e);
- }
- }
- }
-
- public static String toString( Serializable serializable ) {
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = null;
- try {
- oos = new ObjectOutputStream( baos );
- oos.writeObject( serializable );
- return new String( Base64.encodeBase64( baos.toByteArray() ) );
- } catch (IOException e) {
- throw new Base64Serializer.Exception(e);
- } finally {
- try {
- if(oos != null) {
- oos.close();
- }
- } catch (IOException e) {
- throw new Base64Serializer.Exception(e);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/4e07d41e/core/metamodel/src/main/java/org/apache/isis/core/commons/encoding/HexUtils.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/commons/encoding/HexUtils.java b/core/metamodel/src/main/java/org/apache/isis/core/commons/encoding/HexUtils.java
deleted file mode 100644
index de068dd..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/commons/encoding/HexUtils.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.isis.core.commons.encoding;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-import org.apache.commons.codec.DecoderException;
-import org.apache.commons.codec.binary.Hex;
-
-import org.apache.isis.core.commons.exceptions.IsisException;
-
-public final class HexUtils {
-
- private HexUtils() {
- }
-
- public static String encoded(final Object object) {
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- final DataOutputStreamExtended outputImpl = new DataOutputStreamExtended(baos);
- try {
- outputImpl.writeEncodable(object);
- final byte[] byteArray = baos.toByteArray();
- return new String(Hex.encodeHex(byteArray));
- } catch (final IOException e) {
- throw new IsisException("Failed to write object", e);
- }
- }
-
- public static <T> T decoded(final String hexEncoded, Class<T> cls) {
- final char[] chars = hexEncoded.toCharArray();
- byte[] bytes;
- try {
- bytes = Hex.decodeHex(chars);
- final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- final DataInputStreamExtended inputImpl = new DataInputStreamExtended(bais);
- return inputImpl.readEncodable(cls);
- } catch (final IOException ex) {
- throw new IsisException("Failed to read object", ex);
- } catch (final DecoderException ex) {
- throw new IsisException("Failed to hex decode object", ex);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/4e07d41e/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/forsession/DisableForSessionFacetViaMethod.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/forsession/DisableForSessionFacetViaMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/forsession/DisableForSessionFacetViaMethod.java
index 4e95be3..6840c71 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/forsession/DisableForSessionFacetViaMethod.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/disabled/forsession/DisableForSessionFacetViaMethod.java
@@ -25,7 +25,6 @@ import java.util.List;
import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.core.commons.authentication.AuthenticationSessionProvider;
-import org.apache.isis.core.commons.authentication.AuthenticationSessionUtils;
import org.apache.isis.core.commons.lang.MethodExtensions;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
import org.apache.isis.core.metamodel.facets.ImperativeFacet;
@@ -67,7 +66,7 @@ public class DisableForSessionFacetViaMethod extends DisableForSessionFacetAbstr
}
final int len = method.getParameterTypes().length;
final Object[] parameters = new Object[len];
- parameters[0] = AuthenticationSessionUtils.createUserMemento(session);
+ parameters[0] = session.createUserMemento();
// TODO: need to change to pick up as non-static rather than static
return (String) MethodExtensions.invokeStatic(method, parameters);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/4e07d41e/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/hidden/forsession/HideForSessionFacetViaMethod.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/hidden/forsession/HideForSessionFacetViaMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/hidden/forsession/HideForSessionFacetViaMethod.java
index 5d00c8b..294aa24 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/hidden/forsession/HideForSessionFacetViaMethod.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/members/hidden/forsession/HideForSessionFacetViaMethod.java
@@ -25,7 +25,6 @@ import java.util.List;
import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.core.commons.authentication.AuthenticationSessionProvider;
-import org.apache.isis.core.commons.authentication.AuthenticationSessionUtils;
import org.apache.isis.core.commons.lang.MethodExtensions;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
import org.apache.isis.core.metamodel.facets.ImperativeFacet;
@@ -66,7 +65,7 @@ public class HideForSessionFacetViaMethod extends HideForSessionFacetAbstract im
}
final int len = method.getParameterTypes().length;
final Object[] parameters = new Object[len];
- parameters[0] = AuthenticationSessionUtils.createUserMemento(session);
+ parameters[0] = session.createUserMemento();
// TODO: need to change to pick up as non-static rather than static
final Boolean isHidden = (Boolean) MethodExtensions.invokeStatic(method, parameters);
return isHidden.booleanValue() ? "Hidden" : null;