Skip to content

Commit

Permalink
Fix check style errors in openam-shared
Browse files Browse the repository at this point in the history
  • Loading branch information
phillcunnington committed Nov 30, 2015
1 parent 11b2197 commit c49a898
Show file tree
Hide file tree
Showing 85 changed files with 1,249 additions and 777 deletions.
12 changes: 12 additions & 0 deletions checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
<suppress checks=".*" files="/src/main/java/com/sun/identity/" />
<suppress checks=".*" files="/src/test/java/com/sun/identity/" />

<!--
Suppress all checks on legacy resources in openam-shared.
-->
<suppress checks=".*" files="/src/main/resources/amUtilMsgs.properties" />
<suppress checks=".*" files="/src/main/resources/de_DE/amUtilMsgs_de.properties" />
<suppress checks=".*" files="/src/main/resources/es_ES/amUtilMsgs_es.properties" />
<suppress checks=".*" files="/src/main/resources/fr_FR/amUtilMsgs_fr.properties" />
<suppress checks=".*" files="/src/main/resources/ja_JP/amUtilMsgs_ja.properties" />
<suppress checks=".*" files="/src/main/resources/ko_KR/amUtilMsgs_ko.properties" />
<suppress checks=".*" files="/src/main/resources/zh_CN/amUtilMsgs_zh.properties" />
<suppress checks=".*" files="/src/main/resources/zh_TW/amUtilMsgs_zh_TW.properties" />

<!--
Suppress certain checks on unit tests.
-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public class ServicesDefaultValues {
private static Set preappendSlash = new HashSet();
private static Set trimSlash = new HashSet();
private Map defValues = new HashMap();
private static ValidateIPaddress ipValidator = new ValidateIPaddress();

static {
preappendSlash.add(SetupConstants.CONFIG_VAR_PRODUCT_NAME);
Expand Down Expand Up @@ -330,7 +329,7 @@ private static String getCookieDomain(
) {
int idx = hostname.lastIndexOf(".");
if ((idx == -1) || (idx == (hostname.length() -1)) ||
ipValidator.isValidIP(hostname)
ValidateIPaddress.isValidIP(hostname)
) {
cookieDomain = "";
} else if ((cookieDomain == null) || (cookieDomain.length() == 0)) {
Expand Down
4 changes: 4 additions & 0 deletions openam-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<artifactId>openam-shared</artifactId>
<packaging>jar</packaging>

<properties>
<checkstyleFailOnError>true</checkstyleFailOnError>
</properties>

<!-- Build -->
<build>
<plugins>
Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -11,57 +11,55 @@
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2014 ForgeRock AS.
* Copyright 2014-2015 ForgeRock AS.
*/

package org.forgerock.openam.federation.saml2;

import java.util.List;

/**
*
* Enables the storing/recovering serialized state of SAML2 Tokens when in SAML2 failover-mode.
* It is in the OpenAM Shared package so that the Federation Library does not need to have
* a dependency on OpenAM Core and visa-versa.
*
*/
public interface SAML2TokenRepository {

/**
* Retrieves an existing SAML2 object from the CTS as an un-cast Object using the passed primary key.
*
* @param primaryKey primary key
* @return The object found in the repository or null if not found.
* @throws SAML2TokenRepositoryException if there was a problem accessing the SAML2 Token Repository
*/
public Object retrieveSAML2Token(String primaryKey) throws SAML2TokenRepositoryException;
/**
* Retrieves an existing SAML2 object from the CTS as an un-cast Object using the passed primary key.
*
* @param primaryKey primary key
* @return The object found in the repository or null if not found.
* @throws SAML2TokenRepositoryException if there was a problem accessing the SAML2 Token Repository
*/
Object retrieveSAML2Token(String primaryKey) throws SAML2TokenRepositoryException;

/**
* Retrieves a list of existing SAML2 objects from the CTS as un-cast Objects using the passed secondary key.
*
* @param secondaryKey Secondary Key
* @return A non null, but possibly empty collection of SAML2 objects.
* @throws SAML2TokenRepositoryException if there was a problem accessing the SAML2 Token Repository
*/
public List<Object> retrieveSAML2TokensWithSecondaryKey(String secondaryKey) throws SAML2TokenRepositoryException;
/**
* Retrieves a list of existing SAML2 objects from the CTS as un-cast Objects using the passed secondary key.
*
* @param secondaryKey Secondary Key
* @return A non null, but possibly empty collection of SAML2 objects.
* @throws SAML2TokenRepositoryException if there was a problem accessing the SAML2 Token Repository
*/
List<Object> retrieveSAML2TokensWithSecondaryKey(String secondaryKey) throws SAML2TokenRepositoryException;

/**
* Deletes the SAML2 object by using the passed primary key from the repository
*
* @param primaryKey primary key
* @throws SAML2TokenRepositoryException if there was a problem accessing the SAML2 Token Repository
*/
public void deleteSAML2Token(String primaryKey) throws SAML2TokenRepositoryException;
/**
* Deletes the SAML2 object by using the passed primary key from the repository.
*
* @param primaryKey primary key
* @throws SAML2TokenRepositoryException if there was a problem accessing the SAML2 Token Repository
*/
void deleteSAML2Token(String primaryKey) throws SAML2TokenRepositoryException;

/**
* Saves SAML2 data into the SAML2 Repository.
*
* @param primaryKey Primary key.
* @param secondaryKey Secondary Key, can be null
* @param samlObj the SAML2 object to store such as Response, IDPSession.
* @param expirationTime Expiration time in seconds from epoch.
* @throws SAML2TokenRepositoryException if there was a problem accessing the SAML2 Token Repository
*/
public void saveSAML2Token(String primaryKey, String secondaryKey, Object samlObj, long expirationTime)
/**
* Saves SAML2 data into the SAML2 Repository.
*
* @param primaryKey Primary key.
* @param secondaryKey Secondary Key, can be null
* @param samlObj the SAML2 object to store such as Response, IDPSession.
* @param expirationTime Expiration time in seconds from epoch.
* @throws SAML2TokenRepositoryException if there was a problem accessing the SAML2 Token Repository
*/
void saveSAML2Token(String primaryKey, String secondaryKey, Object samlObj, long expirationTime)
throws SAML2TokenRepositoryException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,32 @@
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2014 ForgeRock AS.
* Copyright 2014-2015 ForgeRock AS.
*/

package org.forgerock.openam.federation.saml2;

/**
*
* This class is used to wrap Exceptions thrown by implementations of the SAML2TokenRepository.
*
*/
public class SAML2TokenRepositoryException extends Exception {

/**
* Constructs a new SAML2TokenRepositoryException with the specified detail message and
* cause.
*
* @param error The detail message.
* @param cause The cause.
*/
public SAML2TokenRepositoryException(String error, Throwable cause) {
super(error, cause);
}

/**
* Constructs a new SAML2TokenRepositoryException with the specified detail message.
*
* @param error The detail message.
*/
public SAML2TokenRepositoryException(String error) {
super(error);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2015 ForgeRock AS.
*/

/**
* This package contains SAML2 federation utilities for use throughout the OpenAM codebase.
*/
package org.forgerock.openam.federation.saml2;
29 changes: 0 additions & 29 deletions openam-shared/src/main/java/org/forgerock/openam/package-info.java

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2014 ForgeRock AS.
* Copyright 2014-2015 ForgeRock AS.
*/

package org.forgerock.openam.shared.concurrency;

import java.lang.ref.Reference;
Expand All @@ -39,6 +40,9 @@ public class LockFactory<K> {

private final Map<Key<K>, Reference<Lock>> lockCache;

/**
* Constructs a new LockFactory instance.
*/
public LockFactory() {
lockCache = new WeakHashMap<Key<K>, Reference<Lock>>();
}
Expand Down Expand Up @@ -106,7 +110,7 @@ public boolean equals(Object o) {
return false;
}

final Key<?> key = (Key<?>)o;
final Key<?> key = (Key<?>) o;
return value == null ? key.value == null : value.equals(key.value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public class ResizableLinkedBlockingQueue<E> extends LinkedBlockingQueue<E> {
private final ResizableSemaphore availablePlaces;

/**
* {@inheritdoc}
* Creates a {@code ResizableLinkedBlockingQueue} with a capacity of
* {@link Integer#MAX_VALUE}.
*/
public ResizableLinkedBlockingQueue() {
super();
Expand All @@ -44,7 +45,14 @@ public ResizableLinkedBlockingQueue() {
}

/**
* {@inheritdoc}
* Creates a {@code ResizableLinkedBlockingQueue} with a capacity of
* {@link Integer#MAX_VALUE}, initially containing the elements of the
* given collection,
* added in traversal order of the collection's iterator.
*
* @param c the collection of elements to initially contain
* @throws NullPointerException if the specified collection or any
* of its elements are null
*/
public ResizableLinkedBlockingQueue(Collection<? extends E> c) {
super(c);
Expand All @@ -53,7 +61,12 @@ public ResizableLinkedBlockingQueue(Collection<? extends E> c) {
}

/**
* {@inheritdoc}
* Creates a {@code ResizableLinkedBlockingQueue} with the given number of
* permits.
*
* @param initialCapacity the initial number of permits available.
* This value may be negative, in which case releases
* must occur before any acquires will be granted.
*/
public ResizableLinkedBlockingQueue(int initialCapacity) {
super();
Expand Down Expand Up @@ -97,9 +110,6 @@ public int getMaximumQueueSize() {
return queueSize;
}

/**
* {@inheritdoc}
*/
@Override
public boolean offer(E e) {
Reject.ifNull(e, "Element to offer cannot be null.");
Expand All @@ -122,9 +132,6 @@ public boolean offer(E e) {
return returnValue;
}

/**
* {@inheritdoc}
*/
@Override
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException {
Reject.ifNull(e, "Element to offer cannot be null.");
Expand All @@ -147,9 +154,6 @@ public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedExcepti
return returnValue;
}

/**
* {@inheritdoc}
*/
@Override
public E poll() {
E returnValue = super.poll();
Expand All @@ -159,9 +163,6 @@ public E poll() {
return returnValue;
}

/**
* {@inheritdoc}
*/
@Override
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
E resultValue = super.poll(timeout, unit);
Expand All @@ -172,26 +173,17 @@ public E poll(long timeout, TimeUnit unit) throws InterruptedException {
return resultValue;
}

/**
* {@inheritdoc}
*/
@Override
public void put(E e) throws InterruptedException {
availablePlaces.acquire();
super.put(e);
}

/**
* {@inheritdoc}
*/
@Override
public int remainingCapacity() {
return availablePlaces.availablePermits();
}

/**
* {@inheritdoc}
*/
@Override
public boolean remove(Object o) {
if (super.remove(o)) {
Expand All @@ -202,9 +194,6 @@ public boolean remove(Object o) {
return false;
}

/**
* {@inheritdoc}
*/
@Override
public E take() throws InterruptedException {
E result = super.take();
Expand Down
Loading

0 comments on commit c49a898

Please sign in to comment.