All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.geode.security.NotAuthorizedException Maven / Gradle / Ivy

Go to download

Apache Geode provides a database-like consistency model, reliable transaction processing and a shared-nothing architecture to maintain very low latency performance with high concurrency processing

There is a newer version: 1.15.1
Show newest version
/*
 * 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.geode.security;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.security.Principal;
import javax.naming.NamingException;

/**
 * Thrown when a client/peer is unauthorized to perform a requested operation.
 * 
 * @since GemFire 5.5
 */
public class NotAuthorizedException extends GemFireSecurityException {

  private static final long serialVersionUID = 419215768216387745L;

  private Principal principal = null;

  /**
   * Constructs a new exception with the specified detail message and principal.
   *
   * @param message the detail message (which is saved for later retrieval by the
   *        {@link #getMessage()} method). (A null value is permitted.)
   */
  public NotAuthorizedException(final String message) {
    this(message, null, null);
  }

  /**
   * Constructs a new exception with the specified detail message and cause.
   *
   * 

* If {@code message} is null, then the detail message associated with {@code cause} is * automatically used as this exception's detail message. * * @param message the detail message (which is saved for later retrieval by the * {@link #getMessage()} method). (A null value is permitted.) * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). * (A null value is permitted, and indicates that the cause is nonexistent or * unknown.) */ public NotAuthorizedException(final String message, final Throwable cause) { this(message, cause, null); } /** * Constructs a new exception with the specified detail message and principal. * * @param message the detail message (which is saved for later retrieval by the * {@link #getMessage()} method). (A null value is permitted.) * @param principal the principal for which authorization failed. (A null value is * permitted.) */ public NotAuthorizedException(final String message, final Principal principal) { this(message, null, principal); } /** * Constructs a new exception with the specified detail message, cause and principal. * *

* If {@code message} is null, then the detail message associated with {@code cause} is * automatically used as this exception's detail message. * * @param message the detail message (which is saved for later retrieval by the * {@link #getMessage()} method). (A null value is permitted.) * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). * (A null value is permitted, and indicates that the cause is nonexistent or * unknown.) * @param principal the principal for which authorization failed. (A null value is * permitted.) */ public NotAuthorizedException(final String message, final Throwable cause, final Principal principal) { super(message, cause); this.principal = principal; } /** * Returns the {@code principal} for which authorization failed. * * @return the {@code principal} for which authorization failed. */ public synchronized Principal getPrincipal() { return this.principal; } private synchronized void writeObject(final ObjectOutputStream out) throws IOException { final Principal thisPrincipal = this.principal; if (!isSerializable(thisPrincipal)) { this.principal = null; } final Object resolvedObj = getResolvedObj(); NamingException namingException = null; if (!isSerializable(resolvedObj)) { namingException = (NamingException) getCause(); namingException.setResolvedObj(null); } try { out.defaultWriteObject(); } finally { this.principal = thisPrincipal; if (namingException != null) { namingException.setResolvedObj(resolvedObj); } } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy